
    U-fy                     n   d Z ddlZddlZddlmZ ddlmZ ddlZddl	Z	ddl
Z
ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z!  ej"        e#          Z$dZ% G d d          Z& G d d          Z'dS )zACME client API.    N)parsedate_tz)Any)cast)List)Mapping)Optional)Set)Tuple)Union)HTTPAdapter)parse_header_links)
challenges)crypto_util)errors)jws)messages-   c            
          e Zd ZdZdej        ddddfdZdej        dej        fd	Z	d
ej        dej        fdZ
	 d8d
ej        deej                 dej        fdZd9d
ej        dedej        fdZdedej        fdZdej        deej        ej        f         fdZ	 d8dej        deej                 dej        fdZdej        dej        dej        fdZdej        dej        fdZ	 d9dej        dej        dedej        fdZ	 d9dej        dej        dedej        fdZdej        de ddfdZ!defd Z"d!e#d"e#dej        fd#Z$d$ej        d%e%de&e%         fd&Z'e(d'e%dddej        fd(            Z)e(	 	 d:d$ej        d)ee%         d*ee%         dej        fd+            Z*d
ej        d,ej        dej        fd-Z+d!e#d"e#dej        fd.Z,d
ej        dej        fd/Z-dej        dej        fd0Z.	 	 d:d$ej        d1eej/                 d)ee%         dej        fd2Z0d3ej1        d$e2j3        dej4        fd4Z5e(d$ej        d5e dej        fd6            Z6dej        de d'e%ddfd7Z7dS );ClientV2zuACME client for a v2 API.

    :ivar messages.Directory directory:
    :ivar .ClientNetwork net: Client network.
    	directorynetClientNetworkreturnNc                 "    || _         || _        dS )zInitialize.

        :param .messages.Directory directory: Directory Resource
        :param .ClientNetwork net: Client network.
        N)r   r   )selfr   r   s      Z/home/cdr/domains/dharristours.com/map/certbot/lib/python3.11/site-packages/acme/client.py__init__zClientV2.__init__*   s     #    new_accountc                     |                      | j        d         |          }|j        dk    r(d|j        v rt	          j        |j        d                   |                     |          }|| j        _        |S )zRegister.

        :param .NewRegistration new_account:

        :raises .ConflictError: in case the account already exists

        :returns: Registration Resource.
        :rtype: `.RegistrationResource`
        
newAccount   Location)	_postr   status_codeheadersr   ConflictError_regr_from_responser   account)r   r   responseregrs       r   r   zClientV2.new_account3   st     ::dn\:KHH3&&:9I+I+I&x'7
'CDDD''11r   r+   c                 Z    |                      |d          | j        _        | j        j        S )zQuery server about registration.

        :param messages.RegistrationResource regr: Existing Registration
            Resource.

        T)_get_v2_accountr   r)   r   r+   s     r   query_registrationzClientV2.query_registrationF   s)      //d;;xr   updatec                     |                      |          }||j        n|}t          j        di t	          |          }|                     ||          }|| j        _        |S )aK  Update registration.

        :param messages.RegistrationResource regr: Registration Resource.
        :param messages.Registration update: Updated body of the
            resource. If not provided, body will be taken from `regr`.

        :returns: Updated Registration Resource.
        :rtype: `.RegistrationResource`

        Nbody )r-   r3   r   UpdateRegistrationdict_send_recv_regrr   r)   )r   r+   r0   r3   updated_regrs        r   update_registrationzClientV2.update_registrationR   sj     ##D))$n&*::T&\\::++Dt+<<'r   Fupdate_bodyc                 f   d | j         _        |j                            d          }|                     | j        d         |          }|j        d         }|                    |r1t          j        	                    |
                                          n|j        |          }|| j         _        |S )NT)only_return_existingr!   r#   r3   uri)r   r)   r3   r0   r$   r   r&   r   Registration	from_jsonjson)r   r+   r:   only_existing_regr*   updated_urinew_regrs          r   r-   zClientV2._get_v2_accounth   s     I,,$,GG::dn\:<MNN&z2;;"-%=H$9$C$CHMMOO$T$T$T379#.  0 0 $r   csr_pemc                 T   t           j                            t           j        j        |          }t	          j        |          }t	          j        |          }g }|D ]5}|                    t          j	        t          j
        |                     6|D ]5}|                    t          j	        t          j        |                     6t          j        |          }|                     | j        d         |          }	t          j                            |	                                          }
