+
     #ce  c                   sj   ^ RI t ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RIHtHt ^ RI	H
t
 ^ RI	Ht ^ RIHtHt ^ RIHt ^ RIHt R	R
RRRRRRRRRRRR/t Rt  ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R  R!]4      t] ! R" R#]4      4       t ! R$ R%]4      t ! R& R'4      tR# )(i    N)
deprecated)JWExceptionJWKeyNotFound)json_decodejson_encode)JWE)default_allowed_algs)JWKJWKSet)JWSissZIssuersubZSubjectaudZAudienceexpzExpiration Timenbfz
Not Beforeiatz	Issued AtjtizJWT IDTc                   s:   a a ] tR t^(t oRtRV 3R lltRtVtV ;t# )
JWTExpiredzfJSON Web Token is expired.

This exception is raised when a token is expired according to its claims.
c                   < R pV'       d   \        V4      pMRpV'       d   VR\        V4      ,          ,          p\        \        V `  V4       R # )NzToken expired {%s})strsuperr   __init__selfZmessageZ	exceptionZmsg	__class__   &&& 1/usr/lib/python3.14/site-packages/jwcrypto/jwt.pyr   ZJWTExpired.__init__.   s>    g,C!C7S^++Cj$(-     NN	__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell__Z__classcell__r   __classdict__   @@r   r   r   (   s     
. .r   r   c                   s:   a a ] tR t^9t oRtRV 3R lltRtVtV ;t# )JWTNotYetValidzrJSON Web Token is not yet valid.

This exception is raised when a token is not valid yet according to its
claims.
c                r   )NzToken not yet validr   )r   r   r*   r   r   r   r   r   ZJWTNotYetValid.__init__@   s>    g,C'C7S^++Cnd,S1r   r   r   r   r'   r)   r   r*   r*   9   s     2 2r   r*   c                   s:   a a ] tR t^Kt oRtRV 3R lltRtVtV ;t# )JWTMissingClaimkJSON Web Token claim is invalid.

This exception is raised when a claim does not match the expected value.
c                r   NzInvalid Claim Valuer   )r   r   r+   r   r   r   r   r   ZJWTMissingClaim.__init__Q   s>    g,C'C7S^++Cot-c2r   r   r   r   r'   r)   r   r+   r+   K   s     
3 3r   r+   c                   s:   a a ] tR t^\t oRtRV 3R lltRtVtV ;t# )JWTInvalidClaimValuer,   c                r   r-   )r   r   r.   r   r   r   r   r   ZJWTInvalidClaimValue.__init__b   s?    g,C'C7S^++C"D237r   r   r   r   r'   r)   r   r.   r.   \   s     
8 8r   r.   c                   s:   a a ] tR t^mt oRtRV 3R lltRtVtV ;t# )JWTInvalidClaimFormatziJSON Web Token claim format is invalid.

This exception is raised when a claim is not in a valid format.
c                r   )NzInvalid Claim Formatr   )r   r   r/   r   r   r   r   r   ZJWTInvalidClaimFormat.__init__s   s?    g,C(C7S^++C#T3C8r   r   r   r   r'   r)   r   r/   r/   m   s     
9 9r   r/   c                   s:   a a ] tR t^~t oRtRV 3R lltRtVtV ;t# )JWTMissingKeyIDzJSON Web Token is missing key id.

This exception is raised when trying to decode a JWT with a key set
that does not have a kid value in its header.
c                r   )NzMissing Key IDr   )r   r   r0   r   r   r   r   r   ZJWTMissingKeyID.__init__   s>    g,C"C7S^++Cot-c2r   r   r   r   r'   r)   r   r0   r0   ~   s     3 3r   r0   c                   s:   a a ] tR t^t oRtRV 3R lltRtVtV ;t# )JWTMissingKeyzJSON Web Token is using a key not in the key set.

This exception is raised if the key that was used is not available
in the passed key set.
c                r   )NzMissing Keyr   )r   r   r1   r   r   r   r   r   ZJWTMissingKey.__init__   s>    g,CC7S^++CmT+C0r   r   r   r   r'   r)   r   r1   r1      s     1 1r   r1   c                   s  a  ] tR t^t o RtR(R lt]R 4       t]P                  R 4       t]R 4       t	]	P                  R 4       t	]R 4       t
]
P                  R	 4       t
]R
 4       t]P                  R 4       t]R 4       t]P                  R 4       tR)R lt]R 4       t]P                  R 4       tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR  tR)R! ltR*R" lt ]!R# 4       t"R$ t#R% t$R& t%R't&V t'R# )+JWTz>JSON Web token object

This object represent a generic token.
Nc	                sB   RV n         RV n        RV n        WPn        RV n        RV n        ^<V n        RV n        RV n        Wn	        V'       d   Wn
        Ve   W`n        Ve   VRJd   V P                  V4       Wpn        Ve   W n        Ve   V P                  W44       R# R# )a  Creates a JWT object.

:param header: A dict or a JSON string with the JWT Header data.
:param claims: A dict or a string with the JWT Claims data.
:param jwt: a 'raw' JWT token
:param key: A (:class:`jwcrypto.jwk.JWK`) key to deserialize
 the token. A (:class:`jwcrypto.jwk.JWKSet`) can also be used.
:param algs: An optional list of allowed algorithms
:param default_claims: An optional dict with default values for
 registered claims. A None value for NumericDate type claims
 will cause generation according to system time. Only the values
 from RFC 7519 - 4.1 are evaluated.
:param check_claims: An optional dict of claims that must be
 present in the token, if the value is not None the claim must
 match exactly.
:param expected_type: An optional string that defines what kind
 of token to expect when validating a deserialized token.
 Supported values: "JWS" or "JWE"
 If left to None the code will try to detect what the expected
 type is based on other parameters like 'algs' and will default
 to JWS if no hints are found. It has no effect on token creation.

Note: either the header,claims or jwt,key parameters should be
provided as a deserialization operation (which occurs if the jwt
is provided) will wipe any header or claim provided by setting
those obtained from the deserialization of the jwt token.

Note: if check_claims is not provided the 'exp' and 'nbf' claims
are checked if they are set on the token but not enforced if not
set. Any other RFC 7519 registered claims are checked only for
format conformance.
NiX  F)_header_claims_token_algs_reg_claims_check_claims_leeway	_validitydeserializelog_expected_typeheader_check_check_claimsclaimsdeserialize)	r   r=   r?   jwtkeyZalgsZdefault_claimscheck_claimsexpected_types	   &&&&&&&&&r   r   ZJWT.__init__   s    H 
!"+ K%-#5(((6!- K?S& r   c                L    V P                   f   \        R4      hV P                   # )Nz'header' not set)r3   KeyErrorr      &r   r=   
JWT.header   "    <<-..||r   c                s    \        V\        4      '       d   \        V4      pMTp\        V4      pVP	                  R 4      RJ d   \        R4      hW n        R# )Zb64Fz8b64 header is invalid.JWTs cannot use unencoded payloadsN)
isinstancedictr   r   get
ValueErrorr3   )r   ZhZeh   && r   r=   rI      sP    aQBBBA55<5  B C Cr   c                rE   )Nz'claims' not set)r4   rF   rG   rH   r   r?   
JWT.claims   rJ   r   c                s    \        V\        4      '       g'   V P                  '       g	   Wn        R # \	        V4      pM\
        P                  ! V4      pV P                  V4       \        V4      V n        R # N)	rK   rL   r7   r4   r   copyZdeepcopy_add_default_claimsr   )r   c   &&r   r?   rP     sU    !T""### AA a A  #"1~r   c                    V P                   # rQ   )r5   rG   rH   r   token	JWT.token  s    {{r   c                s    \        V\        4      '       g-   \        V\        4      '       g   \        V\        4      '       d	   Wn        R# \        R 4      h)z.Invalid token type, must be one of JWS,JWE,JWTN)rK   r	   r   r2   r5   	TypeError)r   trU   r   rW   rX     s8    aAs!3!3z!S7I7IKLMMr   c                rV   rQ   )r9   rG   rH   r   leeway
