Skip to content

Commit c2c6a99

Browse files
authored
chore: add missing documentation, hide private (#62)
Adds some missing documentation and typespecs. Hides implementation details from the docs
1 parent fcd6893 commit c2c6a99

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

lib/openid_connect.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ defmodule OpenIDConnect do
330330
defp audience_matches?(aud, expected_aud) when is_list(aud), do: Enum.member?(aud, expected_aud)
331331
defp audience_matches?(aud, expected_aud), do: aud === expected_aud
332332

333+
@doc """
334+
Fetch claims about the authenticated end-user
335+
336+
For more information, see the [OpenID Connect Spec](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
337+
"""
338+
@spec fetch_userinfo(config(), jwt()) :: {:ok, response :: map()} | {:error, term()}
333339
def fetch_userinfo(config, access_token) do
334340
discovery_document_uri = config.discovery_document_uri
335341

lib/openid_connect/application.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule OpenIDConnect.Application do
2+
@moduledoc false
23
use Application
34

45
def start(_type, _args) do

lib/openid_connect/document.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ defmodule OpenIDConnect.Document do
1414
jwks: nil,
1515
expires_at: nil
1616

17+
@type t :: %__MODULE__{}
18+
1719
@refresh_time_seconds Application.compile_env(
1820
:openid_connect,
1921
:document_max_expiration_seconds,
2022
60 * 60
2123
)
2224

25+
@doc """
26+
Fetches an OIDC document from cache, falling back to fetching from the remote resource
27+
"""
28+
@spec fetch_document(String.t()) :: {:ok, t()} | {:error, term()}
2329
def fetch_document(uri) do
2430
with :error <- Cache.fetch(uri),
2531
{:ok, document_json, document_expires_at} <- fetch_remote_resource(uri),

lib/openid_connect/document/cache.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule OpenIDConnect.Document.Cache do
2+
@moduledoc false
23
use GenServer
34
alias OpenIDConnect.Document
45

0 commit comments

Comments
 (0)