+
    ~j;  c                  t  a  0 t $ ^ RIHt ^ RIt^ RIHu Ht Rt	^ RI
t
^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHtHt ^RIHtHtHtHtHt ^RI H!t!H"t" ^RI#H$t$H%t%H&t&H't'H(t(H)t) ]PT                  R8  d
   ^ RIH+t+H,t, M^ RI-H+t+H,t, ]PT                  R8  d   ^ RIH.t. M^ RI-H.t. ]! R4      t/]+! R4      t0]1]1]2]23,          R3,          t3R]4R&   ]1]3R3,          t5R]4R&    ! R R]!4      t6]! RR7       ! R R]&4      4       t7]! RR7       ! R R](]7,          4      4       t8 ! R R]'4      t9R# )     )annotationsNTLSAttributeTLSConnectableTLSListener	TLSStream)CallableMapping)	dataclass)wraps)
SSLContext)Any	TypeAliasTypeVar)BrokenResourceErrorEndOfStreamaclose_forcefullyget_cancelled_exc_class	to_thread)TypedAttributeSettyped_attribute)AnyByteStreamAnyByteStreamConnectable
ByteStreamByteStreamConnectableListener	TaskGroup)TypeVarTupleUnpack)overrideT_RetvalPosArgsT.r   _PCTRTT_PCTRTTTc                     ] tR t^5t$ Rt]! 4       tR]R&   ]! 4       tR]R&   ]! 4       t	R]R&   ]! 4       t
R]R	&   ]! 4       tR
]R&   ]! 4       tR]R&   ]! 4       tR]R&   ]! 4       tR]R&   ]! 4       tR]R&   ]! 4       tR]R&   RtR# )r   z5Contains Transport Layer Security related attributes.
str | Nonealpn_protocolbyteschannel_binding_tls_uniqueztuple[str, str, int]cipherz*None | dict[str, str | _PCTRTTT | _PCTRTT]peer_certificatezbytes | Nonepeer_certificate_binaryboolserver_sidez!list[tuple[str, str, int]] | Noneshared_ciphersssl.SSLObject
ssl_objectstandard_compatiblestrtls_version N)__name__
__module____qualname____firstlineno____doc__r   r%   __annotations__r'   r(   r)   r*   r,   r-   r/   r0   r2   __static_attributes__r3       f/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/anyio/streams/tls.pyr   r   5   s    ? !0 1M:1(7(99#2#4F 4 FUEVBV,;,=\=')K) 9H8IN5I / 1J1 !0 11&(K(r;   F)eqc            	          ] tR t^Qt$ RtR]R&   R]R&   R]R&   R]R	&   R]R
&   ]RRRRRRRR/R R ll4       tR R ltR R lt	R R lt
R!R R lltR R ltR R lt]R R l4       tR tR# )"r   a  
A stream wrapper that encrypts all sent data and decrypts received data.

This class has no public initializer; use :meth:`wrap` instead.
All extra attributes from :class:`~TLSAttribute` are supported.

:var AnyByteStream transport_stream: the wrapped stream

r   transport_streamr+   r0   r.   _ssl_objectzssl.MemoryBIO	_read_bio
_write_bior,   Nhostnamessl_contextTc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )   r?   r   r,   zbool | NonerC   r$   rD   ssl.SSLContext | Noner0   r+   returnr   r3   )formats   "r<   __annotate__TLSStream.__annotate__d   sN     D D'D !	D
 D +D "D 
Dr;   c                 "   Vf   V'       * pV'       g   V'       d   \         P                  P                  M\         P                  P                  p\         P                  ! V4      p\        \         R4      '       d)   V;P                  \         P                  ( ,          un        \         P                  ! 4       p\         P                  ! 4       p\        V4      \         P                  J d   VP                  WxW#R7      p	M-\        P                  ! VP                  VVVVR4      G Rj  xL
 p	V ! VVV	VVR7      p
V
P                  V	P                  4      G Rj  xL
  V
