OpenPayments.Types.GrantClient (open_payments_elixir v1.0.0)

Copy Markdown View Source

A grant request's client identity, preserving all three protocol forms.

from_value/1 accepts a wallet-address string, a walletAddress object, or a directed-identity jwk object. Object forms support optional typed display information and forbid extra fields. Wallet and JWK identities are mutually exclusive. The string form is deprecated by the pinned specification but remains supported without silently converting it to an object.

Wallet values follow the schema's absolute-URI format without normalization or payment-pointer resolution. Directed identity contains a public Types.JWK; it does not import a private signing key. This type does not fetch wallet keys, check that a JWK matches the signing key, or decide whether a grant is interactive. Directed identity's non-interactive restriction belongs to grant-request validation.

Inspection omits JWK/display data. to_value/1 and JSON encoding preserve wire shape and public JWK metadata. Validate manually modified structs with validate/1; encoding converts shape without validating it.

Summary

Functions

Decodes a protocol client string or object into a validated identity.

Converts to the original protocol string/object shape without validating.

Checks the identity form and typed nested fields without performing HTTP.

Types

t()

@type t() :: %OpenPayments.Types.GrantClient{
  display: OpenPayments.Types.ClientDisplay.t() | nil,
  jwk: OpenPayments.Types.JWK.t() | nil,
  kind: :wallet_string | :wallet_address | :directed_identity,
  wallet_address: String.t() | nil
}

Functions

from_value(value)

@spec from_value(term()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}

Decodes a protocol client string or object into a validated identity.

to_value(client)

@spec to_value(t()) :: String.t() | map()

Converts to the original protocol string/object shape without validating.

validate(client)

@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}

Checks the identity form and typed nested fields without performing HTTP.