JWT.leeway  s    ||r   c                &    \        V4      V n        R # rQ   )intr9   )r   ZlwyrU   r   r[   r\   !  s    3xr   c                rV   rQ   )r:   rG   rH   r   validityJWT.validity%  s    ~~r   c                r]   rQ   )r^   r:   r   vrU   r   r_   r`   )  s    Qr   c                s   V P                   f   V P                  '       dt   \        V P                  4      P                  \        R.,           4      '       d	   RV n         M5\        V P                  4      P                  \
        4      '       d   RV n         V P                   f4   V P                  '       d"   R\        V P                  4      9   d   RV n         V P                   f   Ve   \        V\        4      '       d0   VP                  R4      pVR8X  d	   RV n         MpVR8X  d   RV n         Ma\        V\        4      '       dL   R pV F&  pVP                  R4      pVf   TpK  W#8w  g   K$  R p M	  VR8X  d	   RV n         MVR8X  d   RV n         V P                   Ef   VEe   \        V\        4      '       d   VP                  R4      pV'       dn   \        V\        4      '       g   V.p\        V4      P                  RR	.4      '       d
   RV n         EM.\        V4      P                  R
R.4      '       d   RV n         EM\        V\        4      '       d   R pR pV F  pVP                  R4      pV'       d   \        V\        4      '       g   V.pVfk   \        V4      P                  RR	.4      '       d   \        RR	.4      pRpKl  \        V4      P                  R
R.4      '       d   \        R
R.4      pRpK  R p M6\        V4      P                  V4      '       g   R p MK  V'       g   K  R p M	  V'       d   Wpn         V P                   f   RV n         V P                   # )NZRSA1_5r   r	   ZencuseZsigZkey_opsZsignverifyZencryptdecrypt)r<   r6   ZsetZissubsetjwe_algsjws_algsr3   r   rK   r   rM   r   list)r   rB   rc   Zall_useZkZopsZall_opsZttypes   &&      r   _expected_type_heuristicsZJWT._expected_type_heuristics-  s   &4:::4::''H:(=>>&+#TZZ))(33&+#&4<<<DLL11&+#&3?#s##ggen%<*/D'E\*/D'C((A%%,C"%"&  e#*/D'%*/D'&3?#s##ggi(%c400"e3x((&();<<.3+S**Iy+ABB.3+C((A%%	*C)#t44#&%C"?"3x00&(1CDD*-vx.@*A(-!$S!2!2Iy3I!J!J*-y).D*E(-(, %#&s8#4#4W#=#=(, % $> ! $+ , */'&"'D"""r   c                sV    V P                   e   V P                   # V P                  4       # rQ   )r<   ri   rG   rH   r   rD   JWT.expected_typeu  s+    *&&& --//r   c                s6    VR9   d	   Wn         R# \        R4      h)r	   z%Invalid value, must be 'JWS' or 'JWE'N)r	   r   )r<   rN   ra   rU   r   rD   rj     s    "#DEEr   c                sb    W9   d   R # V P                   P                  VR 4      pVe   W2V&   R # R # rQ   )r7   rM   )r   namer?   val   &&& r   _add_optional_claimZJWT._add_optional_claim  s3    >""4.?4L r   c                s    W9   d   R # WP                   9   d3   V P                   V,          f   W2V&   R # V P                   V,          W!&   R # R # rQ   )r7   )r   rk   r?   Zdefval   &&&&r   _add_time_claimZJWT._add_time_claim  sE    >###%-%t#//5	 $r   c                s|    R V9   g   R V P                   9  d   R# \        \        P                  ! 4       4      VR &   R# )r   N)r7   r   uuidZuuid4r   r?   rU   r   _add_jti_claimZJWT._add_jti_claim  s-    F?e4+;+;;DJJL)ur   c                s~   V P                   f   R # \        \        P                  ! 4       4      pV P                  RV4       V P                  RV4       V P                  RV4       V P	                  RWV P
                  ,           4       V P	                  RW4       V P	                  RW4       V P                  V4       R # )Nr
   r   r   r   r   r   )r7   r^   timern   rp   r_   rs   )r   r?   ZnowrO   r   rS   ZJWT._add_default_claims  s    #$))+  /  /  /UF$--,?@UF0UF0F#r   c                sx    W9  g   W!,          f   R # \        W!,          \        4      '       g   \        R4      hR # )Nz"Claim %s is not a StringOrURI type)rK   r   r/   r   rk   r?      &&&r   _check_string_claimZJWT._check_string_claim  s2    !5&,,,'(LMM -r   c                sR   W9  g   W!,          f   R # \        W!,          \        4      '       dM   \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        RV: R24      hR # \        W!,          \        4      '       g   \        RV: R24      hR # )Nc              3   sL   "   T F  p\        V\        4      '       * x  K  	  R # 5irQ   )rK   r   )Z.0claim   & r   Z	<genexpr>Z3JWT._check_array_or_string_claim.<locals>.<genexpr>  s     B6%z%---6s   "$TFClaim z contains non StringOrURI typesz is not a StringOrURI type)rK   rh   Zanyr/   r   ru   rv   r   _check_array_or_string_claimZ JWT._check_array_or_string_claim  s    !5flD))sB6BsssB6BBB+AEHJ J C FL#..'8<?A A /r   c                s    W9  g   W!,          f   R #  \        W!,          4       R #   \         d   p\        RT: R24      ThR p?ii ; i)Nrz   z is not an integer)r^   rN   r/   )r   rk   r?   erm   r   _check_integer_claimZJWT._check_integer_claim  sK    !5	@ 	@'0479>?@	@s   ' AAAc                sH    WV,
          8  d   \        R WV3,          4      hR# )z#Expired at %d, time: %d(leeway: %d)N)r   r   rx   Zlimitr[   ro   r   
