+
    ÆÚj_3  ã                  ó  € ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt	^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^RIHtHt ^R	IHt ^R
IHtHt ^RIHt  ! R R]	P@                  PB                  4      t" ! R R4      t#R# )é    )ÚannotationsN)Ú	lru_cache)Ú
SSLContext)ÚAny)Ú	HTTPErrorÚURLError)Úurlparse)ÚPyJWKÚPyJWKSet)Údecode_complete)ÚPyJWKClientConnectionErrorÚPyJWKClientError)ÚJWKSetCachec                  ó"   € ] tR t^tR R ltRtR# )Ú_NoRedirectHandlerc               ó4   € V ^8„  d   QhRRRRRRRRR	RR
RRR/# )é   Úreqzurllib.request.RequestÚfpr   ÚcodeÚintÚmsgÚstrÚheadersÚnewurlÚreturnzurllib.request.Request | None© )Úformats   "Ú†/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/jwt/jwks_client.pyÚ__annotate__Ú_NoRedirectHandler.__annotate__   sP   € ÷ 	ñ 	à#ð	ð ð	ð ð		ð
 ð	ð ð	ð ð	ð 
'ñ	ó    c                	ó   € R # )Nr   )Úselfr   r   r   r   r   r   s   &&&&&&&r   Úredirect_requestÚ#_NoRedirectHandler.redirect_request   s   € ñ r"   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r%   Ú__static_attributes__r   r"   r   r   r      s   † ÷	ñ 	r"   r   c                  ó¬   € ] tR t^"tRR R lltR R ltRR R llt]R R	 l4       tRR
 R llt	]R R l4       t
R R ltR R lt]R R l4       tRtR# )ÚPyJWKClientNc               ó<   € V ^8„  d   QhRRRRRRRRRR	R
RRR	RRRR	/	# )r   Úurir   Ú
cache_keysÚboolÚmax_cached_keysr   Úcache_jwk_setÚlifespanÚfloatr   zdict[str, Any] | NoneÚtimeoutÚssl_contextzSSLContext | NoneÚcooldown_durationr   )r   s   "r   r    ÚPyJWKClient.__annotate__#   so   € ÷ n3ñ n3àðn3ð ðn3ð ð	n3ð
 ðn3ð ðn3ð 'ðn3ð ðn3ð 'ðn3ð !ñn3r"   c
                óX  € Vf   / p\        V4      P                  P                  4       p
