Ë
    [üàg  ã                   ó\   — d dl Z d dlZd dlmZmZ d dlmZmZ d„ Zd„ Z	d„ Z
 G d„ de«      Zy)	é    N)Úsha1Úsha256)ÚurlparseÚparse_qsc                 ór   — t        | «      t        |«      k7  ryd}t        | |«      D ]  \  }}|||k(  z  }Œ |S )zçCompare two strings while protecting against timing attacks

    :param str string1: the first string
    :param str string2: the second string

    :returns: True if the strings are equal, False if not
    :rtype: :obj:`bool`
    FT)ÚlenÚzip)Ústring1Ústring2ÚresultÚc1Úc2s        úV/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/twilio/request_validator.pyÚcomparer      sK   € ô ˆ7ƒ|”s˜7“|Ò#ØØ€FÜ�g˜wÓ'ò ‰ˆˆBØ�"˜‘(Ñ‰ðð €Mó    c                 óº   — | j                   s| j                  «       S | j                  j                  d«      d   }| j	                  |¬«      }|j                  «       S )z¥Remove the port number from a URI

    :param uri: parsed URI that Twilio requested on your server

    :returns: full URI without a port number
    :rtype: str
    ú:r   ©Únetloc)ÚportÚgeturlr   ÚsplitÚ_replace)ÚuriÚ
new_netlocÚnew_uris      r   Úremove_portr      sM   € ð �8Š8Ø�z‰z‹|Ðà—‘×!Ñ! #Ó& qÑ)€JØ�l‰l *ˆlÓ-€Gà�>‰>ÓÐr   c                 óÚ   — | j                   r| j                  «       S | j                  dk(  rdnd}| j                  dz   t	        |«      z   }| j                  |¬«      }|j                  «       S )z�Add the port number to a URI

    :param uri: parsed URI that Twilio requested on your server

    :returns: full URI with a port number
    :rtype: str
    Úhttpsi»  éP   r   r   )r   r   Úschemer   Ústrr   )r   r   r   r   s       r   Úadd_portr#   +   s]   € ð ‡x‚xØ�z‰z‹|Ðà—*‘* Ò'‰3¨R€DØ—‘˜cÑ!¤C¨£IÑ-€JØ�l‰l *ˆlÓ-€Gà�>‰>ÓÐr   c                   ó*   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚRequestValidatorc                 ó0   — |j                  d«      | _        y ©Núutf-8)ÚencodeÚtoken)Úselfr*   s     r   Ú__init__zRequestValidator.__init__>   s   € Ø—\‘\ 'Ó*ˆ�
r   c                 ó’  — |}|rLt        t        |«      «      D ]5  }| j                  ||«      }t        t        |«      «      D ]
  }|||z   z  }Œ Œ7 t        j                  | j
                  |j                  d«      t        «      }t        j                  |j                  «       «      }|j                  d«      }|j                  «       S )zâCompute the signature for a given request

        :param uri: full URI that Twilio requested on your server
        :param params: post vars that Twilio sent with the request

        :returns: The computed signature
        r(   )ÚsortedÚsetÚ
get_valuesÚhmacÚnewr*   r)   r   Úbase64Ú	b64encodeÚdigestÚdecodeÚstrip)	r+   r   ÚparamsÚsÚ
param_nameÚvaluesÚvalueÚmacÚcomputeds	            r   Úcompute_signaturez"RequestValidator.compute_signatureA   s­   € ð ˆÙÜ$¤S¨£[Ó1ò ,�
ØŸ™¨°Ó<�ä#¤C¨£KÓ0ò ,�EØ˜ eÑ+Ñ+‘Añ,ð,ô �h‰h�t—z‘z 1§8¡8¨GÓ#4´dÓ;ˆÜ×#Ñ# C§J¡J£LÓ1ˆØ—?‘? 7Ó+ˆà�~‰~ÓÐr   c                 ó–   — 	 |j                  |«      S # t        $ r, 	 |j                  |«      cY S # t        $ r ||   gcY cY S w xY ww xY w)N)ÚgetallÚAttributeErrorÚgetlist)r+   Ú
param_dictr:   s      r   r0   zRequestValidator.get_valuesX   sZ   € ð		0à×$Ñ$ ZÓ0Ð0øÜò 	0ð0à!×)Ñ)¨*Ó5Ò5øÜ!ò 0à" :Ñ.Ð/Ô/ð0úð		0ús(   ‚ “	A�0­A°A¿AÁAÁAc                 ór   — t        |j                  d«      «      j                  «       }|j                  «       S r'   )r   r)   Ú	hexdigestr7   )r+   Úbodyr>   s      r   Úcompute_hashzRequestValidator.compute_hashd   s+   € Ü˜$Ÿ+™+ gÓ.Ó/×9Ñ9Ó;ˆà�~‰~ÓÐr   c                 ól  — |€i }t        |«      }t        |«      }t        |«      }d}t        |j                  «      }d|v r3t        |t        «      r#t        | j                  |«      |d   d   «      }i }t        | j                  ||«      |«      }	t        | j                  ||«      |«      }
|xr |	xs |
S )a]  Validate a request from Twilio

        :param uri: full URI that Twilio requested on your server
        :param params: dictionary of POST variables or string of POST body for JSON requests
        :param signature: expected signature in HTTP X-Twilio-Signature header

        :returns: True if the request passes validation, False if not
        TÚ
bodySHA256r   )
r   r#   r   r   ÚqueryÚ
isinstancer"   r   rH   r?   )r+   r   r8   Ú	signatureÚ
parsed_uriÚuri_with_portÚuri_without_portÚvalid_body_hashrK   Úvalid_signatureÚvalid_signature_with_ports              r   ÚvalidatezRequestValidator.validatei   sÊ   € ð ˆ>ØˆFä˜c“]ˆ
Ü  Ó,ˆÜ& zÓ2Ðàˆä˜×)Ñ)Ó*ˆØ˜5Ñ ¤Z°¼Ô%<Ü% d×&7Ñ&7¸Ó&?ÀÀ|ÑATÐUVÑAWÓXˆOØˆFô "Ø×"Ñ"Ð#3°VÓ<¸ió
ˆô %,Ø×"Ñ" =°&Ó9¸9ó%
Ð!ð ÒQ OÒ$PÐ7PÐQr   N)Ú__name__Ú
__module__Ú__qualname__r,   r?   r0   rH   rT   © r   r   r%   r%   =   s   „ ò+ò ò.
0ò ó
 Rr   r%   )r3   r1   Úhashlibr   r   Úurllib.parser   r   r   r   r#   Úobjectr%   rX   r   r   ú<module>r\      s0   ðÛ Û ß  ç +òò$ò"ô$LR�võ LRr   