g }|
j        D ]?}|                    |                     |                     |          |                     @t          j        |
|	j                            d          ||          S )zRequest a new Order object from the server.

        :param bytes csr_pem: A CSR in PEM format.

        :returns: The newly created order.
        :rtype: OrderResource
        )typvalue)identifiersnewOrderr>   r#   )r3   r>   authorizationsrE   )OpenSSLcryptoload_certificate_requestFILETYPE_PEMr    _pyopenssl_cert_or_req_all_names_pyopenssl_cert_or_req_san_ipappendr   
IdentifierIDENTIFIER_FQDNIDENTIFIER_IPNewOrderr$   r   Orderr@   rA   rL   _authzr_from_response_post_as_getOrderResourcer&   get)r   rE   csrdnsNamesipNamesrI   nameipsorderr*   r3   rL   urls                r   	new_orderzClientV2.new_ordert   s    n55gn6QSZ[[?DD;C@@ 	 	Dx2x7O          	 	Cx2x7M         !k:::::dnZ8%@@~''88 & 	_ 	_C!!$"<"<T=N=Ns=S=SY\"<"]"]^^^^% $$Z00)	   	r   authzrc                     |                      |j                  }|                     ||j        j        |j                  }||fS )a  Poll Authorization Resource for status.

        :param authzr: Authorization Resource
        :type authzr: `.AuthorizationResource`

        :returns: Updated Authorization Resource and HTTP response.

        :rtype: (`.AuthorizationResource`, `requests.Response`)

        )rZ   r>   rY   r3   
identifier)r   re   r*   updated_authzrs       r   pollzClientV2.poll   sG     $$VZ0033fk,fj: :x''r   orderrdeadlinec                     |4t           j                                         t          j        d          z   }|                     ||          }|                     ||          S )ad  Poll authorizations and finalize the order.

        If no deadline is provided, this method will timeout after 90
        seconds.

        :param messages.OrderResource orderr: order to finalize
        :param datetime.datetime deadline: when to stop polling and timeout

        :returns: finalized order
        :rtype: messages.OrderResource

        NZ   seconds)datetimenow	timedeltapoll_authorizationsfinalize_order)r   rj   rk   s      r   poll_and_finalizezClientV2.poll_and_finalize   s\     (,,..1CB1O1O1OOH))&(;;""68444r   c                    g }|j         j        D ]}t          j                                        |k     r|                     |                     |          |          }|j         j        t          j        k    r|	                    |           n6t          j        d           t          j                                        |k     t          |          t          |j         j                  k     rt          j                    g }|D ]G}|j         j        t          j        k    r+|j         j        D ]}|j        |	                    |           H|rt          j        |          |                    |          S )zPoll Order Resource for status.rK      N)rL   )r3   rL   rp   rq   rY   rZ   statusr   STATUS_PENDINGrS   timesleeplenr   TimeoutErrorSTATUS_VALIDr   errorValidationErrorr0   )r   rj   rk   	responsesrc   re   failedchalls           r   rs   zClientV2.poll_authorizations   se    	;- 	 	C#''))H4433D4E4Ec4J4JPS3TT;%)@@@$$V,,,
1 #''))H44 y>>C :;;;;%''' 	. 	.F{!X%:::#[3 . .E{.f--- 	1(000}}I}666r   c                    t           j                            t           j        j        |j                  }t          j        t          j        |                    }| 	                    |j
        j        |          }|                    t
          j                            |                                                    }|S )a  Start the process of finalizing an order.

        :param messages.OrderResource orderr: order to finalize
        :param datetime.datetime deadline: when to stop polling and timeout

        :returns: updated order
        :rtype: messages.OrderResource
        )r]   r2   )rM   rN   rO   rP   rE   r   CertificateRequestjoseComparableX509r$   r3   finalizer0   rX   r@   rA   )r   rj   r]   wrapped_csrress        r   begin_finalizationzClientV2.begin_finalization   s     n55N'9 91d6I#6N6NOOOjj-{;;HN$<$<SXXZZ$H$HIIr   fetch_alternative_chainsc                 &    t           j                                         |k     r[t          j        d                                |j                  }t          j                            |	                                          }|j
        t          j        k    r4|j        t          j        |j                  t          j        d          |j
        t          j        k    r{|j        t                     |j                  }|                    ||j                  }|r:                     |d          } fd|D             }|                    |          }|S t           j                                         |k     [t          j                    )z
        Poll an order that has been finalized for its status.
        If it becomes valid, obtain the certificate.

        :returns: finalized order (with certificate)
        :rtype: messages.OrderResource
        rw   NzPThe certificate order failed. No further information was provided by the server.)r3   fullchain_pem	alternatec                 D    g | ]}                     |          j        S r4   )rZ   text).0rc   r   s     r   
