Lockspire.JwksFetcher (lockspire v1.0.0)

Copy Markdown

Fetches and caches JSON Web Key Sets (JWKS) dynamically using Req and Cachex.

Summary

Functions

Returns the JWKS cache TTL in milliseconds for successful fetches.

Retrieves a parsed JOSE.JWK (which contains the JWKSet) from the given URI.

Forces a bounded cache refresh for the given JWKS URI.

Types

result()

@type result() ::
  {:ok, JOSE.JWK.t()}
  | {:error, {:jwks_fetch_failed, atom() | {atom(), atom() | integer()}}}

Functions

cache_ttl()

@spec cache_ttl() :: pos_integer()

Returns the JWKS cache TTL in milliseconds for successful fetches.

get_keys(uri, opts \\ [])

@spec get_keys(
  String.t(),
  keyword()
) :: result()

Retrieves a parsed JOSE.JWK (which contains the JWKSet) from the given URI.

Hits the network only on cache miss. Strict timeouts are enforced.

refresh_keys(uri, opts \\ [])

@spec refresh_keys(
  String.t(),
  keyword()
) :: result()

Forces a bounded cache refresh for the given JWKS URI.

This bypasses the cached entry, updates the cache only on a successful refetch, and preserves the last-known-good cached entry when the refresh fails.