V
R	9  d   \        RV
: R24      hWn        RV n        W`n        Wpn        W€n        V	^ 8  d   \        RV	 R24      h\        P                  ! V	4      '       g   \        RV	 R24      hW�n        RV n        \        P                  ! 4       V n        V'       d(   V^ 8:  d   \        RV R24      h\!        V4      V n        MRV n        V'       d%   \#        VR7      ! V P$                  4      pW°n        R# R# )
u¼  A client for retrieving signing keys from a JWKS endpoint.

``PyJWKClient`` uses a two-tier caching system to avoid unnecessary
network requests:

**Tier 1 â€” JWK Set cache** (enabled by default):
Caches the entire JSON Web Key Set response from the endpoint.
Controlled by:

- ``cache_jwk_set``: Set to ``True`` (the default) to enable this
  cache. When enabled, the JWK Set is fetched from the network only
  when the cache is empty or expired.
- ``lifespan``: Time in seconds before the cached JWK Set expires.
  Defaults to ``300`` (5 minutes). Must be greater than 0.

Unknown key IDs can trigger one forced refresh after the cooldown
period configured by ``cooldown_duration``. Every successful fetch
starts this cooldown, including the initial fetch and cache-expiry
fetches. A newly rotated key may therefore wait for the cooldown
period before it is fetched; set ``cooldown_duration`` to ``0`` to
disable this behavior. The cooldown is bypassed when
``cache_jwk_set`` is ``False``.

**Tier 2 â€” Signing key cache** (disabled by default):
Caches individual signing keys (looked up by ``kid``) using an LRU
cache with **no time-based expiration**. Keys are evicted only when
the cache reaches its maximum size. Controlled by:

- ``cache_keys``: Set to ``True`` to enable this cache.
  Defaults to ``False``.
- ``max_cached_keys``: Maximum number of signing keys to keep in
  the LRU cache. Defaults to ``16``.

:param uri: The URL of the JWKS endpoint.
:type uri: str
:param cache_keys: Enable the per-key LRU cache (Tier 2).
:type cache_keys: bool
:param max_cached_keys: Max entries in the signing key LRU cache.
:type max_cached_keys: int
:param cache_jwk_set: Enable the JWK Set response cache (Tier 1).
:type cache_jwk_set: bool
:param lifespan: TTL in seconds for the JWK Set cache.
:type lifespan: float
:param headers: Optional HTTP headers to include in requests.
:type headers: dict or None
:param timeout: HTTP request timeout in seconds.
:type timeout: float
:param ssl_context: Optional SSL context for the request.
:type ssl_context: ssl.SSLContext or None
:param cooldown_duration: Minimum time in seconds between forced
    refreshes after an unknown key ID. Defaults to ``30``.
:type cooldown_duration: float
NzInvalid JWKS URI scheme z(: only 'http' and 'https' are supported.zDCooldown duration must be greater than or equal to 0, the input is "Ú"z0Cooldown duration must be finite, the input is "z/Lifespan must be greater than 0, the input is ")Úmaxsize)ÚhttpÚhttps)r	   ÚschemeÚlowerr   r/   Újwk_set_cacher   r6   r7   ÚmathÚisfiniter8   Ú_last_successful_fetchÚ	threadingÚRLockÚ_client_lockr   r   Úget_signing_key)r$   r/   r0   r2   r3   r4   r   r6   r7   r8   r?   rH   s   &&&&&&&&&&  r   Ú__init__ÚPyJWKClient.__init__#   sB  € ðB Š?ØˆGô
 ˜#“×%Ñ%×+Ñ+Ó-ˆØÐ*Ô*Ü"Ø*¨6©*ð 5!ð "óð ð ŒØ15ˆÔØŒØŒØ&ÔØ˜qÔ Ü"ð!Ø!2Ð 3°1ð6óð ô �}Š}Ð.×/Ò/Ü"ØBÐCTÐBUÐUVÐWóð ð "3ÔØ48ˆÔ#Ü%ŸOšOÓ-ˆÔçð ˜1Œ}Ü&ØEÀhÀZÈqÐQóð ô "-¨XÓ!6ˆDÕà!%ˆDÔçä'°Õ@À×AUÑAUÓVˆOà#2Ö ñ	 r"   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r    r9   “   s   € ÷ )ñ )˜Cñ )r"   c                óv  €  \         P                  P                  V P                  V P                  R7      p\        4       .pV P                  e:   VP                  \         P                  P                  V P                  R7      4       \         P                  P                  ! V!  pVP                  WP                  R7      ;_uu_ 4       p\        P                  ! V4      pRRR4       T P/                  X4      pT P0                  e   T P0                  P3                  T4       \4        P6                  ! 4       T n        T#   + '       g   i     Lf; i  \        \        \         P"                  P$                  3 d<   p\'        T\(        4      '       d   TP+                  4        \-        RT R24      ThRp?ii ; i)aç  Fetch the JWK Set from the JWKS endpoint.

Makes an HTTP request to the configured ``uri`` and returns the
parsed JSON response. If the JWK Set cache is enabled, the
response is stored in the cache.

:returns: The parsed JWK Set as a dictionary.
:raises PyJWKClientConnectionError: If the HTTP request fails.
:raises PyJWKClientError: If the endpoint does not return a JSON
    object.
:raises PyJWKSetError: If the JWK Set cache is enabled and the
    response contains no usable keys.
)Úurlr   N)Úcontext)r6   z'Fail to fetch data from the url, err: "r;   )ÚurllibÚrequestÚRequestr/   r   r   r7   ÚappendÚHTTPSHandlerÚbuild_openerÚopenr6   ÚjsonÚloadr   ÚTimeoutErrorr=   ÚclientÚHTTPExceptionÚ
isinstancer   Úcloser   Ú_as_jwk_set_payloadrA   ÚputÚtimeÚ	monotonicrD   )r$   ÚrÚhandlersÚopenerÚresponseÚjwk_setÚes   &      r   Ú
fetch_dataÚPyJWKClient.fetch_data“   sD  € ð	Ü—‘×&Ñ&¨4¯8©8¸T¿\¹\Ð&ÓJˆAÜ#5Ó#7Ð"8ˆHØ×ÑÒ+Ø—‘¤§¡× ;Ñ ;ÀD×DTÑDTÐ ;Ó UÔVÜ—^‘^×0Ò0°(Ñ;ˆFØ—‘˜Q¯©�×5Ô5¸ÜŸ)š) HÓ-�÷ 6ð ×*Ñ*¨7Ó3ˆð ×ÑÒ)Ø×Ñ×"Ñ" 7Ô+Ü&*§n¢nÓ&6ˆÔ#Øˆ÷+ 6×5ûäœ,¬¯©×(AÑ(AÐBô 	Ü˜!œY×'Ò'Ø—‘”	Ü,Ø9¸!¸¸AÐ>óàðûð	ús6   ‚C	E ÃE Ã"E Å E	ÅE ÅE Å*F8Å=6F3Æ3F8c               ó    € V ^8„  d   QhRRRR/# )r   Úrefreshr1   r   r   r   )r   s   "r   r    r9   ¾   s   € ÷ #ñ # 4ð #°Hñ #r"   c                óx  € RpRpV P                   e#   V'       g   V P                   P                  4       pVf   V P                  4       pRp\        V\        4      '       d   TpM%\        P
                  ! V P                  V4      4      pV'       d*   V P                   e   V P                   P                  V4       V# )a  Return the JWK Set, using the cache when available.

:param refresh: Force a fresh fetch from the endpoint, bypassing
    the cache.
:type refresh: bool
:returns: The JWK Set.
:rtype: PyJWKSet
:raises PyJWKClientError: If the endpoint does not return a JSON
    object.
NFT)rA   Úgetrg   r[   r   Ú	from_dictr]   r^   )r$   rj   ÚdataÚfetchedre   s   &&   r   Úget_jwk_setÚPyJWKClient.get_jwk_set¾   sž   € ð ˆØˆØ×ÑÒ)·'Ø×%Ñ%×)Ñ)Ó+ˆDàŠ<Ø—?‘?Ó$ˆDØˆGô
 �dœH×%Ò%Ø‰Gä×(Ò(¨×)AÑ)AÀ$Ó)GÓHˆG÷ �t×)Ñ)Ò5Ø×Ñ×"Ñ" 7Ô+àˆr"   c               ó    € V ^8„  d   QhRRRR/# )r   rn   r   r   zdict[str, Any]r   )r   s   "r   r    r9   ä   s   € ÷ ñ  #ð ¨.ñ r"   c                	óH   € \        V \        4      '       g   \        R 4      hV # )z.The JWKS endpoint did not return a JSON object)r[   Údictr   )rn   s   &r   r]   ÚPyJWKClient._as_jwk_set_payloadã   s    € ä˜$¤×%Ò%Ü"Ð#SÓTÐTàˆr"   c               ó    € V ^8„  d   QhRRRR/# )r   rj   r1   r   úlist[PyJWK]r   )r   s   "r   r    r9   ê   s   € ÷ <ñ <¨ð <¸ñ <r"   c                óF   € V P                  V4      pV P                  V4      # )a_  Return all signing keys from the JWK Set.

Filters the JWK Set to keys whose ``use`` is ``"sig"`` (or
unspecified) and that have a ``kid``.

:param refresh: Force a fresh fetch from the endpoint, bypassing
    the cache.
:type refresh: bool
:returns: A list of signing keys.
:rtype: list[PyJWK]
:raises PyJWKClientError: If no signing keys are found.
)rp   Ú_get_signing_keys_from_jwk_set)r$   rj   re   s   && r   Úget_signing_keysÚPyJWKClient.get_signing_keysê   s%   € ð ×"Ñ" 7Ó+ˆØ×2Ñ2°7Ó;Ð;r"   c               ó    € V ^8„  d   QhRRRR/# )r   re   r   r   rw   r   )r   s   "r   r    r9   û   s   € ÷ 
ñ 
°ð 
¸[ñ 
r"   c                	óº   € V P                    Uu. uF,  pVP                  R9   g   K  VP                  '       g   K*  VNK.  	  ppV'       g   \        R4      hV# u upi )Úsigz2The JWKS endpoint did not contain any signing keys)r~   N)ÚkeysÚpublic_key_useÚkey_idr   )re   Újwk_set_keyÚsigning_keyss   &  r   ry   Ú*PyJWKClient._get_signing_keys_from_jwk_setú   sb   € ð  'Ÿ|š|ó
á+�Ø×)Ñ)¨]Ñ:ô à?J×?QÕ?Q÷ ˆKÙ+ð 	ð 
÷ Ü"Ð#WÓXÐXàÐùò
s   �A§A»Ac               ó    € V ^8„  d   QhRRRR/# )r   Úkidr   r   r
   r   )r   s   "r   r    r9     s   € ÷ #ñ # 3ð #¨5ñ #r"   c                ó4  € V P                   ;_uu_ 4        V P                  4       pV P                  W!4      pV'       g¼   V P                  RJ;'       dJ    V P                  RJ;'       d4    \
        P                  ! 4       V P                  ,
          V P                  8  pV'       g>   V P                  RR7      p\
        P                  ! 4       V n        V P                  W!4      pV'       g   \        RV R24      hVuuRRR4       #   + '       g   i     R# ; i)a~  Return the signing key matching the given ``kid``.

If no match is found in the current JWK Set, the set is refreshed
from the endpoint and the lookup is retried once when the refresh
cooldown permits it.

:param kid: The key ID to look up.
:type kid: str
:returns: The matching signing key.
:rtype: PyJWK
:raises PyJWKClientError: If no matching key is found after
    refreshing.
NT)rj   z,Unable to find a signing key that matches: "r;   )	rG   rz   Ú	match_kidrA   rD   r_   r`   r8   r   )r$   r†   rƒ   Úsigning_keyÚcooling_downs   &&   r   rH   ÚPyJWKClient.get_signing_key  sì   € ð ××ÓØ×0Ñ0Ó2ˆLØŸ.™.¨Ó;ˆKçà×&Ñ&¨dÐ2÷ -ð -Ø×3Ñ3¸4Ð?÷-ð -äŸšÓ(¨4×+FÑ+FÕFØ×,Ñ,ñ-ð ÷ $Ø#'×#8Ñ#8ÀÐ#8Ó#F�LÜ26·.².Ó2B�DÔ/Ø"&§.¡.°Ó"C�Kç"Ü*ØFÀsÀeÈ1ÐMóð ð ÷+ ××Óús$   •>DÁDÁ*;DÂ&ADÃ+DÄD	c               ó    € V ^8„  d   QhRRRR/# )r   Útokenzstr | bytesr   r
   r   )r   s   "r   r    r9   ,  s   € ÷ 7ñ 7¨kð 7¸eñ 7r"   c                ór   € \        VRR/R7      pVR,          pV P                  VP                  R4      4      # )a  Return the signing key for a JWT by reading its ``kid`` header.