<listcomp>z.ClientV2.poll_finalization.<locals>.<listcomp>   s*    !Y!Y!Y#$"3"3C"8"8"=!Y!Y!Yr   )alternative_fullchains_pem)rp   rq   rz   r{   rZ   r>   r   rX   r@   rA   rx   STATUS_INVALIDr   r   IssuanceErrorErrorr~   certificater0   r   
_get_linksr}   )	r   rj   rk   r   r*   r3   certificate_responsealt_chains_urls
alt_chainss	   `        r   poll_finalizationzClientV2.poll_finalization   sg    ##%%00JqMMM((44H>++HMMOO<<D{h555:) .tz:::l%& & &  555$:J:V'+'8'89I'J'J$D@T@YZZ+ R&*oo6JK&X&XO!Y!Y!Y!Y!Y!Y!YJ#]]j]QQF# ##%%00$ !###r   c                 Z    |                      |           |                     |||          S )a{  Finalize an order and obtain a certificate.

        :param messages.OrderResource orderr: order to finalize
        :param datetime.datetime deadline: when to stop polling and timeout
        :param bool fetch_alternative_chains: whether to also fetch alternative
            certificate chains

        :returns: finalized order
        :rtype: messages.OrderResource

        )r   r   )r   rj   rk   r   s       r   rt   zClientV2.finalize_order  s1     	'''%%fh8PQQQr   certrsnc                 J    |                      ||| j        d                    dS )a  Revoke certificate.

        :param .ComparableX509 cert: `OpenSSL.crypto.X509` wrapped in
            `.ComparableX509`

        :param int rsn: Reason code for certificate revocation.

        :raises .ClientError: If revocation is unsuccessful.

        
revokeCertN)_revoker   )r   r   r   s      r   revokezClientV2.revoke  s'     	T3| <=====r   c                     t          | j        d          o*t          | j        j        d          o| j        j        j        S )zGChecks if ACME server requires External Account Binding authentication.metaexternal_account_required)hasattrr   r   r   r   s    r   r   z"ClientV2.external_account_required"  s>    t~v.. =t~*,GHH=~"<	=r   argskwargsc                 L    |dd         dz   |dd         z   } | j         |i |S )z
        Send GET request using the POST-as-GET protocol.
        :param args:
        :param kwargs:
        :return:
        Nrw   N)r$   )r   r   r   new_argss       r   rZ   zClientV2._post_as_get(  s:     8g%QRR0tz8.v...r   r*   relation_typec                 j    d|j         vrg S t          |j         d                   }fd|D             S )z
        Retrieves all Link URIs of relation_type from the response.
        :param requests.Response response: The requests HTTP response.
        :param str relation_type: The relation type to filter by.
        Linkc                 H    g | ]}d |v d|v 
|d          k    |d         S )relrc   r4   )r   lr   s     r   r   z'ClientV2._get_links.<locals>.<listcomp>=  sH     L L LQA::%1**5]1J1J %1J1J1Jr   )r&   r   )r   r*   r   linkss     ` r   r   zClientV2._get_links2  s_     )))I"8#3F#;<<L L L L% L L L 	Lr   rc   c                     t           j                            |                    |                                                    S )aB  
        Retrieves the ACME directory (RFC 8555 section 7.1.1) from the ACME server.
        :param str url: the URL where the ACME directory is available
        :param ClientNetwork net: the ClientNetwork to use to make the request

        :returns: the ACME directory object
        :rtype: messages.Directory
        )r   	Directoryr@   r\   rA   )clsrc   r   s      r   get_directoryzClientV2.get_directory@  s1     !++CGGCLL,=,=,?,?@@@r   r>   terms_of_servicec                     d|j         v r|j         d         d         }t          j        t          j                            |                                          |j                            d|          |          S )Nzterms-of-servicerc   r#   )r3   r>   r   )r   r   RegistrationResourcer?   r@   rA   r&   r\   )r   r*   r>   r   s       r   r(   zClientV2._regr_from_responseL  ss     //'~.@A%H,&00AA $$Z55-/ / / 	/r   r3   c                 |    |                      |j        |          }|                     ||j        |j                  S )N)r>   r   )r$   r>   r(   r   )r   r+   r3   r*   s       r   r7   zClientV2._send_recv_regrX  sC    ::dh-- ''$(!2 ( 4 4 	4r   c                 x    |                     dt          | j        d                      | j        j        |i |S )zWrapper around self.net.post that adds the newNonce URL.

        This is used to retry the request in case of a badNonce error.

        new_nonce_urlnewNonce)
