OpenPayments.Types.JWK (open_payments_elixir v1.0.0)

Copy Markdown View Source

An Ed25519 public JSON Web Key used by Open Payments.

from_map/1 validates the shared schema's required fields and enum values. An omitted use becomes nil; an explicit null is invalid. Additional JSON metadata is preserved in extensions.

This public type rejects the private d parameter and excludes it from export, including when a struct is manually modified. Its inspection omits extensions. Private-key import belongs to the signing utilities.

Validation checks the schema's nonempty base64url alphabet for x. It does not establish that the value decodes to a usable 32-byte Ed25519 key. Cryptographic key validation and key selection are separate from decoding response data.

Struct literals can bypass validation. Call validate/1 after constructing or modifying a struct; to_map/1 converts its shape without validating it.

Summary

Functions

Decodes and validates a public JWK JSON object.

Converts a public JWK to JSON fields, excluding private key material.

Validates a public JWK struct, treating nil use as omitted.

Types

t()

@type t() :: %OpenPayments.Types.JWK{
  alg: String.t(),
  crv: String.t(),
  extensions: %{optional(String.t()) => term()},
  kid: String.t(),
  kty: String.t(),
  use: String.t() | nil,
  x: String.t()
}

Functions

from_map(data)

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

Decodes and validates a public JWK JSON object.

to_map(key)

@spec to_map(t()) :: map()

Converts a public JWK to JSON fields, excluding private key material.

validate(key)

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

Validates a public JWK struct, treating nil use as omitted.