
    Yj                    p    d dl mZ d dl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Zy)	    )annotationsN   )HeadersLike)get_required_header)InvalidWebhookSignatureErrorc               v   t        |d      }t        |d      }t        |d      }	 t        |      }t        t	        j                               }||z
  |kD  rt        d      d|||z   kD  rt        d      dg }	|j                         D ]9  }
|
j                  d      r|	j                  |
d	d        )|	j                  |
       ; |j                  d
      rt        j                  |dd       }n|j                         }t        | t              r| j                  d      n| }| d| d| }t        j                  t        j                   ||j                         t"        j$                        j'                               j                         t)        fd|	D              S # t        $ r t        d      dw xY w)z?Validate the replay window and compare the supplied signatures.zwebhook-signaturezwebhook-timestampz
webhook-idz Invalid webhook timestamp formatNzWebhook timestamp is too oldzWebhook timestamp is too newzv1,   whsec_   zutf-8.c              3  J   K   | ]  }t        j                  |        y w)N)hmaccompare_digest).0sigexpected_signatures     S/var/www/html/vmm-quimica/venv/lib/python3.12/site-packages/openai/lib/_webhooks.py	<genexpr>z,webhook_signature_matches.<locals>.<genexpr>@   s     Rt""#5s;Rs    #)r   int
ValueErrorr   timesplit
startswithappendbase64	b64decodeencode
isinstancebytesdecode	b64encoder   newhashlibsha256digestany)payloadheaderssecret	tolerancesignature_header	timestamp
webhook_idtimestamp_secondsnow
signaturespartdecoded_secretbodysigned_payloadr   s                 @r   webhook_signature_matchesr5      s    +74GH#G-@AI$Wl;JY	N diik
C
**+IJPTT3?**+IJPTT
 J &&( $??5!d12h'd#	$ "))&*5&0%&@7>>'"gD #|1YKq7N))!6!6!8'..IPPRfh 
 RzRRRI  Y*+MNTXXYs   F" "F8)
r'   zstr | bytesr(   r   r)   strr*   r   returnbool)
__future__r   r   r   r   r#   _typesr   _utilsr   _exceptionsr   r5        r   <module>r?      sV    "       ( 63S3S3S 	3S
 3S 
3Sr>   