setdefaultgetattrr   r   postr   r   r   s      r   r$   zClientV2._postf  s?     	/74>:+N+NOOOtx}d-f---r   c                 n    |                      |t          j                            ddd                    S )zDeactivate registration.

        :param messages.RegistrationResource regr: The Registration Resource
            to be deactivated.

        :returns: The Registration resource that was deactivated.
        :rtype: `.RegistrationResource`

        deactivatedN)rx   contact)r9   r   r?   r@   r.   s     r   deactivate_registrationz ClientV2.deactivate_registrationo  s>     ''h.C.M.M$66/8 /8 9 9 	9r   c                     t          j        d          }|                     |j        |          }|                     ||j        j        |j                  S )a  Deactivate authorization.

        :param messages.AuthorizationResource authzr: The Authorization resource
            to be deactivated.

        :returns: The Authorization resource that was deactivated.
        :rtype: `.AuthorizationResource`

        r   )rx   )r   UpdateAuthorizationr$   r>   rY   r3   rg   )r   re   r3   r*   s       r   deactivate_authorizationz!ClientV2.deactivate_authorization}  sR     +=AAA::fj$//))(K"FJ0 0 	0r   rg   c                    t          j        t           j                            |                                          |j                            d|                    }|$|j        j        |k    rt          j
        |          |S )Nr#   r=   )r   AuthorizationResourceAuthorizationr@   rA   r&   r\   r3   rg   r   UnexpectedUpdate)r   r*   rg   r>   re   s        r   rY   zClientV2._authzr_from_response  sz     /'11(--//BB $$Z557 7 7 !fk&<
&J&J)&111r   challbc                    |                      |j        |          }	 |j        d         d         }n"# t          $ r t	          j        d          w xY wt          j        |t          j        	                    |
                                                    }|j        |j        k    rt	          j        |j                  |S )ah  Answer challenge.

        :param challb: Challenge Resource body.
        :type challb: `.ChallengeBody`

        :param response: Corresponding Challenge response
        :type response: `.challenges.ChallengeResponse`

        :returns: Challenge Resource with updated body.
        :rtype: `.ChallengeResource`

        :raises .UnexpectedUpdate:

        uprc   z"up" Link header missing)
authzr_urir3   )r$   r>   r   KeyErrorr   ClientErrorr   ChallengeResourceChallengeBodyr@   rA   r   )r   r   r*   respr   challrs         r   answer_challengezClientV2.answer_challenge  s      zz&*h//	AD)%0JJ 	A 	A 	A$%?@@@	A+!'11$))++>>@ @ @ :##)&*555s	   1 Adefaultc                    |j                             dt          |                    }	 t          |          }nz# t          $ rm t          |          }|W	 t          j        |d         |d         nd          }t          j        |dd          |z
  cY S # t          t          f$ r Y nw xY w|}Y nw xY wt          j        	                                t          j        |          z   S )a  Compute next `poll` time based on response ``Retry-After`` header.

        Handles integers and various datestring formats per
        https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37

        :param requests.Response response: Response from `poll`.
        :param int default: Default value (in seconds), used when
            ``Retry-After`` header is not present or invalid.

        :returns: Time point when next `poll` should be performed.
        :rtype: `datetime.datetime`

        zRetry-AfterNr      rn   )
