Ë
    [üàgÒ  ã                   óˆ   — d dl mZ d dlmZ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dg d	¢«      Z G d
„ de
«      Zy)é    )Ú
namedtuple)ÚRequestÚSession)ÚTwilioRestException)Úurlparse)Ú
HttpClient)ÚResponse)ÚClientValidationJwtÚValidationPayload©ÚmethodÚpathÚquery_stringÚall_headersÚsigned_headersÚbodyc                   óD   — e Zd ZddgZ	 d	d„Z	 	 	 	 	 	 d
d„Zd„ Zd„ Zd„ Zy)ÚValidationClientÚauthorizationÚhostc                 ón   — || _         || _        || _        || _        |rt	        «       | _        yd| _        y)a+  
        Build a ValidationClient which signs requests with private_key and allows Twilio to
        validate request has not been tampered with.

        :param str account_sid: A Twilio Account Sid starting with 'AC'
        :param str api_key_sid: A Twilio API Key Sid starting with 'SK'
        :param str credential_sid: A Credential Sid starting with 'CR',
                                   corresponds to public key Twilio will use to verify the JWT.
        :param str private_key: The private key used to sign the Client Validation JWT.
        N)Úaccount_sidÚcredential_sidÚapi_key_sidÚprivate_keyr   Úsession)Úselfr   r   r   r   Úpool_connectionss         ú[/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/twilio/http/validation_client.pyÚ__init__zValidationClient.__init__   s5   € ð$ 'ˆÔØ,ˆÔØ&ˆÔØ&ˆÔÙ$4”w“yˆ�¸$ˆ�ó    Nc	                 óJ  — | j                   xs
 t        «       }	t        |j                  «       |||||¬«      }
|	j	                  |
«      }d|j
                  vr,d|j
                  vr| j                  |«      |j
                  d<   | j                  |«      }t        | j                  | j                  | j                  | j                  |«      }|j                  «       |j
                  d<   |	j                  |||¬«      }t        t!        |j"                  «      |j$                  «      S )aØ  
        Make a signed HTTP Request

        :param str method: The HTTP method to use
        :param str url: The URL to request
        :param dict params: Query parameters to append to the URL
        :param dict data: Parameters to go in the body of the HTTP request
        :param dict headers: HTTP Headers to send with the request
        :param tuple auth: Basic Auth arguments
        :param float timeout: Socket/Read timeout for the request
        :param boolean allow_redirects: Whether or not to allow redirects
        See the requests documentation for explanation of all these parameters

        :return: An http response
        :rtype: A :class:`Response <twilio.rest.http.response.Response>` object
        )ÚparamsÚdataÚheadersÚauthÚHostr   zTwilio-Client-Validation)Úallow_redirectsÚtimeout)r   r   r   ÚupperÚprepare_requestr%   Ú	_get_hostÚ_build_validation_payloadr
   r   r   r   r   Úto_jwtÚsendr	   ÚintÚstatus_codeÚtext)r   r   Úurlr#   r$   r%   r&   r)   r(   r   ÚrequestÚprepared_requestÚvalidation_payloadÚjwtÚresponses                  r   r4   zValidationClient.request-   s  € ð6 —,‘,Ò+¤'£)ˆÜØ�L‰L‹N˜C¨°TÀ7ÐQUô
ˆð #×2Ñ2°7Ó;Ðð Ð*×2Ñ2Ñ2ØÐ.×6Ñ6Ñ6à/3¯~©~Ð>NÓ/OÐ×$Ñ$ VÑ,à!×;Ñ;Ð<LÓMÐÜ!Ø×ÑØ×ÑØ×ÑØ×ÑØó
ˆð @C¿z¹z»|Ð× Ñ Ð!;Ñ<à—<‘<ØØ+Øð  ó 
ˆô œ˜H×0Ñ0Ó1°8·=±=ÓAÐAr!   c           	      óæ   — t        |j                  «      }|j                  }|j                  xs d}t	        |j
                  |||j                  t        j                  |j                  xs d¬«      S )zÏ
        Extract relevant information from request to build a ClientValidationJWT
        :param PreparedRequest request: request we will extract information from.
        :return: ValidationPayload
        Ú r   )
r   r3   r   Úqueryr   r   r%   r   Ú!_ValidationClient__SIGNED_HEADERSr   )r   r4   Úparsedr   r   s        r   r-   z*ValidationClient._build_validation_payloadf   s_   € ô ˜'Ÿ+™+Ó&ˆØ�{‰{ˆØ—|‘|Ò) rˆä Ø—>‘>ØØ%ØŸ™Ü+×<Ñ<Ø—‘Ò# ô
ð 	
r!   c                 óV   — t        |j                  «      }t        |j                  «      S )z Pull the Host out of the request)r   r3   ÚstrÚnetloc)r   r4   r=   s      r   r,   zValidationClient._get_hosty   s   € ä˜'Ÿ+™+Ó&ˆÜ�6—=‘=Ó!Ð!r!   c                 ó’   — |j                  dd«      }|j                  dk  s|j                  dk\  rt        |j                  dd«      ‚y)z£
        Validate that a request to the new SSL certificate is successful
        :return: null on success, raise TwilioRestException if the request fails
        ÚGETzhttps://tls-test.twilio.com:443éÈ   i,  z"Failed to validate SSL certificateN)r4   r1   r   )r   Úclientr8   s      r   Úvalidate_ssl_certificatez)ValidationClient.validate_ssl_certificate~   sR   € ð
 —>‘> %Ð)JÓKˆà×Ñ #Ò%¨×)=Ñ)=ÀÒ)DÜ%Ø×$Ñ$Ø1Ø4óð ð *Er!   )T)NNNNNF)	Ú__name__Ú
__module__Ú__qualname__r<   r    r4   r-   r,   rE   © r!   r   r   r      sA   „ Ø'¨Ð0Ðð ó?ð8 ØØØØØó7Bòr
ò&"ó
r!   r   N)Úcollectionsr   Úrequestsr   r   Útwilio.base.exceptionsr   Úurllib.parser   Útwilio.httpr   Útwilio.http.responser	   Útwilio.jwt.validationr
   r   r   rI   r!   r   ú<module>rQ      s;   ðÝ "ç %å 6Ý !Ý "Ý )Ý 5ñ ØÚOóÐ ôx�zõ xr!   