Parse an OID4VCI Credential Offer (draft-ietf-oauth-openid4vci §4.1) the
wallet receives - the holder-side mirror of Attesto.CredentialOffer.build/1.
A Credential Offer reaches the wallet in one of three shapes:
- by value, as a decoded JSON object or a raw JSON string;
- as an
openid-credential-offer://deep link carrying the offer, JSON encoded, in itscredential_offerquery parameter; or - as an
openid-credential-offer://deep link carrying acredential_offer_uriquery parameter, from which the wallet fetches the offer object itself.
parse/1 handles the first two forms directly and returns {:fetch, uri}
for the third, deferring the network fetch to fetch/2. This keeps parsing
conn-free and testable without a live issuer; fetch/2 performs the GET
(through AttestoClient.OAuthHTTP, so it is mockable the same way as the
rest of this library) and parses the result the same way.
Summary
Functions
Fetch a by-reference offer from credential_offer_uri and parse it.
Parse an offer the wallet received: a decoded JSON object, a raw JSON
string, or an openid-credential-offer:// deep link.
Types
@type error() ::
:invalid_credential_offer
| :invalid_json
| :invalid_credential_issuer
| :invalid_credential_configuration_ids
| :invalid_grants
| :invalid_authorization_code_grant
| :invalid_pre_authorized_code_grant
| :invalid_tx_code
| :missing_credential_offer
| :ambiguous_credential_offer
@type grants() :: %{ pre_authorized_code: pre_authorized_code_grant() | nil, authorization_code: authorization_code_grant() | nil }
@type tx_code() :: %{ input_mode: String.t() | nil, length: pos_integer() | nil, description: String.t() | nil }
Functions
Fetch a by-reference offer from credential_offer_uri and parse it.
HTTP goes through AttestoClient.OAuthHTTP.get_json/2, so it is mockable
the same way as the rest of this library (req_options: [plug: ...]).
Parse an offer the wallet received: a decoded JSON object, a raw JSON
string, or an openid-credential-offer:// deep link.
Returns {:ok, offer} for a by-value offer, {:fetch, uri} when the deep
link carries credential_offer_uri (pass uri to fetch/2), or
{:error, reason}.