r&   r\   strint
ValueErrorr   rp   rr   OverflowErrorrq   )r   r*   r   retry_afterro   whentz_secss          r   r   zClientV2.retry_after  s    &**=#g,,GG	+&&GG 
	 
	 
	  ,,D&0T"X=QbWXYYG#,d2A2h7'AAAA"M2   DGGG
	  $$&&);G)L)L)LLLs3   : B1<BB1B)&B1(B))B10B1c                     |                      |t          j        ||                    }|j        t          j        k    rt          j        d          dS )a.  Revoke certificate.

        :param .ComparableX509 cert: `OpenSSL.crypto.X509` wrapped in
            `.ComparableX509`

        :param int rsn: Reason code for certificate revocation.

        :param str url: ACME URL to post to

        :raises .ClientError: If revocation is unsuccessful.

        )r   reasonz0Successful revocation must return HTTP OK statusN)r$   r   
Revocationr%   http_clientOKr   r   )r   r   r   rc   r*   s        r   r   zClientV2._revoke  si     ::c&1,0'*, , ,- - ;>11$BD D D 21r   r   )F)NN)8__name__
__module____qualname____doc__r   r   r   NewRegistrationr   r   r/   r   r?   r9   boolr-   bytesr[   rd   r   r
   requestsResponseri   rp   ru   rs   r   r   rt   r   r   r   r   r   r   rZ   r   r   r   classmethodr   r(   r7   r$   r   r   rT   rY   r   r   ChallengeResponser   r   r   r   r4   r   r   r   r   #   s        ("4 ? t    x'? HDa    &
 x'D 
  ( =
  
  
  
  GK (E $,X-B$C!)!>   ,
 
H$A 
PT 
$9
 
 
 
! !8+A ! ! ! !F(89 (68IIJ( ( ( ($ CG5 5(> 5$,X->$?5KSKa5 5 5 5&7(*@ 7HL] 7!)!77 7 7 72)?  ( 6   & <A$ $(> $$,$5$48$  (5$ $ $ $B 9>R RX%; RxGX R15RBJBXR R R R >4. >S >T > > > >=4 = = = =/# / /9J / / / /L8#4 LS LTRUY L L L L 	A 	A/ 	Ah>P 	A 	A 	A [	A SW>B	/ 	/8+< 	/8C= 	/.6sm	/!)!>	/ 	/ 	/ [	/4H$A 4&348@8U4 4 4 4.3 .# .(2C . . . .9H,I 9%-%B9 9 9 90)1)G0&.&D0 0 0 0$ KO37 h.? *283F*G#+C=<D<Z   x'= #-#?DLD^   : M8#4 Ms MxGX M M M [M>DD/ Dc D D D D D D D Dr   r   c                      e Zd ZdZdZdZdZdZ	 dej	        dde
fd	ej        d
eej                 dej        dedededdfdZd$dZdej        dededefdZe	 d%dej        dee         dej        fd            Zdededededej        f
dZdededej        fdZefdedededej        fdZdej        ddfdZded edefd!Z dededej        fd"Z!efdedej        dededej        f
d#Z"dS )&r   zvWrapper around requests that signs POSTs for authentication.

    Also adds user agent, and handles Content-Type.
    zapplication/jsonzapplication/jose+jsonzapplication/problem+jsonzReplay-NonceNTzacme-pythonkeyr)   alg
verify_ssl
user_agenttimeoutr   c                 8   || _         || _        || _        || _        t	                      | _        || _        t          j                    | _	        || _
        t                      }| j	                            d|           | j	                            d|           d S )Nzhttp://zhttps://)r   r)   r   r   set_noncesr   r   Sessionsession_default_timeoutr   mount)r   r   r)   r   r   r   r   adapters           r   r   zClientNetwork.__init__   s     $!$$')) '--9g...:w/////r   c                 \    	 | j                                          d S # t          $ r Y d S w xY wr   )r   close	Exceptionr   s    r   __del__zClientNetwork.__del__  sC    	L      	 	 	DD	s    
++objnoncerc   c           	         |r(|                     d                                          nd}t                              d|           | j        ||d}| j        | j        d         |d<   | j        |d	<   t          j        j	        |fi t          t          t          t          f         |                               d          S )
zWrap `JSONDeSerializable` object in JWS.

        .. todo:: Implement ``acmePath``.

        :param josepy.JSONDeSerializable obj:
        :param str url: The URL to which this object will be POSTed
        :param str nonce:
        :rtype: str

           )indentr   zJWS payload:
%s)r   r	  rc   Nr>   kidr   )
json_dumpsencodeloggerdebugr   r)   r   r   JWSsignr   r   r   r   )r   r  r	  rc   jobjr   s         r   _wrap_in_jwszClientNetwork._wrap_in_jws  s     58@s~~Q~''..000S'...8
 
 <# L/F5Muw|DDDDc):F$C$CDDOOWXOYYYr   r*   content_typec                    |j                             d          }|r-|                    d          d                                         }	 |                                }n# t
          $ r d}Y nw xY w|j        dk    r-t          j        |j                             dd                    |j	        s|s|| j
        k    rt                              d|           	 t          j                            |          # t           j        $ r}t          j        ||f          d}~ww xY wt          j        |          |&|| j        k    rt                              d	|           || j        k    r|t          j        d