#  L6 L5i)a\  
Wrap an existing stream with Transport Layer Security.

This performs a TLS handshake with the peer.

:param transport_stream: a bytes-transporting stream to wrap
:param server_side: ``True`` if this is the server side of the connection,
    ``False`` if this is the client side (if omitted, will be set to ``False``
    if ``hostname`` has been provided, ``False`` otherwise). Used only to create
    a default context when an explicit context has not been provided.
:param hostname: host name of the peer (if host name checking is desired)
:param ssl_context: the SSLContext object to use (if not provided, a secure
    default will be created)
:param standard_compatible: if ``False``, skip the closing handshake when
    closing the connection, and don't raise an exception if the peer does the
    same
:raises ~ssl.SSLError: if the TLS handshake fails

NOP_IGNORE_UNEXPECTED_EOF)r,   server_hostname)r?   r0   r@   rA   rB   )sslPurposeCLIENT_AUTHSERVER_AUTHcreate_default_contexthasattroptionsrM   	MemoryBIOtyper   wrap_bior   run_sync_call_sslobject_methoddo_handshake)clsr?   r,   rC   rD   r0   purposebio_inbio_outr/   wrappers   &&$$$$     r<   wrapTLSStream.wrapc   s,    : &,K+6''CKK<S<S  44W=K s677##(D(D'DD#--/ .$--[ . J  )11$$  J - 3"
 ,,Z-D-DEEE#  	Fs.   E$E$DE$)E */E$E"E$"E$c               $    V ^8  d   QhRRRRRR/# )rF   funcz&Callable[[Unpack[PosArgsT]], T_Retval]argszUnpack[PosArgsT]rH   r   r3   )rI   s   "r<   rJ   rK      s$     , ,:,CS,	,r;   c                	  "     V! V!  pV P                   P                  '       d<   V P                  P                  V P                   P	                  4       4      G Rj  xL
  V#  L  \
        P                   Ed     T P                   P                  '       d=   T P                  P                  T P                   P	                  4       4      G Rj  xL 
  T P                  P                  4       G Rj  xL 
 pT P                  P                  T4        EK    \         d!    T P                  P                  4          EK>  \         dA   pT P                  P                  4        T P                   P                  4        \        ThRp?ii ; i\
        P                   dB    T P                  P                  T P                   P	                  4       4      G Rj  xL 
   EK  \
        P                   dA   pT P                  P                  4        T P                   P                  4        \        ThRp?i\
        P                    d   pT P                  P                  4        T P                   P                  4        \#        T\
        P$                  4      '       g$   TP&                  '       d2   RTP&                  9   d!   T P(                  '       d   \        Th\        Rhh Rp?ii ; i5i)TNUNEXPECTED_EOF_WHILE_READING)rB   pendingr?   sendreadrO   SSLWantReadErrorreceiverA   writer   	write_eofOSErrorr   SSLWantWriteErrorSSLSyscallErrorSSLError
isinstanceSSLEOFErrorstrerrorr0   )selfrd   re   resultdataexcs   &&*   r<   rZ    TLSStream._call_sslobject_method   s     (tH ??***//44T__5I5I5KLLL MI '' //..."33889M9M9OPPP!%!6!6!>!>!@@@D NN((.. # /NN,,.. 7NN,,.OO--/-367 (( I++001E1E1GHHH&& 3((*))+)s2<< ((*))+c3??33LLL%Cs||%S///1s:)t3s   K)A& AK)A$K)&K&=D6DC"D2C53D8K&K)%F<K&=K)F
F;FFK&!7K&GK&K)"K&5K&6;H11K&K&	A%K!/"K!K!!K&&K)c                   V ^8  d   QhRR/# )rF   rH   ztuple[AnyByteStream, bytes]r3   )rI   s   "r<   rJ   rK      s     
< 
<9 
<r;   c                  "   V P                  V P                  P                  4      G Rj  xL
  V P                  P	                  4        V P
                  P	                  4        V P                  V P                  P                  4       3#  L^5i)zl