_check_expZJWT._check_exp  s1    6>!B"6F3 3 4 4 "r   c                sH    WV,           8  d   \        R WV3,          4      hR# )z#Valid from %d, time: %d(leeway: %d)N)r*   r~   ro   r   
_check_nbfZJWT._check_nbf  s1    6>! !F!&vJ7 "7 8 8 "r   c                sB   V P                  R V4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  f   RV9   d8   V P	                  VR,          \
        P
                  ! 4       V P                  4       RV9   d:   V P                  VR,          \
        P
                  ! 4       V P                  4       R# R# R# 	r
   r   r   r   r   r   r   typN)rw   r{   r}   r8   r   rt   r9   r   rr   rU   r   _check_default_claimsZJWT._check_default_claims  s      /  /))%8!!%0!!%0!!%0  /  /%utyy{DLLIutyy{DLLI  &r   c                s&   V P                  R V4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       V P                  RV4       R# r   )rw   r{   r}   )r   rC   rU   r   r>   ZJWT._check_check_claims  s      5  5))%>!!%6!!%6!!%6  5  5r   c           
     s   V P                   R J d   R#  \        V P                  4      p\        V\        4      '       g   \        4       h T P                  T4       T P                   f   R# T P                   P                  4        EF:  w  r4Y19  d   \        RT: R24      hTR9   d4   Te.   YAT,          8w  d   \        RT: RT: RY,          : R24      hKT  KV  TR	8X  d   Te   \        Y,          \        4      '       d
   Y,          pM	Y,          .p\        T\        4      '       d   TpMT.pR pT F  pY9   g   K  R
p M	  T'       g#   \        RP                  Y1T,          T4      4      hK  K  TR8X  dZ   Te   T P                  Y,          T^ 4       EK  T P                  Y,          \        P                  ! 4       T P                  4       EKN  TR8X  dZ   Te   T P!                  Y,          T^ 4       EKu  T P!                  Y,          \        P                  ! 4       T P                  4       EK  TR8X  dT   TeM   T P#                  T4      T P#                  Y,          4      8w  d   \        RT: RY,          : RT: R24      hEK  EK  Tf   EK  YAT,          8w  g   EK  \        RT: RT: RY,          : R24      h	  R#   \
         d&   pT P                   e   \        R4      Th Rp?R# Rp?ii ; i)FNz4Claims check requested but claims is not a json dictrz   z is missingz	Invalid 'z' value. Expected 'z' got 'Z'r   Tz)Invalid '{}' value. Expected '{}' in '{}'r   r   r   z
' value. 'z' does not normalize to ')r
   r   r   )r8   r   r?   rK   rL   rN   r/   r   Zitemsr+   r.   rh   formatr   rt   r9   r   norm_typ)	r   r?   r|   rk   ZvalueZtclaimsZcclaimsZfoundrb   s	   &        r   _check_provided_claimsZJWT._check_provided_claims  s   &		 -Ffd++ l" , 	""6*%--335KD!%t&FGG,,$,)>. %78 8 *?$
 $!&,55"(,#)<.!%.."'#('!E$<$(E! % !2GNN $TlE;< < ! %& $OOFL%;OOFL$))+t||L$OOFL%;OOFL$))+t||L$}}U+t}}V\/JJ2=A=C\\=B	4D E E K % $,)>. %78 8k 6  	!!-+ -3 49:; 	s   5K K6K11K6c                sF    VP                  4       pR V9   d   V# RV,           # )Z/zapplication/)Zlower)r   rl   ZlcrO   r   r   ZJWT.norm_typ5  s$    YY["9I!B&&r   c                s    \        V P                  4      pV P                  '       d   V P                  Vn        VP	                  WP
                  R7       W n        RV n        R# )zSigns the payload.

