ExAcme.AccountKey (ExAcme v0.2.0)

View Source

Handles the ACME account key operations.

Provides functionalities to generate keys, sign requests, and manage key identifiers.

Attributes

  • key - The JOSE JSON Web Key (JWK).
  • type - The type of the key (e.g., :ec256, :ed25519).
  • kid - The Key ID assigned by the server.

Summary

Types

t()

Account key for authenticating requests

Functions

Deserializes the account key from JSON.

Generates a new account key.

Signs a request body with the account key.

Generates the thumbprint of the account key.

Serializes the account key to JSON.

Converts the account key to its public representation.

Updates the Key ID (KID) of the account key.

Types

t()

@type t() :: %ExAcme.AccountKey{
  key: JOSE.JWK.t(),
  kid: String.t() | nil,
  type: atom()
}

Account key for authenticating requests

Functions

from_json(json)

@spec from_json(String.t()) :: {:ok, t()} | {:error, term()}

Deserializes the account key from JSON.

Parameters

  • json - The JSON string representing the account key.

Returns

  • {:ok, %ExAcme.AccountKey{}} on success.
  • {:error, reason} on failure.

generate(type \\ :ec256)

@spec generate(atom()) :: t()

Generates a new account key.

Parameters

  • type - The type of key to generate (:ec256 or :ed25519). Defaults to :ec256.

Returns

  • %ExAcme.AccountKey{} struct.

sign(account_key, body, header)

@spec sign(t(), binary(), map()) :: map()

Signs a request body with the account key.

Parameters

  • account_key - The account key.
  • body - The request body to sign.
  • header - Additional headers.

Returns

  • The signed JWS.

thumbprint(account_key)

@spec thumbprint(t()) :: String.t()

Generates the thumbprint of the account key.

Parameters

  • account_key - The account key.

Returns

  • The thumbprint as a string.

to_json(account_key)

@spec to_json(t()) :: String.t()

Serializes the account key to JSON.

Parameters

  • account_key - The account key.

Returns

  • JSON string representation of the account key.

to_public(account_key)

@spec to_public(t()) :: map()

Converts the account key to its public representation.

Parameters

  • account_key - The account key.

Returns

  • A map representing the public JWK.

update_kid(account_key, kid)

@spec update_kid(t(), String.t()) :: t()

Updates the Key ID (KID) of the account key.

Parameters

  • key - The account key.
  • kid - The new Key ID.

Returns

  • Updated %ExAcme.AccountKey{} struct.