Does the TLS closing handshake.

:return: a tuple of (wrapped byte stream, bytes left in the read buffer)

N)rZ   r@   unwraprA   rn   rB   r?   rj   rv   s   &r<   r}   TLSStream.unwrap   sk      ))$*:*:*A*ABBB  "!!#$$dnn&9&9&;;; 	Cs   )BB
ABc                   V ^8  d   QhRR/# rF   rH   Noner3   )rI   s   "r<   rJ   rK      s     - -d -r;   c                	  "   V P                   '       d    V P                  4       G R j  xL
  V P                  P                  4       G R j  xL
  R #  L(  \         d!    \        T P                  4      G R j  xL 
  h i ; i L65iN)r0   r}   BaseExceptionr   r?   acloser~   s   &r<   r   TLSStream.aclose   so     ###kkm##
 ##**,,, $  '(=(=>>> 	-sC   BA AA BBBA #A?7A:8A??Bc                    V ^8  d   QhRRRR/# )rF   	max_bytesintrH   r&   r3   )rI   s   "r<   rJ   rK      s      s u r;   c                	   "   V P                  V P                  P                  V4      G R j  xL
 pV'       g   \        hV#  L5ir   )rZ   r@   rj   r   )rv   r   rx   s   && r<   rl   TLSStream.receive   s:     001A1A1F1F	RR	 Ss   *AAA	Ac                    V ^8  d   QhRRRR/# )rF   itemr&   rH   r   r3   )rI   s   "r<   rJ   rK      s     H Hu H Hr;   c                	n   "   V P                  V P                  P                  V4      G R j  xL
  R #  L5ir   )rZ   r@   rm   )rv   r   s   &&r<   ri   TLSStream.send   s'     ))$*:*:*@*@$GGGs   *535c                   V ^8  d   QhRR/# r   r3   )rI   s   "r<   rJ   rK      s     
 
 
r;   c                	B  "   V P                  \        P                  4      p\        P                  ! R V4      pV'       dT   \        VP                  ^4      4      \        VP                  ^4      ;'       g    ^ 4      rCW43R8  d   \        RV 24      h\        R4      h5i)zTLSv(\d+)(?:\.(\d+))?z;send_eof() requires at least TLSv1.3; current session uses z7send_eof() has not yet been implemented for TLS streams)      )extrar   r2   rematchr   groupNotImplementedError)rv   r2   r   majorminors   &    r<   send_eofTLSStream.send_eof   s     jj!9!9:1;?u{{1~.EKKN4G4Ga0H5~&)$$/=2 
 "E
 	
s   A4B7(Bc                   V ^8  d   QhRR/# rF   rH   zMapping[Any, Callable[[], Any]]r3   )rI   s   "r<   rJ   rK     s     
 
"A 
r;   c                	H  a  / S P                   P                  C\        P                  S P                  P
                  \        P                  S P                  P                  \        P                  S P                  P                  \        P                  V 3R  l\        P                  V 3R l\        P                  V 3R l\        P                  V 3R l\        P                  V 3R l\        P                  V 3R l\        P                  S P                  P                   /
C# )c                 :   < S P                   P                  R 4      # )Fr@   getpeercertr~   s   r<   <lambda>,TLSStream.extra_attributes.<locals>.<lambda>  s    43C3C3O3OPU3Vr;   c                 :   < S P                   P                  R 4      # )Tr   r~   s   r<   r   r     s    $:J:J:V:V;r;   c                 0   < S P                   P                  # r   )r@   r,   r~   s   r<   r   r     s    d.>.>.J.Jr;   c                 t   < S P                   P                  '       d   S P                   P                  4       # R # r   )r@   r,   r-   r~   s   r<   r   r     s6    ##///   //1 r;   c                    < S P                   # r   r0   r~   s   r<   r   r         d6N6Nr;   c                    < S P                   # r   )r@   r~   s   r<   r   r     s    T-=-=r;   )r?   extra_attributesr   r%   r@   selected_alpn_protocolr'   get_channel_bindingr(   r)   r*   r,   r-   r0   r/   r2   versionr~   s   fr<   r   TLSStream.extra_attributes  s    
##44
&&(8(8(O(O33  44!1!1!8!8))+V00 3 $$&J'' *
 ,,.N##%=$$d&6&6&>&>'
 	
r;   r3   )i   )r4   r5   r6   r7   r8   r9   classmethodra   rZ   r}   r   rl   ri   r   propertyr   r:   r3   r;   r<   r   r   Q   s     $#D $(	D
  $D .2D %)D DL,\
