ffddlZddlZddlmZddlmZmZmZmZm Z ddl m Z m Z m Z mZddlmZmZmZmZddlmZmZGdd ZeZejZejZejZejZejZejZdS) N)Mapping)AnyDictListOptionalType) Algorithmget_default_algorithms has_cryptorequires_cryptography) DecodeErrorInvalidAlgorithmErrorInvalidSignatureErrorInvalidTokenError)base64url_decodebase64url_encodec ,eZdZdZddZedZdZdZdZ dd e d e d e d e e d e eejde f dZ dde d e dee de de e eff dZ dde d e dee de de f dZdZdZ ddZdZdZdS)PyJWSJWTNc6t|_|t|nt|j|_t |jD]}||jvr|j|=|i}i|||_dS)N)r _algorithmsset _valid_algslistkeys_get_default_optionsoptions)self algorithmsrkeys k/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jwt/api_jws.py__init__zPyJWS.__init__s133)5C OOO3t?O;P;P  (--//00 * *C$***$S) ?GA$3355AA c ddiS)Nverify_signatureTr'r$r"rzPyJWS._get_default_options's "D))r$c||jvrtdt|tst d||j|<|j|dS)zW Registers a new Algorithm for use when creating and verifying tokens. z Algorithm already has a handler.z!Object is not of type `Algorithm`N)r ValueError isinstancer TypeErrorradd)ralg_idalg_objs r"register_algorithmzPyJWS.register_algorithm+sm T% % %?@@ @'9-- A?@@ @#*  V$$$$$r$cz||jvrtd|j|=|j|dS)z Unregisters an Algorithm for use when creating and verifying tokens Throws KeyError if algorithm is not registered. zJThe specified algorithm could not be removed because it is not registered.N)rKeyErrorrremove)rr-s r"unregister_algorithmzPyJWS.unregister_algorithm8sS ) ) )1   V $ '''''r$c*t|jS)zM Returns a list of supported values for the 'alg' parameter. )rr)rs r"get_algorithmszPyJWS.get_algorithmsFsD$%%%r$HS256payloadr! algorithmheaders json_encoderreturncg}|d}||jvr |j|d}|r*||||t j|d|}|t||t|d |} |j |} | |}| | |} n?#t$r2ts|tvrt!d|zt!dwxYw|t| d |} | dS) Nnone)typalg),:) separatorscls.zFAlgorithm '%s' could not be found. Do you have cryptography installed?Algorithm not supportedutf-8)r header_typ_validate_headersupdatejsondumpsencodeappendrjoinr prepare_keysignr1r r NotImplementedErrordecode) rr7r!r8r9r:segmentsheader json_header signing_inputr. signatureencoded_strings r"rLz PyJWS.encodeLs  I D, , , ;;  #  " "7 + + + MM' " " "j z|   &((  (55666(11222 (++  E&y1G%%c**C ]C88II E E E E)/D"D"D)!#,- **CDDD E (334448,,$$W---s 8D,/JJtQ,?,? )M>.;.A.A$.J.J +NOO > > >344# = > A*>::KK8>* A A A677S @ A FZ ,,FF F F F9A=>>A E F&'** NLMM M B&77GG8>* B B B788c A B A(88II8>* A A A677S @ A ::sx2B B*B%%B*.B>>C)C$$C)-D D$ DD$ EF2FF FG1GGc&|d}|||vrtd |j|}||}||||st ddS#t $rtdwxYw)Nr?z&The specified alg value is not allowedzSignature verification failedrE)getrrrOverifyrr1)rrVrTrWr!r r?r.s r"r]zPyJWS._verify_signaturesjj  !c&;&;'(PQQ Q C&s+G%%c**C>>-i@@ M+,KLLL M M C C C'(ABB B Cs AA66BcHd|vr||ddSdS)Nkid) _validate_kid)rr9s r"rHzPyJWS._validate_headerss3 G     wu~ . . . . .  r$cNt|tstddS)Nz(Key ID header parameter must be a string)r*rgr)rrxs r"ryzPyJWS._validate_kids0#s## P#$NOO O P Pr$)NN)r6NN)rYNN)rYN)__name__ __module__ __qualname__rGr# staticmethodrr/r3r5rhrgrrrrJ JSONEncoderrLrrr`rRrer\r]rHryr'r$r"rrsJ B B B B**\* % % % ( ( (&&&!"&9= 2.2.2.2. 2. $ 2. tD$456 2. 2.2.2.2.n $     I     c3h    @ $ " "  " "I "  "  " " " "   $;$;$;V  CCCC0///PPPPPr$r)rkrJcollections.abcrtypingrrrrrr r r r r exceptionsrrrrutilsrrr_jws_global_objrLr`rRr/r3rer'r$r"rsd ######22222222222222  65555555bPbPbPbPbPbPbPbPJ%''  !1  $7&;'=r$