Creates a JWS token with the header as the JWS protected header and
the claims as the payload. See (:class:`jwcrypto.jws.JWS`) for
details on the exceptions that may be raised.

:param key: A (:class:`jwcrypto.jwk.JWK`) key.
)Z	protectedr	   N)r	   r?   r6   allowed_algsZadd_signaturer=   rW   r<   r   rB   rZ   rO   r   make_signed_tokenZJWT.make_signed_token<  sE     :::!ZZAN	{{3
#r   c                s    \        V P                  V P                  4      pV P                  '       d   V P                  Vn        VP                  V4       W n        RV n        R# )zEncrypts the payload.

Creates a JWE token with the header as the JWE protected header and
the claims as the plaintext. See (:class:`jwcrypto.jwe.JWE`) for
details on the exceptions that may be raised.

:param key: A (:class:`jwcrypto.jwk.JWK`) key.
r   N)r   r?   r=   r6   r   Zadd_recipientrW   r<   r   rO   r   make_encrypted_tokenZJWT.make_encrypted_tokenM  sE     T[[):::!ZZAN	
#r   c                s   . V n         V P                  f   \        R4      hV P                  V4      pRp\	        V P                  \
        4      '       dE   VR8w  d'   \        '       d   \        RP                  V4      4      hV P                  P                  pMo\	        V P                  \        4      '       dE   VR8w  d'   \        '       d   \        RP                  V4      4      hV P                  P                  pM\        R4      h V! V4       V P                   P                  R4       T P                  P&                  T n        T P                  P*                  p\	        T\,        4      '       d   TP/                  R
4      pYPn        T P3                  4        R#   \         d   p\	        T P                  \
        4      '       d   T P                  P                  T n         M;\	        T P                  \        4      '       d   T P                  P                  T n         T P                   P                  R	P                  \!        T4      4      4       \	        T\"        4      '       d   \%        4       Thh Rp?ii ; i)zValidate a JWT token that was deserialized w/o providing a key

:param key: A (:class:`jwcrypto.jwk.JWK`) verification or
 decryption key, or a (:class:`jwcrypto.jwk.JWKSet`) that
 contains a key indexed by the 'kid' header.
NzToken emptyr	   zExpected {}, got JWSr   zExpected {}, got JWEToken format unrecognizedZSuccesszValidation failed: [{}]zutf-8)r;   rW   rN   ri   rK   r	   JWT_expect_typerY   r   rd   r   re   Zappend	ExceptionZ	verifylogZ
decryptlogreprr   r1   Zjose_headerr=   payloadZbytesZdecoder?   r   )r   rB   ZetZvalidate_fnr|   r   s   &&    r   validateZJWT.validate^  s    !::]++++C0djj#&&U{ 6 = =b ABB**++K