|           |S )a  Check response content and its type.

        .. note::
           Checking is not strict: wrong server response ``Content-Type``
           HTTP header is ignored if response is an expected JSON object
           (c.f. Boulder #56).

        :param str content_type: Expected Content-Type response header.
            If JSON is expected and not present in server response, this
            function will raise an error. Otherwise, wrong Content-Type
            is ignored, but logged.

        :raises .messages.Error: If server response body
            carries HTTP Problem (https://datatracker.ietf.org/doc/html/rfc7807).
        :raises .ClientError: In case of other networking errors.

        Content-Type;r   Ni  r#   zUNKNOWN-LOCATIONz/Ignoring wrong Content-Type (%r) for JSON Errorz<Ignoring wrong Content-Type (%r) for JSON decodable responsez"Unexpected response Content-Type: )r&   r\   splitstriprA   r   r%   r   r'   okJSON_ERROR_CONTENT_TYPEr  r  r   r   r@   r   DeserializationErrorr   JSON_CONTENT_TYPE)r   r*   r  response_ctr  r   s         r   _check_responsezClientNetwork._check_response1  s   ( &**>:: 	<%++C00399;;K	 ==??DD 	 	 	DDD	 3&&&x'7';';JHZ'['[\\\{ 	]#"===LLI#% % %@".2248880 @ @ @ ,h->???@
 (222K33H$H$H +- - - s444()[k)[)[\\\s*   A   A/.A/C9 9D#DD#methodr   r   c           	      r   |dk    r#t                               d||d                    nt                               d||           | j        |d<   |                    di            |d                             d| j                   |                    d| j                   	  | j        j        ||g|R i |}nt# t          j	        j
        $ r]}	 d	}t          j        |t          |                    }| |                                \  }	}
}}t          d|	 |
 d|           d
}~ww xY wd|d         v rt!          j        |j                  }nd|_        |j        }t                               d|j        d                    d |j                                        D                       |           |S )a  Send HTTP request.

        Makes sure that `verify_ssl` is respected. Logs request and
        response (with headers). For allowed parameters please see
        `requests.request`.

        :param str method: method for the new `requests.Request` object
        :param str url: URL for the new `requests.Request` object

        :raises requests.exceptions.RequestException: in case of any problems

        :returns: HTTP Response
        :rtype: `requests.Response`


        POSTzSending POST request to %s:
%sdatazSending %s request to %s.verifyr&   z
User-Agentr   zT.*host='(\S*)'.*Max retries exceeded with url\: (\/\w*).*(\[Errno \d+\])([A-Za-z ]*)NzRequesting :Acceptzutf-8z!Received response:
HTTP %d
%s