Extracts the ``kid`` from the token's unverified header and
delegates to :meth:`get_signing_key`.

:param token: The encoded JWT.
:type token: str or bytes
:returns: The matching signing key.
:rtype: PyJWK
Úverify_signatureF)ÚoptionsÚheaderr†   )Údecode_tokenrH   rl   )r$   r�   Ú
unverifiedr‘   s   &&  r   Úget_signing_key_from_jwtÚ$PyJWKClient.get_signing_key_from_jwt,  s:   € ô " %Ð2DÀeÐ1LÔMˆ
Ø˜HÕ%ˆØ×#Ñ# F§J¡J¨uÓ$5Ó6Ð6r"   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rƒ   rw   r†   r   r   zPyJWK | Noner   )r   s   "r   r    r9   <  s!   € ÷ ñ  ð °#ð ¸,ñ r"   c                óH   € RpV  F  pVP                   V8X  g   K  Tp V# 	  V# )zÿFind a key in *signing_keys* that matches *kid*.

:param signing_keys: The list of keys to search.
:type signing_keys: list[PyJWK]
:param kid: The key ID to match.
:type kid: str
:returns: The matching key, or ``None`` if not found.
:rtype: PyJWK or None
N)r�   )rƒ   r†   r‰   Úkeys   &&  r   rˆ   ÚPyJWKClient.match_kid;  s5   € ð ˆãˆCØ�z‰z˜SÖ Ø!�ØàÐñ  ð
 Ðr"   )	rG   rD   r8   rH   r   rA   r7   r6   r/   )Fé   Ti,  Né   Nr›   )F)r'   r(   r)   r*   rI   rg   rp   Ústaticmethodr]   rz   ry   rH   r”   rˆ   r+   r   r"   r   r-   r-   "   sa   † ÷n3õ`)÷V#ðJ ôó ð÷<ð  ô
ó ð
õ#õJ7ð ôó ôr"   r-   )$Ú
__future__r   Úhttp.clientr=   rV   rB   rE   r_   Úurllib.requestrO   Ú	functoolsr   Ússlr   Útypingr   Úurllib.errorr   r   Úurllib.parser	   Úapi_jwkr
   r   Úapi_jwtr   r’   Ú
exceptionsr   r   rA   r   rP   ÚHTTPRedirectHandlerr   r-   r   r"   r   Ú<module>r©      sW   ðÝ "ã Û Û Û Û Û Ý Ý Ý ß ,Ý !ç $Ý 4ß DÝ &ô
˜Ÿ™×;Ñ;ô 
÷kó kr"   