C((U{ 6 = =b ABB**,,K899	&&y1 jj,,**$$gu%%nnW-G##%!  		$**c**&*jj&:&:#DJJ,,&*jj&;&;#&&)00a9;!]++#o1,		s   #F I7&CI22I7c                sp   VP                  R4      pV^8X  d   \        4       V n        M"V^8X  d   \        4       V n        M\	        R4      hV P
                  '       d   V P
                  V P                  n        RV n        V P                  P                  VR4       V'       d   V P                  V4       R# R# )a)  Deserialize a JWT token.

NOTE: Destroys any current status and tries to import the raw
token provided.

:param jwt: a 'raw' JWT token.
:param key: A (:class:`jwcrypto.jwk.JWK`) verification or
 decryption key, or a (:class:`jwcrypto.jwk.JWKSet`) that
 contains a key indexed by the 'kid' header.
Z.r   N)
Zcountr	   rW   r   rN   r6   r   r;   r@   r   )r   rA   rB   rT   rm   r   r@   ZJWT.deserialize  s     IIcN6DJ!VDJ899 :::&*jjDJJ#" 	

sD)MM# r   c                s^    V'       g   \        R4      hV P                  P                  V4      # )a  Serializes the object into a JWS token.

:param compact(boolean): must be True.

Note: the compact parameter is provided for general compatibility
with the serialize() functions of :class:`jwcrypto.jws.JWS` and
:class:`jwcrypto.jwe.JWE` so that these objects can all be used
interchangeably. However the only valid JWT representation is the
compact representation.