%s
c              3   H   K   | ]\  }}d                      ||          V  dS )z{0}: {1}N)format)r   kvs      r   	<genexpr>z.ClientNetwork._send_request.<locals>.<genexpr>  sR       F F$(Aq  *00A66 F F F F F Fr   )r  r  r   r   r   r  r   requestr   
exceptionsRequestExceptionrematchr   groupsr   base64	b64encodecontentencodingr   r%   joinr&   items)r   r"  rc   r   r   r*   e	err_regexmhostpath_err_noerr_msgdebug_contents                 r   _send_requestzClientNetwork._send_requestl  s   " VLL:vf~/ / / / LL4fcBBB?x)R(((y$$\4?CCC)T%:;;;	C+t|+FCI$III&IIHH"3 	C 	C 	C/ pICFF++Ay+,88::(D$A4AAAAABBB+	C6 vi(((",X-=>>MM !(H$MM<)YY F F,4,<,B,B,D,DF F F F F"		$ 	$ 	$
 s   #B; ;D,AD''D,c                 $     | j         dg|R i |S )a  Send HEAD request without checking the response.

        Note, that `_check_response` is not called, as it is expected
        that status code other than successfully 2xx will be returned, or
        messages2.Error will be raised by the server.

        HEAD)rC  r   s      r   headzClientNetwork.head  s'     "t!&:4:::6:::r   c                 J    |                       | j        d|fi ||          S )z$Send GET request and check response.GETr  )r!  rC  )r   rc   r  r   s       r   r\   zClientNetwork.get  s@     ##Duc44V44< $ Q Q 	Qr   c                    | j         |j        v r|j        | j                  }	 t          j        j        d                             |          }n,# t          j        $ r}t          j	        ||          d }~ww xY wt                              d|           | j                            |           d S t          j        |          )Nr	  zStoring nonce: %s)REPLAY_NONCE_HEADERr&   r   Header_fieldsdecoder   r  r   BadNoncer  r  r   addMissingNonce)r   r*   r	  decoded_noncer   s        r   
_add_noncezClientNetwork._add_nonce  s    #x'777$T%=>E4 #
 27 ; B B5 I I, 4 4 4oeU3334LL,e444L]+++++%h///s   *A A6A11A6r   c                 $   | j         sqt                              d           ||                     |          }n*|                     |                     |          d           }|                     |           | j                                         S )NzRequesting fresh noncerI  )r   r  r  rF  r!  rS  pop)r   rc   r   r*   s       r   
_get_noncezClientNetwork._get_nonce  s    | 	&LL1222$99S>>  //		-0H0HW[/\\OOH%%%|!!!r   c                     	  | j         |i |S # t          j        $ r>}|j        dk    r-t                              d|            | j         |i |cY d}~S  d}~ww xY w)zPOST object wrapped in `.JWS` and check response.

        If the server responded with a badNonce error, the request will
        be retried once.

        badNoncez Retrying request after error:
%sN)
_post_oncer   r   coder  r  )r   r   r   r   s       r   r   zClientNetwork.post  s    	"4?D3F333~ 	 	 	zZ''@%HHH&t777777777		s     A2AAAAc                 2   |                     dd           }|                     ||                     ||          |          }|                    dd|i            | j        d|fd|i|}|                     ||          }|                     |           |S )Nr   r&   r  r$  r%  rI  )rU  r  rV  r   rC  r!  rS  )r   rc   r  r  r   r   r%  r*   s           r   rY  zClientNetwork._post_once  s    

?D99  dooc=&I&I3OO)nl%CDDD%4%fcGGGGG''|'LL!!!r   )r   Nr   )#r   r   r   r   r  JOSE_CONTENT_TYPEr  rK  r   RS256DEFAULT_NETWORK_TIMEOUTJWKr   r   r   JWASignaturer   r   r   r   r  JSONDeSerializabler  r   r   r   r!  r   rC  rF  r\   rS  rV  r   rY  r4   r   r   r   r     s         +/8(
 Z^*.*#0AX0 0DH 0x8U/V 0'0BF0 0;>0]a0 0 0 0    Z 7 Z Z# ZRU Z Z Z Z2 6:8 8x'8 8&.sm8?G?P8 8 8 [8tEC Ec E# E EQYQb E E E EN;# ; ;1B ; ; ; ; 1B Q Qs Q# QQ&/Q Q Q Q
08#4 
0 
0 
0 
0 
0	"c 	"# 	"# 	" 	" 	" 	"#  1B      (9 c (? !$DGLTL]     r   r   )(r   r5  rp   email.utilsr   http.clientclientr   loggingr2  rz   typingr   r   r   r   r   r	   r
   r   josepyr   rM   r   requests.adaptersr   requests.utilsr   acmer   r   r   r   r   	getLoggerr   r  r^  r   r   r4   r   r   <module>rl     s       $ $ $ $ $ $ ! ! ! ! ! !  				                                                        ) ) ) ) ) ) - - - - - -                              		8	$	$ ED ED ED ED ED ED ED EDPF F F F F F F F F Fr   