Layr8.Credentials (layr8 v0.2.6)

Copy Markdown View Source

W3C Verifiable Credential operations via the Layr8 cloud-node REST API.

All functions accept a Layr8.REST client and keyword options.

Example

rest = Layr8.REST.new("https://node.example.com", "my-api-key")
{:ok, jwt} = Layr8.Credentials.sign_credential(rest, credential, issuer_did: "did:example:alice")

Summary

Functions

Retrieves a stored credential by ID.

Lists stored credentials for a holder.

Signs a W3C Verifiable Credential using the issuer's assertion key.

Stores a signed credential JWT for a holder in the cloud-node credential store.

Verifies a signed credential using the verifier DID's assertion key.

Types

credential()

@type credential() :: map()

credential_format()

@type credential_format() :: String.t()

stored_credential()

@type stored_credential() :: map()

Functions

get_credential(rest, credential_id)

@spec get_credential(Layr8.REST.t(), String.t()) ::
  {:ok, stored_credential()} | {:error, term()}

Retrieves a stored credential by ID.

Returns {:ok, stored_credential()} or {:error, reason}.

list_credentials(rest, opts \\ [])

@spec list_credentials(
  Layr8.REST.t(),
  keyword()
) :: {:ok, [stored_credential()]} | {:error, term()}

Lists stored credentials for a holder.

Options

  • :holder_did — holder DID (default: agent DID)

Returns {:ok, [stored_credential()]} or {:error, reason}.

sign_credential(rest, credential, opts \\ [])

@spec sign_credential(Layr8.REST.t(), credential(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Signs a W3C Verifiable Credential using the issuer's assertion key.

Options

  • :issuer_did — issuer DID (default: agent DID)
  • :format — output format: "compact_jwt" (default), "json", "jwt", "enveloped"

Returns {:ok, signed_jwt} or {:error, reason}.

store_credential(rest, credential_jwt, opts \\ [])

@spec store_credential(Layr8.REST.t(), String.t(), keyword()) ::
  {:ok, stored_credential()} | {:error, term()}

Stores a signed credential JWT for a holder in the cloud-node credential store.

Options

  • :holder_did — holder DID (default: agent DID)
  • :issuer_did — issuer DID metadata (optional)
  • :valid_until — ISO 8601 expiration string (optional)

Returns {:ok, stored_credential} or {:error, reason}.

verify_credential(rest, signed_credential, opts \\ [])

@spec verify_credential(Layr8.REST.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Verifies a signed credential using the verifier DID's assertion key.

Options

  • :verifier_did — verifier DID (default: agent DID)

Returns {:ok, verified} or {:error, reason}.