:return: A json formatted string or a compact representation string
:rtype: `str`
z)Only the compact serialization is allowed)rN   rW   	serialize)r   ZcompactrU   r   r   ZJWT.serialize  s(     HIIzz##G,,r   c                s6    V ! 4       pVP                  V4       V# )zCreates a JWT object from a serialized JWT token.

:param token: A string with the json or compat representation
 of the token.

:raises InvalidJWEData or InvalidJWSObject: if the raw object is an
 invalid JWT token.

:return: A JWT token
:rtype: JWT
)r@   )ZclsrW   ZobjrO   r   from_jose_tokenZJWT.from_jose_token  s     e
r   c                s    \        V\        4      '       g   R # V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # )F)rK   r2   r4   r3   rW   )r   ZotherrU   r   __eq__Z
JWT.__eq__  s[    %%%||u}}, & &LLEMM)& &JJ%++%	&r   c                sf     V P                  4       #   \         d    T P                  4       u # i ; irQ   )r   r   __repr__rG   rH   r   __str__ZJWT.__str__  s/    	#>>## 	#==?"	#s    00c                s
   \        V P                  4      pR V P                   R2RV P                   R2,           RV R2,           RV P                   R2,           RV P
                   R2,           RV P                   R2,           # )zJWT(header=z, zclaims=zjwt=zkey=None, algs=zdefault_claims=zcheck_claims=Z))r   rW   r3   r4   r6   r7   r8   )r   rA   ry   r   r   ZJWT.__repr__  s    4::T\\N"-b)*cU"~ !B/0 !!1!1 2"5	6
 t112!45 	5r   )r6   r8   r4   r<   r3   r9   r7   r5   r:   r?   r;   r=   rW   )NNNNNNNNrQ   )T)(r    r!   r"   r#   r$   r   Zpropertyr=   Zsetterr?   rW   r[   r_   ri   rD   rn   rp   rs   rS   rw   r{   r}   r   r   r   r>   r   r   r   r   r   r@   r   Zclassmethodr   r   r   r   r%   r&   )r(   s   @r   r2   r2      s    
>'@  
 ]]
 
  
 ]]& &   \\N N   ]]      __   F#P 0 0 F F6*
$N	A@4
8
J 6L8\'$"$",&\<-&  "&#5 5r   r2   )rR   rt   rq   r    Zjwcrypto.commonr   r   r   r   Zjwcrypto.jwer   r   rf   Zjwcrypto.jwkr   r   Zjwcrypto.jwsr	   rg   ZJWTClaimsRegistryr   r   r*   r+   r.   r/   r0   r1   r2   r   r   r   <module>r      s       ! 6 4  9 $  9
 HIJ-LKH&  * . ."2[ 2$3k 3"8; 8"9K 9" 3k 3 3$1M 1$@	5 @	5r   