<-H
 
 
r;   c                      ] tR tRt$ RtR]R&   R]R&   RtR]R	&   ^tR
]R&   ]R R l4       t	RR R llt
R R lt]R R l4       tRtR# )r   i   aj  
A convenience listener that wraps another listener and auto-negotiates a TLS session
on every accepted connection.

If the TLS handshake times out or raises an exception,
:meth:`handle_handshake_error` is called to do whatever post-mortem processing is
deemed necessary.

Supports only the :attr:`~TLSAttribute.standard_compatible` extra attribute.

:param Listener listener: the listener to wrap
:param ssl_context: the SSL context object
:param standard_compatible: a flag passed through to :meth:`TLSStream.wrap`
:param handshake_timeout: time limit for the TLS handshake
    (passed to :func:`~anyio.fail_after`)
zListener[Any]listenerzssl.SSLContextrD   Tr+   r0   floathandshake_timeoutc               $    V ^8  d   QhRRRRRR/# )rF   ry   r   streamr   rH   r   r3   )rI   s   "r<   rJ   TLSListener.__annotate__9  s"      -  SW r;   c                $  "   \        V4      G Rj  xL
  \        V \        4       4      '       g,   \        P                  ! \
        4      P                  RV R7       \        V \        4      '       d   \        V \        4       4      '       d   h R#  L|5i)au  
Handle an exception raised during the TLS handshake.

This method does 3 things:

#. Forcefully closes the original stream
#. Logs the exception (unless it was a cancellation exception) using the
   ``anyio.streams.tls`` logger
#. Reraises the exception if it was a base exception or a cancellation exception

:param exc: the exception
:param stream: the original stream

NzError during TLS handshake)exc_info)r   rs   r   logging	getLoggerr4   	exception	Exception)ry   r   s   &&r<   handle_handshake_error"TLSListener.handle_handshake_error8  sz        ''' #6899
 h'11,s 2 
 #y))Z=T=V-W-W .X 	(s   BBA=BNc               $    V ^8  d   QhRRRRRR/# )rF   handlerzCallable[[TLSStream], Any]
task_groupzTaskGroup | NonerH   r   r3   )rI   s   "r<   rJ   r   X  s(     ? ?+? %? 
	?r;   c                	   a a"   \        S4      R  VV 3R ll4       pS P                  P                  W24      G Rj  xL
  R#  L5i)c                    V ^8  d   QhRRRR/# )rF   r   r   rH   r   r3   )rI   s   "r<   rJ   'TLSListener.serve.<locals>.__annotate__^  s     	. 	.- 	.D 	.r;   c                  <"   ^RI Hp  V! SP                  4      ;_uu_ 4        \        P	                  V SP
                  SP                  R7      G Rj  xL
 pRRR4       S! X4      G Rj  xL
  R#  L  + '       g   i     L$; i L  \         d&   pSP                  Y04      G Rj  xL 
   Rp?R# Rp?ii ; i5i)rF   )
fail_after)rD   r0   N)	 r   r   r   ra   rD   r0   r   r   )r   r   wrapped_streamry   r   rv   s   &   r<   handler_wrapper*TLSListener.serve.<locals>.handler_wrapper]  s     %
. 6 677+4>>$($4$4,0,D,D ,: , &N 8 n---& 87 . ! ?11#>>>?su   B>B 0A6A4A6B "B>-B	.B>4A66B	B 	B>B;B6*B-+B60B>6B;;B>N)r
   r   serve)rv   r   r   r   s   ff& r<   r   TLSListener.serveX  s=     
 
