.. index:: single: jwt_jwks
.. _jwt_jwks/0:

.. rst-class:: right

**object**

``jwt_jwks``
============

JSON Web Key Set validation and key selection helpers.

| **Availability:** 
|    ``logtalk_load(jwt(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-07-06

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`jwt_helpers <jwt_helpers/0>`
| **Uses:**
|    :ref:`jwt_jwa <jwt_jwa/0>`
|    :ref:`jwt_jwk <jwt_jwk/0>`
|    :ref:`list <list/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: validate/1
.. _jwt_jwks/0::validate/1:

``validate/1``
^^^^^^^^^^^^^^

Validates that a term is a JSON Web Key Set.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``validate(JWKSet)``
| **Mode and number of proofs:**
|    ``validate(+term)`` - ``one_or_error``

| **Exceptions:**
|    ``JWKSet`` is not a JSON Web Key Set with a ``keys`` list:
|        ``domain_error(jwt_jwks,JWKSet)``


------------

.. index:: select_key/3
.. _jwt_jwks/0::select_key/3:

``select_key/3``
^^^^^^^^^^^^^^^^

Selects a matching verification key from a JWK Set for a JWT header.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``select_key(JWKSet,Header,Key)``
| **Mode and number of proofs:**
|    ``select_key(+term,+term,-term)`` - ``one_or_error``

| **Exceptions:**
|    ``JWKSet`` is not a JSON Web Key Set with a ``keys`` list:
|        ``domain_error(jwt_jwks,JWKSet)``
|    ``Header`` does not contain a valid ``alg`` member:
|        ``domain_error(jwt_header,Header)``
|    The JWT algorithm is unsupported or disallowed:
|        ``domain_error(jwt_algorithm,Algorithm)``
|    No compatible key exists for ``Header``:
|        ``existence_error(jwt_jwk,Header)``


------------

.. index:: select_key/4
.. _jwt_jwks/0::select_key/4:

``select_key/4``
^^^^^^^^^^^^^^^^

Selects a matching verification key from a JWK Set for a JWT header and options.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``select_key(JWKSet,Header,Key,Options)``
| **Mode and number of proofs:**
|    ``select_key(+term,+term,-term,+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    An element ``Option`` of the list ``Options`` is neither a variable nor a compound term:
|        ``type_error(compound,Option)``
|    An element ``Option`` of the list ``Options`` is a compound term but not a valid option:
|        ``domain_error(option,Option)``
|    ``JWKSet`` is not a JSON Web Key Set with a ``keys`` list:
|        ``domain_error(jwt_jwks,JWKSet)``
|    ``Header`` does not contain a valid ``alg`` member:
|        ``domain_error(jwt_header,Header)``
|    The JWT algorithm is unsupported or disallowed:
|        ``domain_error(jwt_algorithm,Algorithm)``
|    No compatible key exists for ``Header``:
|        ``existence_error(jwt_jwk,Header)``


------------

.. index:: select_keys/4
.. _jwt_jwks/0::select_keys/4:

``select_keys/4``
^^^^^^^^^^^^^^^^^

Selects all matching verification keys from a JWK Set for a JWT header and options.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``select_keys(JWKSet,Header,Keys,Options)``
| **Mode and number of proofs:**
|    ``select_keys(+term,+term,-list(term),+list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Options`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Options`` is neither a variable nor a list:
|        ``type_error(list,Options)``
|    An element ``Option`` of the list ``Options`` is neither a variable nor a compound term:
|        ``type_error(compound,Option)``
|    An element ``Option`` of the list ``Options`` is a compound term but not a valid option:
|        ``domain_error(option,Option)``
|    ``JWKSet`` is not a JSON Web Key Set with a ``keys`` list:
|        ``domain_error(jwt_jwks,JWKSet)``
|    ``Header`` does not contain a valid ``alg`` member:
|        ``domain_error(jwt_header,Header)``
|    The JWT algorithm is unsupported or disallowed:
|        ``domain_error(jwt_algorithm,Algorithm)``
|    No compatible key exists for ``Header``:
|        ``existence_error(jwt_jwk,Header)``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