w	. 	. 
	. mm!!/>>>s   7AAAc                   V ^8  d   QhRR/# r   r3   )rI   s   "r<   rJ   r   o  s     % %d %r;   c                	V   "   V P                   P                  4       G R j  xL
  R #  L5ir   )r   r   r~   s   &r<   r   TLSListener.acloseo  s     mm""$$$s   )')c                   V ^8  d   QhRR/# r   r3   )rI   s   "r<   rJ   r   s  s     
 
"A 
r;   c                	0   a  \         P                  V 3R  l/# )c                    < S P                   # r   r   r~   s   r<   r   .TLSListener.extra_attributes.<locals>.<lambda>u  r   r;   )r   r0   r~   s   fr<   r   TLSListener.extra_attributesr  s     ,,.N
 	
r;   r3   r   )r4   r5   r6   r7   r8   r9   r0   r   staticmethodr   r   r   r   r   r:   r3   r;   r<   r   r      s[    "  $$!u! >?.% 
 
r;   c                  L    ] tR tRtRtRRRRRR/R R	 llt]R
 R l4       tRtR# )r   iy  a  
Wraps another connectable and does TLS negotiation after a successful connection.

:param connectable: the connectable to wrap
:param hostname: host name of the server (if host name checking is desired)
:param ssl_context: the SSLContext object to use (if not provided, a secure default
    will be created)
:param standard_compatible: if ``False``, skip the closing handshake when closing
    the connection, and don't raise an exception if the server does the same
rC   NrD   r0   Tc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )rF   connectabler   rC   r$   rD   rG   r0   r+   rH   r   r3   )rI   s   "r<   rJ   TLSConnectable.__annotate__  s<     7 7-7 	7
 +7 "7 
7r;   c               	N   Wn         T;'       g/    \        P                  ! \        P                  P                  4      V n        \        V P
                  \        P                  4      '       g,   \        R \        V P
                  4      P                   24      hW n        W@n        R# )z7ssl_context must be an instance of ssl.SSLContext, not N)r   rO   rS   rP   rR   rD   rs   r   	TypeErrorrW   r4   rC   r0   )rv   r   rC   rD   r0   s   &&$$$r<   __init__TLSConnectable.__init__  s     ''2 (
 (
c6P6PKK##7
 $**CNN;;I(()2235  !#6 r;   c                   V ^8  d   QhRR/# )rF   rH   r   r3   )rI   s   "r<   rJ   r     s      y r;   c                	  "   V P                   P                  4       G R j  xL
 p \        P                  VV P                  V P
                  V P                  R7      G R j  xL
 #  LD L  \         d    \        T4      G R j  xL 
  h i ; i5i)N)rC   rD   r0   )	r   connectr   ra   rC   rD   r0   r   r   )rv   r   s   & r<   r   TLSConnectable.connect  s     ''//11		" ,,$($<$<	 (    2  	#F+++	sD   BA%B:A)  A'!A) $B'A) )B
BB

B)r   rC   rD   r0   )	r4   r5   r6   r7   r8   r   r   r   r:   r3   r;   r<   r   r   y  s>    	7  $	7
 .27 %)7(  r;   )r   r   r   r   )r      )r      ):__conditional_annotations__
__future__r   builtins@py_builtins_pytest.assertion.rewrite	assertionrewrite
@pytest_ar__all__r   r   rO   syscollections.abcr   r   dataclassesr	   	functoolsr
   r   typingr   r   r   r   r   r   r   r   r   _core._typedattrr   r   abcr   r   r   r   r   r   version_infor   r   typing_extensionsr   r   r    tupler1   r!   r9   r"   r   r   r   r   )r   s   @r<   <module>r      s)   " "      	 
 
 - !   * *  B  w++6w*:
#5c?C/0 0GSL)) ))$ )8 eK

 K
 K
\ eU
(9% U
 U
p,* ,r;   