+
    4O|j@Í  ã                  óò  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIHtHtHtHtHtHtHtHtHtHtHtHt  ^ RIHt ^ RIHt ^ RIHt ^ RIH t  ^ R	I!H"t" R
t#^ RI&H't'H(t(H)t) ^ RI*H+t+H,t,H-t- ^ RI.H/t/ ^ RI0H1t1 ^ RI2H3t3H4t4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t; ^ RI<H=t=H>t>H?t?H@t@ ^ RIAHBtBHCtCHDtDHEtEHFtFHGtG ^ RIHHItI ^ RIJHKtK ^ RILHMtM ^ RINHOtO ^ RIPHQtQHRtR ^ RISHTtT ^ RIUHVtVHWtW ^ RIXHYtYHZtZ ^ RI[H\t\ ^ RI]H^t^ ^ R I_H`t` ^ R!IaHbtb ^ R"IcHdtdHete ^ R#IfHgtgHhth ^ R$IiHjtj ]'       d   ^ R%IHktk ^ R&IlHmtm ^ R'IcHntn R
toR(tp]9tqR)tr]/! ]]s]3,          ]+R*7      ttR+]uR,&   ]/! ]4R-7      tvR. R/ ltw]Pð                  R0 R1 l4       ty ! R2 R3]"4      tz ! R4 R54      t{ ! R6 R74      t| ! R8 R9]s]Pú                  4      t~ ! R: R;]s]Pú                  4      tR< R= lt€ ! R> R?]]d,          4      t�R#   ]$ d	    Rt#]%t" EL�i ; i)@z8Support for explicit client-side field level encryption.)ÚannotationsN)Údeepcopy)ÚTYPE_CHECKINGÚAnyÚDictÚ	GeneratorÚGenericÚIteratorÚMappingÚMutableMappingÚOptionalÚSequenceÚUnionÚcast)ÚMongoCryptError)ÚMongoCryptOptions)ÚAutoEncrypter)ÚExplicitEncrypter)ÚMongoCryptCallbackTF)Ú_dict_to_bsonÚdecodeÚencode)ÚSTANDARDÚUUID_SUBTYPEÚBinary)ÚCodecOptions)Ú	BSONError)ÚDEFAULT_RAW_BSON_OPTIONSÚRawBSONDocumentÚ_inflate_bson)Ú_csot)ÚCONNECT_TIMEOUT)Ú_spawn_daemon)ÚAutoEncryptionOptsÚ	RangeOptsÚTextOptsÚcheck_min_pymongocrypt)ÚConfigurationErrorÚEncryptedCollectionErrorÚEncryptionErrorÚInvalidOperationÚNetworkTimeoutÚServerSelectionTimeoutError)Ú_get_timeout_details)Úsendall)Ú	UpdateOne)ÚPoolOptions)Ú_configured_socketÚ_raise_connection_failure)ÚReadConcern)ÚBulkWriteResultÚDeleteResult)ÚBLOCKING_IO_ERRORSÚget_ssl_context)Ú
Collection)ÚCursor)ÚDatabase)ÚMongoClient)Ú_DocumentTypeÚ_DocumentTypeArg)Ú_parse_kms_tls_optionsÚ
parse_host)ÚWriteConcern)ÚMongoCryptKmsContext)Ú_sslConn)Ú_Addressi»  i'  )Údocument_classÚuuid_representationzCodecOptions[dict[str, Any]]Ú_DATA_KEY_OPTS)rD   c               ó$   € V ^8„  d   QhRRRRRR/# )é   ÚaddressrC   Úoptsr0   ÚreturnzUnion[socket.socket, _sslConn]© )Úformats   "ÚWC:\Users\alokc\chatbot\backend\venv\Lib\site-packages\pymongo/synchronous/encryption.pyÚ__annotate__rO   v   s'   € ÷ \ñ \˜(ð \¨+ð \Ð:Xñ \ó    c                óx   €  \        W4      #   \         d"   p\        Y\        T4      R 7        Rp?R# Rp?ii ; i))Útimeout_detailsN)r1   Ú	Exceptionr2   r-   )rI   rJ   Úexcs   && rN   Ú_connect_kmsrU   v   s9   € ð\Ü! 'Ó0Ð0øÜô \Ü! 'Ô@TÐUYÓ@Z×[Ó[ûð\ús   ‚
 �9˜4´9c               ó   € V ^8„  d   QhRR/# )rH   rK   zIterator[None]rL   )rM   s   "rN   rO   rO   ~   s   € ÷ 	,ñ 	, ñ 	,rP   c               #  ól   "  €  Rx € R#   \          d    h \         d   p \        T 4      T hRp ? ii ; i5i)z2Context manager to wrap encryption related errors.N)r   rS   r)   )rT   s    rN   Ú_wrap_encryption_errorsrX   }   s6   é € ð,ÝøÜô ð 	Üô ,Ü˜cÓ"¨Ð+ûð,üs    ‚4„
 ˆ4Š1Ÿ1 ,¬1±4c                  ó‚   € ] tR t^ŠtR R ltR R ltR R ltR R ltR	 R
 ltR R lt	R R lt
R R ltR R ltRtR# )Ú_EncryptionIOc               ó(   € V ^8„  d   QhRRRRRRRR/# )rH   Úclientz'Optional[MongoClient[_DocumentTypeArg]]Úkey_vault_collzCollection[_DocumentTypeArg]Úmongocryptd_clientrJ   r#   rL   )rM   s   "rN   rO   Ú_EncryptionIO.__annotate__‹   s9   € ÷ Bñ Bà7ðBð 5ðBð Dð	Bð
 !ñBrP   c                óF  € V  Ve   \         P                  ! V4      V n        MRV n        \        \        \
        ,          VP                  \        \        RR7      \        RR7      R7      4      V n
        W0n        W@n        RV n        VP                  \        4      V n        R# )z8Internal class to perform I/O on behalf of pymongocrypt.NÚmajority)Úlevel)Úw)Úcodec_optionsÚread_concernÚwrite_concernF)ÚweakrefÚrefÚ
client_refr   r8   r   Úwith_optionsÚ_KEY_VAULT_OPTSr3   r@   r]   r^   rJ   Ú_spawnedÚ_kms_ssl_contextsÚ_IS_SYNC)Úselfr\   r]   r^   rJ   s   &&&&&rN   Ú__init__Ú_EncryptionIO.__init__‹   s‡   € ñ 	àÒÜ%Ÿkšk¨&Ó1ˆD�Oà"ˆDŒOÜEIÜ”Õ'Ø×'Ñ'Ü-Ü(¨zÔ:Ü*¨ZÔ8ð (ó óF
ˆÔð #5ÔØŒ	ØˆŒØ!%×!7Ñ!7¼Ó!AˆÖrP   c               ó    € V ^8„  d   QhRRRR/# )rH   Úkms_contextrA   rK   ÚNonerL   )rM   s   "rN   rO   r_   ¦   s   € ÷ T)ñ T)Ð';ð T)Àñ T)rP   c           
     óÀ  € VP                   pVP                  pVP                  pV P                  P	                  V4      pVf   \        RRRRRRR\        4      p\        \        P                  ! \        4      R4      p\        VVVR7      p\        V\        4      pVP                  p	V	'       d)   \        V	4      R,          p
\         P"                  ! V
4        \%        W‡4      p \'        W³4       VP(                  ^ 8”  dš   VP+                  \        \        P                  ! \        4      ^ 4      4       \        '       d   VP-                  VP(                  4      pM^ RIHp V! W±P(                  4      pV'       g   \3        R4      hVP5                  V4       Kª   TPG                  4        R#   \6         d    h \8         di   p\;        T\<        4      '       d   \>        P@                  ! R4      p\;        T\2        4      '       d   RpMRp\C        YŽT\E        T4      R	7        Rp?L‹Rp?ii ; i  TPG                  4        i ; i  \6         d    h \8         d…   p\        PH                  ! 4       p\;        T\J        4      '       g   Te	   T^ 8:  d   h  TPM                  4         Rp?R#   \6         d$   p\7        T R
T 2TPN                  4      pTThRp?ii ; iRp?ii ; i)z]Complete a KMS request.

:param kms_context: A :class:`MongoCryptKmsContext`.

:return: None
NFgü©ñÒMbP?)Úconnect_timeoutÚsocket_timeoutÚssl_contextg    €„.A)Úreceive_data_socketzKMS connection closedz	timed out)Ú
msg_prefixrR   z, last attempt failed with: )(ÚendpointÚmessageÚkms_providerrm   Úgetr7   rn   Úmaxr    Úclamp_remainingÚ_KMS_CONNECT_TIMEOUTr0   r?   Ú_HTTPS_PORTÚusleepÚfloatÚtimeÚsleeprU   r.   Úbytes_neededÚ
settimeoutÚrecvÚpymongo.network_layerry   ÚOSErrorÚfeedr   rS   Ú
isinstancer6   ÚsocketÚtimeoutr2   r-   ÚcloseÚ	remainingr+   ÚfailÚcode)ro   rs   r{   r|   ÚproviderÚctxrv   rJ   rI   Úsleep_uÚ	sleep_secÚconnÚdatary   rT   rz   r‘   Ú	final_errs   &&                rN   Úkms_requestÚ_EncryptionIO.kms_request¦   ss  € ð ×'Ñ'ˆØ×%Ñ%ˆØ×+Ñ+ˆØ×$Ñ$×(Ñ(¨Ó2ˆØŠ;ô "ØØØØØØØÜó	ˆCô œe×3Ò3Ô4HÓIÈ5ÓQˆÜØ+Ø*Øô
ˆô
 ˜X¤{Ó3ˆØ×$Ñ$ˆßÜ˜g›¨Õ,ˆIÜ�JŠJ�yÔ!ð0	)Ü Ó.ˆDð Ü˜Ô&Ø!×.Ñ.°Ô2à—O‘O¤C¬×(=Ò(=Ô>RÓ(SÐUVÓ$WÔXç“xØ#Ÿy™y¨×)AÑ)AÓB™õñ  3°4×9QÑ9QÓR˜ßÜ%Ð&=Ó>Ð>Ø×$Ñ$ TÖ*ð 3ð< —
‘
–øô #ô ØÜô ä˜cÔ#5×6Ò6Ü Ÿ.š.¨Ó5�Cä˜c¤7×+Ò+Ø!8‘Jà!%�JÜ)Ø¨ZÔI]Ð^bÓIc÷ò ûðûð —
‘
•ûÜô 	ØÜô 	)ÜŸšÓ)ˆIÜ˜#œ~×.Ò.°9Ò3HÈYÐZ[Ì^Øð)Ø× Ñ ×"Ò"øÜ"ô )Ü%Ø �kÐ!=¸c¸UÐCÀYÇ^Á^ó�ð ˜yÐ(ûð	)þð	)ús†   ÃI Ã%BF- Å<F- ÆH. ÆI Æ-H+ÇH+ÇAH&È!H. È&H+È+H. È.I É I ÉKÉKÉ7KÊJ'Ê'KÊ2KËKËKËKc               ó$   € V ^8„  d   QhRRRRRR/# )rH   ÚdatabaseÚstrÚfilterÚbytesrK   zOptional[list[bytes]]rL   )rM   s   "rN   rO   r_   ü   s'   € ÷ Qñ Q¨ð Q°Uð QÐ?Tñ QrP   c           
     óü   € V P                  4       V,          P                  \        V4      R7      ;_uu_ 4       pV Uu. uF  p\        VR\        4      NK  	  upuuRRR4       # u upi   + '       g   i     R# ; i)a@  Get the collection info for a namespace.

The returned collection info is passed to libmongocrypt which reads
the JSON schema.

:param database: The database on which to run listCollections.
:param filter: The filter to pass to listCollections.

:return: All documents from the listCollections command response as BSON.
)r    FN)ri   Úlist_collectionsr   r   rF   )ro   rž   r    ÚcursorÚdocs   &&&  rN   Úcollection_infoÚ_EncryptionIO.collection_infoü   sa   € ð �_‰_Ó˜xÕ(×9Ñ9ÄÐQWÓAXÐ9×YÔYÐ]cÙIOÓPÉÀ#”M # u¬nÖ=ÉÑP÷ ZÒYùÚP÷ Z×YÐYús   ¹A*¾A%ÁA*Á%A*Á*A;	c               ó   € V ^8„  d   QhRR/# ©rH   rK   rt   rL   )rM   s   "rN   rO   r_   
  s   € ÷ 	ñ 	�tñ 	rP   c                ó¶   € RV n         V P                  P                  ;'       g    R.pVP                  V P                  P                  4       \        V4       R# )zfSpawn mongocryptd.

Note this method is thread safe; at most one mongocryptd will start
successfully.
TÚmongocryptdN)rl   rJ   Ú_mongocryptd_spawn_pathÚextendÚ_mongocryptd_spawn_argsr"   )ro   Úargss   & rN   ÚspawnÚ_EncryptionIO.spawn
  sC   € ð ˆŒØ—	‘	×1Ñ1×BÐB°]ÐCˆØ�‰�D—I‘I×5Ñ5Ô6Ü�dÖrP   c               ó$   € V ^8„  d   QhRRRRRR/# )rH   rž   rŸ   Úcmdr¡   rK   úbytes | memoryviewrL   )rM   s   "rN   rO   r_     s"   € ÷ ñ  Sð ¨uð Ð9Kñ rP   c                ó
  € V P                   '       g-   V P                  P                  '       g   V P                  4        \	        V\
        4      pV P                  f   Q h V P                  V,          P                  V\
        R7      pVP                  #   \         dd    T P                  P                  '       d   h T P                  4        T P                  T,          P                  T\
        R7      p TP                  # i ; i)z¹Mark a command for encryption.

:param database: The database on which to run this command.
:param cmd: The BSON command to run.

:return: The marked command response from mongocryptd.
©rd   )
rl   rJ   Ú_mongocryptd_bypass_spawnr°   r   r   r^   Úcommandr,   Úraw)ro   rž   r³   Úinflated_cmdÚress   &&&  rN   Úmark_commandÚ_EncryptionIO.mark_command  sÚ   € ð �}�}ˆ} T§Y¡Y×%H×%HÐ%HØ�J‰JŒLô % SÔ*BÓCˆØ×&Ñ&Ò2Ð2Ð2ð
	Ø×)Ñ)¨(Õ3×;Ñ;ØÔ,Dð <ó ˆCð �w‰wˆøô +ô 	Ø�y‰y×2×2Ð2ØØ�J‰JŒLØ×)Ñ)¨(Õ3×;Ñ;ØÔ,Dð <ó ‰Cð �w‰wˆð	ús   Á (B Â&DÂ;9DÄDc               ó    € V ^8„  d   QhRRRR/# )rH   r    r¡   rK   z#Generator[bytes | memoryview, None]rL   )rM   s   "rN   rO   r_   0  s   € ÷ 
ñ 
 ð 
Ð+Nñ 
rP   c              #  óî   "  € V P                   f   Q hV P                   P                  \        V4      4      ;_uu_ 4       pV F  pVP                  x € K  	  RRR4       R#   + '       g   i     R# ; i5i)z¢Yields one or more keys from the key vault.

:param filter: The filter to pass to find.

:return: A generator which yields the requested keys from the key vault.
N)r]   Úfindr   r¹   )ro   r    r¤   Úkeys   &&  rN   Ú
fetch_keysÚ_EncryptionIO.fetch_keys0  sX   é € ð ×"Ñ"Ò.Ð.Ð.Ø× Ñ ×%Ñ%¤o°fÓ&=×>Ô>À&Û�Ø—g‘g”ñ ÷ ?×>×>Ò>üs   ‚=A5¿A!Á
A5Á!A2	Á,	A5c               ó    € V ^8„  d   QhRRRR/# )rH   Údata_keyr¡   rK   r   rL   )rM   s   "rN   rO   r_   <  s   € ÷ ñ ¨ð °&ñ rP   c                ó"  € \        V\        4      pVP                  R4      p\        V\        4      '       d   VP
                  \        8w  d   \        R\        V4       24      hV P                  f   Q hV P                  P                  V4       V# )zŽInsert a data key into the key vault.

:param data_key: The data key document to insert.

:return: The _id of the inserted data key document.
Ú_idz5data_key _id must be Binary with a UUID subtype, not )r   rk   r~   r�   r   Úsubtyper   Ú	TypeErrorÚtyper]   Ú
insert_one)ro   rÅ   Úraw_docÚdata_key_ids   &&  rN   Úinsert_data_keyÚ_EncryptionIO.insert_data_key<  sƒ   € ô " (¬OÓ<ˆØ—k‘k %Ó(ˆÜ˜+¤v×.Ò.°+×2EÑ2EÌÔ2UÜØGÌÈ[ÓHYÐGZÐ[óð ð ×"Ñ"Ò.Ð.Ð.Ø×Ñ×&Ñ& wÔ/ØÐrP   c               ó    € V ^8„  d   QhRRRR/# )rH   r¥   zMutableMapping[str, Any]rK   r¡   rL   )rM   s   "rN   rO   r_   N  s   € ÷ 	ñ 	Ð7ð 	¸Eñ 	rP   c                ó   € \        V4      # )z©Encode a document to BSON.

A document can be any mapping type (like :class:`dict`).

:param doc: mapping type representing a document

:return: The encoded BSON bytes.
)r   )ro   r¥   s   &&rN   Úbson_encodeÚ_EncryptionIO.bson_encodeN  s   € ô �c‹{ÐrP   c               ó   € V ^8„  d   QhRR/# r©   rL   )rM   s   "rN   rO   r_   Y  s   € ÷ 	+ñ 	+�tñ 	+rP   c                óŒ   € RV n         RV n        V P                  '       d$   V P                  P                  4        RV n        R# R# )zZRelease resources.

Note it is not safe to call this method from __del__ or any GC hooks.
N)ri   r]   r^   r�   ©ro   s   &rN   r�   Ú_EncryptionIO.closeY  s>   € ð
 ˆŒØ"ˆÔØ×"×"Ð"Ø×#Ñ#×)Ñ)Ô+Ø&*ˆDÖ#ñ #rP   )rm   rl   ri   r]   r^   rJ   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rp   r›   r¦   r°   r¼   rÂ   rÎ   rÒ   r�   Ú__static_attributes__rL   rP   rN   rZ   rZ   Š   s8   † õBõ6T)õlQõ	õõ6
õõ$	÷	+ñ 	+rP   rZ   c                  óL   € ] tR tRtRtRR R llt]R R l4       tR R	 ltR
t	R# )ÚRewrapManyDataKeyResultie  zmResult object returned by a :meth:`~ClientEncryption.rewrap_many_data_key` operation.

.. versionadded:: 4.2
Nc               ó    € V ^8„  d   QhRRRR/# )rH   Úbulk_write_resultúOptional[BulkWriteResult]rK   rt   rL   )rM   s   "rN   rO   Ú$RewrapManyDataKeyResult.__annotate__k  s   € ÷ 4ñ 4Ð*Cð 4Ètñ 4rP   c                	ó   € Wn         R # ©N©Ú_bulk_write_result)ro   rà   s   &&rN   rp   Ú RewrapManyDataKeyResult.__init__k  s   € Ø"3ÖrP   c               ó   € V ^8„  d   QhRR/# )rH   rK   rá   rL   )rM   s   "rN   rO   râ   o  s   € ÷ 'ñ 'Ð#<ñ 'rP   c                ó   € V P                   # )a  The result of the bulk write operation used to update the key vault
collection with one or more rewrapped data keys. If
:meth:`~ClientEncryption.rewrap_many_data_key` does not find any matching keys to rewrap,
no bulk write operation will be executed and this field will be
``None``.
rå   rÖ   s   &rN   rà   Ú)RewrapManyDataKeyResult.bulk_write_resultn  s   € ð ×&Ñ&Ð&rP   c               ó   € V ^8„  d   QhRR/# )rH   rK   rŸ   rL   )rM   s   "rN   rO   râ   x  s   € ÷ Iñ I˜#ñ IrP   c                	óP   € V P                   P                   R V P                  : R2# )Ú(Ú))Ú	__class__rØ   ræ   rÖ   s   &rN   Ú__repr__Ú RewrapManyDataKeyResult.__repr__x  s'   € Ø—.‘.×)Ñ)Ð*¨!¨D×,CÑ,CÑ+FÀaÐHÐHrP   rå   rä   )
rØ   rÙ   rÚ   rÛ   Ú__doc__rp   Úpropertyrà   rð   rÜ   rL   rP   rN   rÞ   rÞ   e  s,   † ñ÷
4ð ô'ó ð'÷Iñ IrP   rÞ   c                  óV   € ] tR tRtRtR R ltR R ltR R ltR	 R
 ltR R lt	Rt
R# )Ú
_Encrypteri|  z€Encrypts and decrypts MongoDB commands.

This class is used to support automatic encryption and decryption of
MongoDB commands.
c               ó    € V ^8„  d   QhRRRR/# )rH   r\   úMongoClient[_DocumentTypeArg]rJ   r#   rL   )rM   s   "rN   rO   Ú_Encrypter.__annotate__ƒ  s    € ÷ Eñ EÐ<ð EÐDVñ ErP   c                ó  € VP                   f   RpM\        VP                   R\        4      pVP                  f   RpM\        VP                  R\        4      pVP                  V n        RV n        VP                  \        4       R R lpVP                  e   VP                  pMV! W4      pVP                  '       d   RpMV! W4      pVP                  P                  R^4      w  r‰Wh,          V	,          p
\        VP                  R\        R7      p\        VV
VV4      p\        V\!        VP"                  VVP$                  VP&                  VP                  VVP(                  VP*                  R7      4      V n        RV n        R# )zŽCreate a _Encrypter for a client.

:param client: The encrypted MongoClient.
:param opts: The encrypted client's :class:`AutoEncryptionOpts`.
NFc               ó$   € V ^8„  d   QhRRRRRR/# )rH   Ú	encrypterrõ   Úmongo_clientr÷   rK   rL   )rM   s   "rN   rO   Ú)_Encrypter.__init__.<locals>.__annotate__—  s$   € ÷ 	#ñ 	#Ø!ð	#Ø1Nð	#à*ñ	#rP   c                ó´   € VP                   P                  P                  f   V# V P                  e   V P                  # VP	                  ^ R R7      pW n        V# )N)ÚminPoolSizeÚauto_encryption_opts)ÚoptionsÚpool_optionsÚmax_pool_sizeÚ_internal_clientÚ
_duplicate)rû   rü   Úinternal_clients   && rN   Ú_get_internal_clientÚ1_Encrypter.__init__.<locals>._get_internal_client—  s\   € ð ×#Ñ#×0Ñ0×>Ñ>ÒFà#Ð#à×)Ñ)Ò5Ø ×1Ñ1Ð1Ø*×5Ñ5À!ÐZ^Ð5Ó_ˆOØ)8Ô&Ø"Ð"rP   Ú.)ÚconnectÚserverSelectionTimeoutMS)Úkms_providersÚ
schema_mapÚcrypt_shared_lib_pathÚcrypt_shared_lib_requiredÚbypass_encryptionÚencrypted_fields_mapÚbypass_query_analysisÚkey_expiration_ms)Ú_schema_mapr   rF   Ú_encrypted_fields_mapÚ_bypass_auto_encryptionr  rm   rn   Ú_key_vault_clientÚ_key_vault_namespaceÚsplitr;   Ú_mongocryptd_uriÚ_MONGOCRYPTD_TIMEOUT_MSrZ   r   Ú_create_mongocrypt_optionsÚ_kms_providersÚ_crypt_shared_lib_pathÚ_crypt_shared_lib_requiredÚ_bypass_query_analysisÚ_key_expiration_msÚ_auto_encrypterÚ_closed)ro   r\   rJ   r  r  r  Úkey_vault_clientÚmetadata_clientÚdbÚcollr]   r^   Úio_callbackss   &&&          rN   rp   Ú_Encrypter.__init__ƒ  sq  € ð ×ÑÒ#Ø‰Jä& t×'7Ñ'7¸ÄÓOˆJà×%Ñ%Ò-Ø#'Ñ ä#0°×1KÑ1KÈUÔTbÓ#cÐ Ø'+×'CÑ'CˆÔ$Ø $ˆÔà×ÑœxÔ(õ	#ð ×!Ñ!Ò-Ø#×5Ñ5Ñá3°DÓAÐà×'×'Ð'Ø"‰Oá2°4Ó@ˆOà×,Ñ,×2Ñ2°3¸Ó:‰ˆØ)Õ-¨dÕ3ˆä=HØ×!Ñ!¨5ÔKbô>
Ðô %ØØØØó	
ˆô  -ØÜ&Ø"×1Ñ1Ø%Ø&*×&AÑ&AØ*.×*IÑ*IØ"&×">Ñ">Ø%9Ø&*×&AÑ&AØ"&×"9Ñ"9ô	ó 
ˆÔð ˆŽrP   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	rH   rž   rŸ   r³   úMapping[str, Any]rd   úCodecOptions[_DocumentTypeArg]rK   zdict[str, Any]rL   )rM   s   "rN   rO   rø   Ê  s2   € ÷ Jñ JØðJØ"3ðJØDbðJà	ñJrP   c                óô   € V P                  4        \        VRV4      p\        4       ;_uu_ 4        V P                  P	                  W4      p\        V\        4      uuRRR4       #   + '       g   i     R# ; i)zÜEncrypt a MongoDB command.

:param database: The database for this command.
:param cmd: A command document.
:param codec_options: The CodecOptions to use while encoding `cmd`.

:return: The encrypted command to execute.
FN)Ú_check_closedr   rX   r"  Úencryptr   r   )ro   rž   r³   rd   Úencoded_cmdÚencrypted_cmds   &&&&  rN   r/  Ú_Encrypter.encryptÊ  sW   € ð 	×ÑÔÜ# C¨°Ó>ˆÜ$×&Õ&Ø ×0Ñ0×8Ñ8¸ÓOˆMä  Ô0HÓI÷ '×&×&Ó&ús   °+A&Á&A7	c               ó    € V ^8„  d   QhRRRR/# )rH   Úresponser´   rK   úOptional[bytes]rL   )rM   s   "rN   rO   rø   Ü  s   € ÷ 	Gñ 	GÐ 2ð 	G°ñ 	GrP   c                óÖ   € V P                  4        \        4       ;_uu_ 4        \        \        V P                  P                  V4      4      uuRRR4       #   + '       g   i     R# ; i)z„Decrypt a MongoDB command response.

:param response: A MongoDB command response as BSON.

:return: The decrypted command response.
N)r.  rX   r   r¡   r"  Údecrypt)ro   r4  s   &&rN   r7  Ú_Encrypter.decryptÜ  sC   € ð 	×ÑÔÜ$×&Õ&Üœ˜t×3Ñ3×;Ñ;¸HÓEÓF÷ '×&×&Ó&ús   £)AÁA(	c               ó   € V ^8„  d   QhRR/# r©   rL   )rM   s   "rN   rO   rø   ç  ó   € ÷ Iñ I˜tñ IrP   c                	ó@   € V P                   '       d   \        R 4      hR# )z"Cannot use MongoClient after closeN)r#  r*   rÖ   s   &rN   r.  Ú_Encrypter._check_closedç  s   € Ø�<�<ˆ<Ü"Ð#GÓHÐHñ rP   c               ó   € V ^8„  d   QhRR/# r©   rL   )rM   s   "rN   rO   rø   ë  s   € ÷ )ñ )�tñ )rP   c                ó²   € RV n         V P                  P                  4        V P                  '       d$   V P                  P                  4        RV n        R# R# )zCleanup resources.TN)r#  r"  r�   r  rÖ   s   &rN   r�   Ú_Encrypter.closeë  sF   € àˆŒØ×Ñ×"Ñ"Ô$Ø× × Ð Ø×!Ñ!×'Ñ'Ô)Ø$(ˆDÖ!ñ !rP   )r"  r  r#  r  N)rØ   rÙ   rÚ   rÛ   rò   rp   r/  r7  r.  r�   rÜ   rL   rP   rN   rõ   rõ   |  s*   † ñõEõNJõ$	GõI÷)ñ )rP   rõ   c                  óB   € ] tR tRtRtRt Rt Rt Rt Rt	 Rt
 R	tR
tR# )Ú	Algorithmiô  z9An enum that defines the supported encryption algorithms.z+AEAD_AES_256_CBC_HMAC_SHA_512-Deterministicz$AEAD_AES_256_CBC_HMAC_SHA_512-RandomÚIndexedÚ	UnindexedÚRangeÚRangePreviewÚTextPreviewrL   N)rØ   rÙ   rÚ   rÛ   rò   Ú+AEAD_AES_256_CBC_HMAC_SHA_512_DeterministicÚ$AEAD_AES_256_CBC_HMAC_SHA_512_RandomÚINDEXEDÚ	UNINDEXEDÚRANGEÚRANGEPREVIEWÚTEXTPREVIEWrÜ   rL   rP   rN   rA  rA  ô  sQ   † ÙCà2_Ð/Ø6Ø+QÐ(Ø/Ø€Gðð €Iðð €Eðð "€Lðð  €KórP   rA  c                  ó<   € ] tR tRtRtRt Rt Rt Rt Rt	 Rt
R	tR
# )Ú	QueryTypei  zeAn enum that defines the supported values for explicit encryption query_type.

.. versionadded:: 4.2
ÚequalityÚrangerE  ÚprefixPreviewÚsuffixPreviewÚsubstringPreviewrL   N)rØ   rÙ   rÚ   rÛ   rò   ÚEQUALITYrK  rL  ÚPREFIXPREVIEWÚSUFFIXPREVIEWÚSUBSTRINGPREVIEWrÜ   rL   rP   rN   rO  rO    sL   † ñð
 €HØ8à€Eðð
 "€Lðð $€Mðð
 $€Mðð
 *ÐórP   rO  c               ó    € V ^8„  d   QhRRRR/# )rH   Úkwargsr   rK   r   rL   )rM   s   "rN   rO   rO   B  s   € ÷ Fñ F¨ð FÐ1Bñ FrP   c                 ój   € V P                  R 4      f   V P                  R R4       \        R/ V BRR/B # )r  NÚenable_multiple_collinfoTrL   )r~   Úpopr   )rZ  s   ,rN   r  r  B  s4   € à‡z�zÐ%Ó&Ò.Ø�
‰
Ð&¨Ô-ÜÑE˜vÑEÀÒEÐErP   c                  ó  € ] tR tRtRtR)R R lltR)R R lltR*R R	 lltR+R
 R lltR,R R llt	R-R R llt
R R ltR R ltR R ltR R l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tR& R' ltR(tR# ).ÚClientEncryptioniI  z,Explicit client-side field level encryption.Nc               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )rH   r  r+  Úkey_vault_namespacerŸ   r$  r÷   rd   r,  Úkms_tls_optionsúOptional[Mapping[str, Any]]r  úOptional[int]rK   rt   rL   )rM   s   "rN   rO   ÚClientEncryption.__annotate__L  sb   € ÷ EAñ EAà(ðEAð !ðEAð 8ð	EAð
 6ðEAð 5ðEAð )ðEAð 
ñEArP   c           
     ó‚  € \         '       g   \        R4      h\        4        \        V\        4      '       g   \        R\        V4       24      h\        V\        4      '       g‚   \        ;QJ d/    R \        V4      P                   4       F  '       g   K   RM$	  RM ! R \        V4      P                   4       4      '       g"   \        R\        V4      P                   24      hWn        W n        W0n        W@n        VP                  R^4      w  rxW7,          V,          p	\!        VVVVR7      p
\#        V
P$                  \&        4      V n        \+        R	V	R	V
4      V n        \/        V P,                  \1        VR	VRR
7      4      V n        V P,                  P4                  f   Q hV P,                  P4                  V n        R	# )a  Explicit client-side field level encryption.

The ClientEncryption class encapsulates explicit operations on a key
vault collection that cannot be done directly on a MongoClient. Similar
to configuring auto encryption on a MongoClient, it is constructed with
a MongoClient (to a MongoDB cluster containing the key vault
collection), KMS provider configuration, and keyVaultNamespace. It
provides an API for explicitly encrypting and decrypting values, and
creating data keys. It does not provide an API to query keys from the
key vault collection, as this can be done directly on the MongoClient.

See `explicit client-side encryption <https://www.mongodb.com/docs/manual/core/csfle/fundamentals/manual-encryption/#csfle-explicit-encryption>`_ for an example.

:param kms_providers: Map of KMS provider options. The `kms_providers`
    map values differ by provider:

      - `aws`: Map with "accessKeyId" and "secretAccessKey" as strings.
        These are the AWS access key ID and AWS secret access key used
        to generate KMS messages. An optional "sessionToken" may be
        included to support temporary AWS credentials.
      - `azure`: Map with "tenantId", "clientId", and "clientSecret" as
        strings. Additionally, "identityPlatformEndpoint" may also be
        specified as a string (defaults to 'login.microsoftonline.com').
        These are the Azure Active Directory credentials used to
        generate Azure Key Vault messages.
      - `gcp`: Map with "email" as a string and "privateKey"
        as `bytes` or a base64 encoded string.
        Additionally, "endpoint" may also be specified as a string
        (defaults to 'oauth2.googleapis.com'). These are the
        credentials used to generate Google Cloud KMS messages.
      - `kmip`: Map with "endpoint" as a host with required port.
        For example: ``{"endpoint": "example.com:443"}``.
      - `local`: Map with "key" as `bytes` (96 bytes in length) or
        a base64 encoded string which decodes
        to 96 bytes. "key" is the master key used to encrypt/decrypt
        data keys. This key should be generated and stored as securely
        as possible.

    KMS providers may be specified with an optional name suffix
    separated by a colon, for example "kmip:name" or "aws:name".
    Named KMS providers do not support `CSFLE on-demand credentials <https://www.mongodb.com/docs/manual/core/csfle/tutorials/aws/aws-automatic/?interface=driver&language=python#use-automatic-client-side-field-level-encryption-with-aws>`_.
:param key_vault_namespace: The namespace for the key vault collection.
    The key vault collection contains all data keys used for encryption
    and decryption. Data keys are stored as documents in this MongoDB
    collection. Data keys are protected with encryption by a KMS
    provider.
:param key_vault_client: A MongoClient connected to a MongoDB cluster
    containing the `key_vault_namespace` collection.
:param codec_options: An instance of
    :class:`~bson.codec_options.CodecOptions` to use when encoding a
    value for encryption and decoding the decrypted BSON value. This
    should be the same CodecOptions instance configured on the
    MongoClient, Database, or Collection used to access application
    data.
:param kms_tls_options: A map of KMS provider names to TLS
    options to use when creating secure connections to KMS providers.
    Accepts the same TLS options as
    :class:`pymongo.mongo_client.MongoClient`. For example, to
    override the system default CA file::

      kms_tls_options={'kmip': {'tlsCAFile': certifi.where()}}

    Or to supply a client certificate::

      kms_tls_options={'kmip': {'tlsCertificateKeyFile': 'client.pem'}}
:param key_expiration_ms: The cache expiration time for data encryption keys.
    Defaults to ``None`` which defers to libmongocrypt's default which is currently 60000.
    Set to 0 to disable key expiration.

.. versionchanged:: 4.12
   Added the `key_expiration_ms` parameter.
.. versionchanged:: 4.0
   Added the `kms_tls_options` parameter and the "kmip" KMS provider.

.. versionadded:: 3.9
zžclient-side field level encryption requires the pymongocrypt library: install a compatible version with: python -m pip install --upgrade 'pymongo[encryption]'zJcodec_options must be an instance of bson.codec_options.CodecOptions, not c              3  ó>   "  € T F  qP                   R 8H  x € K  	  R# 5i)r;   N©rØ   ©Ú.0Úclss   & rN   Ú	<genexpr>Ú,ClientEncryption.__init__.<locals>.<genexpr>±  s   é € Ð_Ñ@^¸—|‘| }Ö4Ó@^ùó   ‚TFzMongoClient required but given r	  )rb  r  N)r  r  r  r  )Ú_HAVE_PYMONGOCRYPTr'   r&   r�   r   rÉ   rÊ   r;   ÚanyÚ__mro__rØ   r  r  r  Ú_codec_optionsr  r#   r>   Ú_kms_tls_optionsrn   rm   rZ   Ú_io_callbacksr   r  Ú_encryptionr]   Ú_key_vault_coll)ro   r  ra  r$  rd   rb  r  r&  r'  r]   rJ   s   &&&&&&&    rN   rp   ÚClientEncryption.__init__L  s‘  € ÷j "Ó!Ü$ðHóð ô 	Ô ä˜-¬×6Ò6ÜØ\Ô]aÐboÓ]pÐ\qÐróð ô Ð*¬K×8Ò8ç“3Ñ_ÄÐEUÓ@V×@^Ò@^Ó_—3—3’3Ñ_ÄÐEUÓ@V×@^Ò@^Ó_×_Ò_ÜÐ"AÄ$ÐGWÓBX×BaÑBaÐAbÐ cÓdÐdà+ÔØ$7Ô!Ø!1ÔØ+Ôà&×,Ñ,¨S°!Ó4‰ˆØ)Õ-¨dÕ3ˆä!ØØØ+Ø/ô	
ˆô "8¸×8MÑ8MÌxÓ!XˆÔÜ6CØ�. $¨ó7
ˆÔô -Ø×ÑÜ&Ø+ØØ"3Ø"&ô	ó
ˆÔð ×!Ñ!×0Ñ0Ò<Ð<Ð<Ø#×1Ñ1×@Ñ@ˆÖrP   c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )rH   rž   zDatabase[_DocumentTypeArg]ÚnamerŸ   Úencrypted_fieldsr+  r}   úOptional[str]Ú
master_keyrc  rZ  r   rK   z6tuple[Collection[_DocumentTypeArg], Mapping[str, Any]]rL   )rM   s   "rN   rO   re  Ó  sc   € ÷ WKñ WKà,ðWKð ðWKð ,ð	WKð
 $ðWKð 0ðWKð ðWKð 
@ñWKrP   c                óÜ  € \        V\        4      '       g‚   \        ;QJ d/    R \        V4      P                   4       F  '       g   K   RM$	  RM ! R \        V4      P                   4       4      '       g"   \        R\        V4      P                   24      h\        V4      p\        VR,          4       FW  w  rx\        V\        4      '       g   K  VP                  R4      e   K2   V P                  VVR7      VR,          V,          R&   KY  	  W6R	&   RVR
&    VP                  ! RRV/VB V3#   \         d   p	\        Y“4      T	hRp	?	ii ; i  \         d   p	\        Y“4      T	hRp	?	ii ; i)a\  Create a collection with encryptedFields.

.. warning::
    This function does not update the encryptedFieldsMap in the client's
    AutoEncryptionOpts, thus the user must create a new client after calling this function with
    the encryptedFields returned.

Normally collection creation is automatic. This method should
only be used to specify options on
creation. :class:`~pymongo.errors.EncryptionError` will be
raised if the collection already exists.

:param database: the database to create the collection
:param name: the name of the collection to create
:param encrypted_fields: Document that describes the encrypted fields for
    Queryable Encryption. The "keyId" may be set to ``None`` to auto-generate the data keys.  For example:

    .. code-block: python

      {
        "escCollection": "enxcol_.encryptedCollection.esc",
        "ecocCollection": "enxcol_.encryptedCollection.ecoc",
        "fields": [
            {
                "path": "firstName",
                "keyId": Binary.from_uuid(UUID('00000000-0000-0000-0000-000000000000')),
                "bsonType": "string",
                "queries": {"queryType": "equality"}
            },
            {
                "path": "ssn",
                "keyId": Binary.from_uuid(UUID('04104104-1041-0410-4104-104104104104')),
                "bsonType": "string"
            }
          ]
      }

  :param kms_provider: the KMS provider to be used
  :param master_key: Identifies a KMS-specific key used to encrypt the
    new data key. If the kmsProvider is "local" the `master_key` is
    not applicable and may be omitted.
  :param kwargs: additional keyword arguments are the same as "create_collection".

All optional `create collection command`_ parameters should be passed
as keyword arguments to this method.
See the documentation for :meth:`~pymongo.database.Database.create_collection` for all valid options.

:raises: - :class:`~pymongo.errors.EncryptedCollectionError`: When either data-key creation or creating the collection fails.

.. versionadded:: 4.4

.. _create collection command:
    https://mongodb.com/docs/manual/reference/command/create

c              3  ó>   "  € T F  qP                   R 8H  x € K  	  R# 5i)r:   Nrh  ri  s   & rN   rl  Ú?ClientEncryption.create_encrypted_collection.<locals>.<genexpr>  s   é € ÐTÑ=S°c—|‘| zÖ1Ó=Sùrn  TFzDatabase required but given ÚfieldsÚkeyIdN)r}   r|  ÚencryptedFieldsÚcheck_existsry  rL   )r�   r:   rp  rÊ   rq  rÉ   rØ   r   Ú	enumerateÚdictr~   Úcreate_data_keyr)   r(   Úcreate_collectionrS   )
ro   rž   ry  rz  r}   r|  rZ  ÚiÚfieldrT   s
   &&&&&&,   rN   Úcreate_encrypted_collectionÚ,ClientEncryption.create_encrypted_collectionÓ  sT  € ô@ ˜(¤H×-Ò-ç“3ÑT¼TÀ(»^×=SÒ=SÓT—3—3’3ÑT¼TÀ(»^×=SÒ=SÓT×TÒTÜÐ">¼tÀH»~×?VÑ?VÐ>WÐ XÓYÐYä#Ð$4Ó5ÐÜ!Ð"2°8Õ"<Ö=‰HˆAÜ˜%¤×&Ô&¨5¯9©9°WÓ+=Ô+EðSØ=A×=QÑ=QØ%1Ø#-ð >Ró >Ð$ XÕ.¨qÕ1°'Ó:ñ >ð %5Ð Ñ!Ø!&ˆˆ~Ñð	Kà×*Ò*Ñ?°Ð?¸Ñ?Ø ðð øô 'ô SÜ2°3ÓIÈsÐRûðSûô ô 	KÜ*¨3ÓAÀsÐJûð	Kús0   Ã($D0ÄE Ä0EÄ;EÅEÅE+ÅE&Å&E+c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )rH   r}   rŸ   r|  rc  Úkey_alt_nameszOptional[Sequence[str]]Úkey_materialr5  rK   r   rL   )rM   s   "rN   rO   re  ,  sC   € ÷ Yñ YàðYð 0ðYð /ð	Yð
 &ðYð 
ñYrP   c                óÞ   € V P                  4        \        4       ;_uu_ 4        \        \        V P                  P                  VVVVR7      4      uuRRR4       #   + '       g   i     R# ; i)aÆ  Create and insert a new data key into the key vault collection.

:param kms_provider: The KMS provider to use. Supported values are
    "aws", "azure", "gcp", "kmip", "local", or a named provider like
    "kmip:name".
:param master_key: Identifies a KMS-specific key used to encrypt the
    new data key. If the kmsProvider is "local" the `master_key` is
    not applicable and may be omitted.

    If the `kms_provider` type is "aws" it is required and has the
    following fields::

      - `region` (string): Required. The AWS region, e.g. "us-east-1".
      - `key` (string): Required. The Amazon Resource Name (ARN) to
         the AWS customer.
      - `endpoint` (string): Optional. An alternate host to send KMS
        requests to. May include port number, e.g.
        "kms.us-east-1.amazonaws.com:443".

    If the `kms_provider` type is "azure" it is required and has the
    following fields::

      - `keyVaultEndpoint` (string): Required. Host with optional
         port, e.g. "example.vault.azure.net".
      - `keyName` (string): Required. Key name in the key vault.
      - `keyVersion` (string): Optional. Version of the key to use.

    If the `kms_provider` type is "gcp" it is required and has the
    following fields::

      - `projectId` (string): Required. The Google cloud project ID.
      - `location` (string): Required. The GCP location, e.g. "us-east1".
      - `keyRing` (string): Required. Name of the key ring that contains
        the key to use.
      - `keyName` (string): Required. Name of the key to use.
      - `keyVersion` (string): Optional. Version of the key to use.
      - `endpoint` (string): Optional. Host with optional port.
        Defaults to "cloudkms.googleapis.com".

    If the `kms_provider` type is "kmip" it is optional and has the
    following fields::

      - `keyId` (string): Optional. `keyId` is the KMIP Unique
        Identifier to a 96 byte KMIP Secret Data managed object. If
        keyId is omitted, the driver creates a random 96 byte KMIP
        Secret Data managed object.
      - `endpoint` (string): Optional. Host with optional
         port, e.g. "example.vault.azure.net:".
      - `delegated` (bool): Optional. If True (recommended), the
        KMIP server will perform encryption and decryption. If
        delegated is not provided, defaults to false.

:param key_alt_names: An optional list of string alternate
    names used to reference a key. If a key is created with alternate
    names, then encryption may refer to the key by the unique alternate
    name instead of by ``key_id``. The following example shows creating
    and referring to a data key by alternate name::

      client_encryption.create_data_key("local", key_alt_names=["name1"])
      # reference the key with the alternate name
      client_encryption.encrypt("457-55-5462", key_alt_name="name1",
                                algorithm=Algorithm.AEAD_AES_256_CBC_HMAC_SHA_512_Random)
:param key_material: Sets the custom key material to be used
    by the data key for encryption and decryption.

:return: The ``_id`` of the created data key document as a
  :class:`~bson.binary.Binary` with subtype
  :data:`~bson.binary.UUID_SUBTYPE`.

.. versionchanged:: 4.2
   Added the `key_material` parameter.
)r|  r�  rŽ  N)r.  rX   r   r   ru  r†  )ro   r}   r|  r�  rŽ  s   &&&&&rN   r†  Ú ClientEncryption.create_data_key,  sY   € ð^ 	×ÑÔÜ$×&Õ&ÜÜØ× Ñ ×0Ñ0Ø Ø)Ø"/Ø!-ð	 1ó ó÷ '×&×&Ó&ús   £-AÁA,	c               ó@   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRR/
# )rH   Úvaluer   Ú	algorithmrŸ   Úkey_idú"Optional[Union[Binary, uuid.UUID]]Úkey_alt_namer{  Ú
query_typeÚcontention_factorrd  Ú
range_optsúOptional[RangeOpts]Úis_expressionÚboolÚ	text_optsúOptional[TextOpts]rK   rL   )rM   s   "rN   rO   re  ‡  sn   € ÷ 1.ñ 1.àð1.ð ð1.ð 3ð	1.ð
 $ð1.ð "ð1.ð )ð1.ð (ð1.ð ð1.ð &ð1.ð 
ñ1.rP   c
                	óÖ  € V P                  4        \        V\        P                  4      '       d   \        P
                  ! V4      pVe7   \        V\        4      '       d   VP                  \        8X  g   \        R4      h\        RV/V P                  R7      p
R pV'       d"   \        VP                  V P                  R7      pR pV	'       d"   \        V	P                  V P                  R7      p\        4       ;_uu_ 4        V P                  P                  ! RRV
RVRVRVRVR	VR
VRV/V'       d   RV/M/ B p\        V4      R,          uuR R R 4       #   + '       g   i     R # ; i)Nz2key_id must be a bson.binary.Binary with subtype 4Úvr¶   r’  r“  r”  r–  r—  r˜  r™  r›  r�  rL   )r.  r�   ÚuuidÚUUIDr   Ú	from_uuidrÈ   r   rÉ   r   rr  ÚdocumentrX   ru  r/  r   )ro   r’  r“  r”  r–  r—  r˜  r™  r›  r�  r¥   Úrange_opts_bytesÚtext_opts_bytesÚencrypted_docs   &&&&&&&&&&    rN   Ú_encrypt_helperÚ ClientEncryption._encrypt_helper‡  sb  € ð 	×ÑÔÜ�fœdŸi™i×(Ò(Ü×%Ò% fÓ-ˆFØÒÜ�vœv×&Ò&¨6¯>©>¼\Ô+IäÐPÓQÐQäØ�%ˆLØ×-Ñ-ô
ˆð  ÐßÜ%Ø×#Ñ#Ø"×1Ñ1ô Ðð ˆßÜ$Ø×"Ñ"Ø"×1Ñ1ôˆOô %×&Õ&Ø ×,Ñ,×4Ò4ñ Øðà#ðð ðð *ð	ð
 &ðð #4ðð ,ðð ,ð÷ 5D�; Ñ0ÈñˆMô ˜-Ó(¨Õ-÷ '×&×&Ó&ús   ÄA
EÅE(	c               ó<   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRR/	# )rH   r’  r   r“  rŸ   r”  r•  r–  r{  r—  r˜  rd  r™  rš  r�  rž  rK   r   rL   )rM   s   "rN   rO   re  º  sd   € ÷ <
ñ <
àð<
ð ð<
ð 3ð	<
ð
 $ð<
ð "ð<
ð )ð<
ð (ð<
ð &ð<
ð 
ñ<
rP   c	                óR   € \        \        V P                  VVVVVVVRVR7	      4      # )ax  Encrypt a BSON value with a given key and algorithm.

Note that exactly one of ``key_id`` or  ``key_alt_name`` must be
provided.

:param value: The BSON value to encrypt.
:param algorithm` (string): The encryption algorithm to use. See
    :class:`Algorithm` for some valid options.
:param key_id: Identifies a data key by ``_id`` which must be a
    :class:`~bson.binary.Binary` with subtype 4 (
    :attr:`~bson.binary.UUID_SUBTYPE`).
:param key_alt_name: Identifies a key vault document by 'keyAltName'.
:param query_type` (str): The query type to execute. See :class:`QueryType` for valid options.
:param contention_factor` (int): The contention factor to use
    when the algorithm is :attr:`Algorithm.INDEXED`.  An integer value
    *must* be given when the :attr:`Algorithm.INDEXED` algorithm is
    used.
:param range_opts: Index options for `range` queries. See
    :class:`RangeOpts` for some valid options.
:param text_opts: Index options for `textPreview` queries. See
    :class:`TextOpts` for some valid options.

:return: The encrypted value, a :class:`~bson.binary.Binary` with subtype 6.

.. versionchanged:: 4.9
   Added the `text_opts` parameter.

.. versionchanged:: 4.9
   Added the `range_opts` parameter.

.. versionchanged:: 4.7
   ``key_id`` can now be passed in as a :class:`uuid.UUID`.

.. versionchanged:: 4.2
   Added the `query_type` and `contention_factor` parameters.
F)	r’  r“  r”  r–  r—  r˜  r™  r›  r�  )r   r   r¨  )	ro   r’  r“  r”  r–  r—  r˜  r™  r�  s	   &&&&&&&&&rN   r/  ÚClientEncryption.encryptº  sC   € ô^ ÜØ× Ñ ØØ#ØØ)Ø%Ø"3Ø%Ø#Ø#ð !ó 
ó
ð 	
rP   c               ó8   € V ^8„  d   QhRRRRRRRRR	RR
RRRRR/# )rH   Ú
expressionr+  r“  rŸ   r”  r•  r–  r{  r—  r˜  rd  r™  rš  rK   r   rL   )rM   s   "rN   rO   re  ø  sZ   € ÷ 5
ñ 5
à%ð5
ð ð5
ð 3ð	5
ð
 $ð5
ð "ð5
ð )ð5
ð (ð5
ð 
ñ5
rP   c                óP   € \        \        V P                  VVVVVVVRR7      4      # )a¬  Encrypt a BSON expression with a given key and algorithm.

Note that exactly one of ``key_id`` or  ``key_alt_name`` must be
provided.

:param expression: The BSON aggregate or match expression to encrypt.
:param algorithm` (string): The encryption algorithm to use. See
    :class:`Algorithm` for some valid options.
:param key_id: Identifies a data key by ``_id`` which must be a
    :class:`~bson.binary.Binary` with subtype 4 (
    :attr:`~bson.binary.UUID_SUBTYPE`).
:param key_alt_name: Identifies a key vault document by 'keyAltName'.
:param query_type` (str): The query type to execute. See
    :class:`QueryType` for valid options.
:param contention_factor` (int): The contention factor to use
    when the algorithm is :attr:`Algorithm.INDEXED`.  An integer value
    *must* be given when the :attr:`Algorithm.INDEXED` algorithm is
    used.
:param range_opts: Index options for `range` queries. See
    :class:`RangeOpts` for some valid options.

:return: The encrypted expression, a :class:`~bson.RawBSONDocument`.

.. versionchanged:: 4.9
   Added the `range_opts` parameter.

.. versionchanged:: 4.7
   ``key_id`` can now be passed in as a :class:`uuid.UUID`.

.. versionadded:: 4.4
T)r’  r“  r”  r–  r—  r˜  r™  r›  )r   r   r¨  )ro   r®  r“  r”  r–  r—  r˜  r™  s   &&&&&&&&rN   Úencrypt_expressionÚ#ClientEncryption.encrypt_expressionø  s@   € ôR ÜØ× Ñ Ø Ø#ØØ)Ø%Ø"3Ø%Ø"ð !ó 	ó
ð 	
rP   c               ó    € V ^8„  d   QhRRRR/# )rH   r’  r   rK   r   rL   )rM   s   "rN   rO   re  /  s   € ÷ Qñ Q˜Vð Q¨ñ QrP   c                ór  € V P                  4        \        V\        4      '       d   VP                  ^8X  g   \	        R4      h\        4       ;_uu_ 4        \        RV/4      pV P                  P                  V4      p\        W0P                  R7      R,          uuRRR4       #   + '       g   i     R# ; i)z¡Decrypt an encrypted value.

:param value` (Binary): The encrypted value, a
    :class:`~bson.binary.Binary` with subtype 6.

:return: The decrypted BSON value.
z<value to decrypt must be a bson.binary.Binary with subtype 6r   r¶   N)r.  r�   r   rÈ   rÉ   rX   r   ru  r7  r   rr  )ro   r’  r¥   Údecrypted_docs   &&  rN   r7  ÚClientEncryption.decrypt/  sƒ   € ð 	×ÑÔÜ˜5¤&×)Ò)¨e¯m©m¸qÔ.@ÜÐZÓ[Ð[ä$×&Õ&Ü˜#˜u˜Ó&ˆCØ ×,Ñ,×4Ñ4°SÓ9ˆMÜ˜-×7JÑ7JÔKÈCÕP÷ '×&×&Ó&ús   ÁAB%Â%B6	c               ó    € V ^8„  d   QhRRRR/# )rH   Úidr   rK   úOptional[RawBSONDocument]rL   )rM   s   "rN   rO   re  @  s   € ÷ :ñ :˜&ð :Ð%>ñ :rP   c                ó|   € V P                  4        V P                  f   Q hV P                  P                  RV/4      # )zÝGet a data key by id.

:param id` (Binary): The UUID of a key a which must be a
    :class:`~bson.binary.Binary` with subtype 4 (
    :attr:`~bson.binary.UUID_SUBTYPE`).

:return: The key document.

.. versionadded:: 4.2
rÇ   ©r.  rv  Úfind_one©ro   r·  s   &&rN   Úget_keyÚClientEncryption.get_key@  s=   € ð 	×ÑÔØ×#Ñ#Ò/Ð/Ð/Ø×#Ñ#×,Ñ,¨e°R¨[Ó9Ð9rP   c               ó   € V ^8„  d   QhRR/# )rH   rK   zCursor[RawBSONDocument]rL   )rM   s   "rN   rO   re  O  s   € ÷ 
-ñ 
-Ð1ñ 
-rP   c                óx   € V P                  4        V P                  f   Q hV P                  P                  / 4      # )z‰Get all of the data keys.

:return: An instance of :class:`~pymongo.cursor.Cursor` over the data key
  documents.

.. versionadded:: 4.2
)r.  rv  rÀ   rÖ   s   &rN   Úget_keysÚClientEncryption.get_keysO  s9   € ð 	×ÑÔØ×#Ñ#Ò/Ð/Ð/Ø×#Ñ#×(Ñ(¨Ó,Ð,rP   c               ó    € V ^8„  d   QhRRRR/# )rH   r·  r   rK   r5   rL   )rM   s   "rN   rO   re  [  s   € ÷ <ñ <˜Vð <¨ñ <rP   c                ó|   € V P                  4        V P                  f   Q hV P                  P                  RV/4      # )a  Delete a key document in the key vault collection that has the given ``key_id``.

:param id` (Binary): The UUID of a key a which must be a
    :class:`~bson.binary.Binary` with subtype 4 (
    :attr:`~bson.binary.UUID_SUBTYPE`).

:return: The delete result.

.. versionadded:: 4.2
rÇ   )r.  rv  Ú
delete_oner¼  s   &&rN   Ú
delete_keyÚClientEncryption.delete_key[  s=   € ð 	×ÑÔØ×#Ñ#Ò/Ð/Ð/Ø×#Ñ#×.Ñ.°°r¨{Ó;Ð;rP   c               ó$   € V ^8„  d   QhRRRRRR/# )rH   r·  r   r–  rŸ   rK   r   rL   )rM   s   "rN   rO   re  j  s&   € ÷ Mñ M 6ð M¸ð MÀñ MrP   c                óŠ   € V P                  4        RRV//pV P                  f   Q hV P                  P                  RV/V4      # )af  Add ``key_alt_name`` to the set of alternate names in the key document with UUID ``key_id``.

:param id: The UUID of a key a which must be a
    :class:`~bson.binary.Binary` with subtype 4 (
    :attr:`~bson.binary.UUID_SUBTYPE`).
:param key_alt_name: The key alternate name to add.

:return: The previous version of the key document.

.. versionadded:: 4.2
z	$addToSetÚkeyAltNamesrÇ   ©r.  rv  Úfind_one_and_update)ro   r·  r–  Úupdates   &&& rN   Úadd_key_alt_nameÚ!ClientEncryption.add_key_alt_namej  sN   € ð 	×ÑÔØ ¨|Ð<Ð=ˆØ×#Ñ#Ò/Ð/Ð/Ø×#Ñ#×7Ñ7¸À¸ÀVÓLÐLrP   c               ó    € V ^8„  d   QhRRRR/# )rH   r–  rŸ   rK   r¸  rL   )rM   s   "rN   rO   re  {  s   € ÷ Lñ L°ð LÐ8Qñ LrP   c                ó|   € V P                  4        V P                  f   Q hV P                  P                  RV/4      # )zÎGet a key document in the key vault collection that has the given ``key_alt_name``.

:param key_alt_name: (str): The key alternate name of the key to get.

:return: The key document.

.. versionadded:: 4.2
rÊ  rº  )ro   r–  s   &&rN   Úget_key_by_alt_nameÚ$ClientEncryption.get_key_by_alt_name{  s>   € ð 	×ÑÔØ×#Ñ#Ò/Ð/Ð/Ø×#Ñ#×,Ñ,¨m¸\Ð-JÓKÐKrP   c               ó$   € V ^8„  d   QhRRRRRR/# )rH   r·  r   r–  rŸ   rK   r¸  rL   )rM   s   "rN   rO   re  ˆ  s'   € ÷ "Oñ "O fð "O¸Cð "OÐD]ñ "OrP   c                ó´   € V P                  4        RRRRRV../RRRRR	R
RV.///.///.pV P                  f   Q hV P                  P                  RV/V4      # )aÌ  Remove ``key_alt_name`` from the set of keyAltNames in the key document with UUID ``id``.

Also removes the ``keyAltNames`` field from the key document if it would otherwise be empty.

:param id: The UUID of a key a which must be a
    :class:`~bson.binary.Binary` with subtype 4 (
    :attr:`~bson.binary.UUID_SUBTYPE`).
:param key_alt_name: The key alternate name to remove.

:return: Returns the previous version of the key document.

.. versionadded:: 4.2
ú$setrÊ  z$condz$eqz$keyAltNamesz$$REMOVEz$filterÚinputÚcondz$nez$$thisrÇ   rË  )ro   r·  r–  Úpipelines   &&& rN   Úremove_key_alt_nameÚ$ClientEncryption.remove_key_alt_nameˆ  sš   € ð 	×ÑÔð Ø!ØØ" ^°l°^Ð$DÐEØ&à )Ø$+¨^Ø$*¨U°X¸|Ð4LÐ,Mð,"ðð	"ð$ððð
ˆð$ ×#Ñ#Ò/Ð/Ð/Ø×#Ñ#×7Ñ7¸À¸ÀXÓNÐNrP   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	rH   r    r+  r”   r{  r|  rc  rK   rÞ   rL   )rM   s   "rN   rO   re  ¬  s2   € ÷ 8/ñ 8/à!ð8/ð  ð8/ð 0ð	8/ð
 
!ñ8/rP   c                ób  € Ve   Vf   \        R4      hV P                  4        \        4       ;_uu_ 4        V P                  P	                  WV4      pVf   \        4       uuRRR4       #  RRR4       \        X\        4      p. pVR,           FC  pRRVR,          RVR,          /RRR	//p\        R
VR
,          /V4      p	VP                  V	4       KE  	  V'       g   \        4       # V P                  f   Q hV P                  P                  V4      p
\        V
4      #   + '       g   i     Lº; i)ag  Decrypts and encrypts all matching data keys in the key vault with a possibly new `master_key` value.

:param filter: A document used to filter the data keys.
:param provider: The new KMS provider to use to encrypt the data keys,
    or ``None`` to use the current KMS provider(s).
:param master_key: The master key fields corresponding to the new KMS
    provider when ``provider`` is not ``None``.

:return: A :class:`RewrapManyDataKeyResult`.

This method allows you to re-encrypt all of your data-keys with a new CMK, or master key.
Note that this does *not* require re-encrypting any of the data in your encrypted collections,
but rather refreshes the key that protects the keys that encrypt the data:

.. code-block:: python

   client_encryption.rewrap_many_data_key(
       filter={"keyAltNames": "optional filter for which keys you want to update"},
       master_key={
           "provider": "azure",  # replace with your cloud provider
           "master_key": {
               # put the rest of your master_key options here
               "key": "<your new key>"
           },
       },
   )

.. versionadded:: 4.2
Nz1A provider must be given if a master_key is givenr   rÖ  ÚkeyMaterialÚ	masterKeyz$currentDateÚ
updateDateTrÇ   )r'   r.  rX   ru  Úrewrap_many_data_keyrÞ   r   r   r/   Úappendrv  Ú
bulk_write)ro   r    r”   r|  Ú
raw_resultrÌ   ÚreplacementsrÁ   Úupdate_modelÚopÚresults   &&&&       rN   rá  Ú%ClientEncryption.rewrap_many_data_key¬  s"  € ðF Ò! hÒ&6Ü$Ð%XÓYÐYØ×ÑÔÜ$×&Õ&Ø×)Ñ)×>Ñ>¸vÐQ[Ó\ˆJØÒ!Ü.Ó0÷ 'Ò&à!÷ 'ô
 " *Ô.FÓGˆØˆØ˜3—<�<ˆCà˜¨¨MÕ(:¸KÈÈ[ÕIYÐZØ ¨tÐ 4ðˆLô ˜E 3 u¥:Ð.°Ó=ˆBØ×Ñ Ö#ñ  ÷ Ü*Ó,Ð,Ø×#Ñ#Ò/Ð/Ð/Ø×%Ñ%×0Ñ0°Ó>ˆÜ& vÓ.Ð.÷% '×&ús   ¶*DÄD.	c               ó   € V ^8„  d   QhRR/# )rH   rK   zClientEncryption[_DocumentType]rL   )rM   s   "rN   rO   re  æ  s   € ÷ ñ Ð:ñ rP   c                	ó   € V # rä   rL   rÖ   s   &rN   Ú	__enter__ÚClientEncryption.__enter__æ  s   € ØˆrP   c               ó(   € V ^8„  d   QhRRRRRRRR/# )rH   Úexc_typer   Úexc_valÚexc_tbrK   rt   rL   )rM   s   "rN   rO   re  é  s(   € ÷ ñ  ð ¨sð ¸Cð ÀDñ rP   c                	ó&   € V P                  4        R # rä   )r�   )ro   rï  rð  rñ  s   &&&&rN   Ú__exit__ÚClientEncryption.__exit__é  s   € Ø�
‰
ŽrP   c               ó   € V ^8„  d   QhRR/# r©   rL   )rM   s   "rN   rO   re  ì  r:  rP   c                	ó8   € V P                   f   \        R4      hR # )Nz"Cannot use closed ClientEncryption)ru  r*   rÖ   s   &rN   r.  ÚClientEncryption._check_closedì  s   € Ø×ÑÒ#Ü"Ð#GÓHÐHñ $rP   c               ó   € V ^8„  d   QhRR/# r©   rL   )rM   s   "rN   rO   re  ð  s   € ÷ $ñ $�tñ $rP   c                ó²   € V P                   '       dE   V P                   P                  4        V P                  P                  4        RV n         RV n        R# R# )a  Release resources.

Note that using this class in a with-statement will automatically call
:meth:`close`::

    with ClientEncryption(...) as client_encryption:
        encrypted = client_encryption.encrypt(value, ...)
        decrypted = client_encryption.decrypt(encrypted)

N)rt  r�   ru  rÖ   s   &rN   r�   ÚClientEncryption.closeð  sI   € ð ××ÐØ×Ñ×$Ñ$Ô&Ø×Ñ×"Ñ"Ô$Ø!%ˆDÔØ#ˆDÖñ	 rP   )rr  ru  rt  r  rv  r  r  rm   )NN)NNN)NNNNNFN)NNNNNN)NNNNN)rØ   rÙ   rÚ   rÛ   rò   rp   rŠ  r†  r¨  r/  r°  r7  r½  rÁ  rÆ  rÎ  rÒ  rÚ  rá  rì  ró  r.  r�   rÜ   rL   rP   rN   r_  r_  I  sv   † Ù6÷EA÷NWK÷rY÷v1.÷f<
÷|5
õnQõ":õ
-õ<õMõ"Lõ"O÷H8/õtõõI÷$ñ $rP   r_  )‚Ú__conditional_annotations__rò   Ú
__future__r   Ú
contextlibÚenumrŽ   r…   r¡  rg   Úcopyr   Útypingr   r   r   r   r   r	   r
   r   r   r   r   r   Úpymongocrypt.errorsr   Úpymongocrypt.mongocryptr   Ú'pymongocrypt.synchronous.auto_encrypterr   Ú+pymongocrypt.synchronous.explicit_encrypterr   Ú&pymongocrypt.synchronous.state_machiner   ro  ÚImportErrorÚobjectÚbsonr   r   r   Úbson.binaryr   r   r   Úbson.codec_optionsr   Úbson.errorsr   Úbson.raw_bsonr   r   r   Úpymongor    Úpymongo.commonr!   Úpymongo.daemonr"   Úpymongo.encryption_optionsr#   r$   r%   r&   Úpymongo.errorsr'   r(   r)   r*   r+   r,   Úpymongo.helpers_sharedr-   rŠ   r.   Úpymongo.operationsr/   Úpymongo.pool_optionsr0   Úpymongo.pool_sharedr1   r2   Úpymongo.read_concernr3   Úpymongo.resultsr4   r5   Úpymongo.ssl_supportr6   r7   Úpymongo.synchronous.collectionr8   Úpymongo.synchronous.cursorr9   Úpymongo.synchronous.databaser:   Ú pymongo.synchronous.mongo_clientr;   Úpymongo.typingsr<   r=   Úpymongo.uri_parser_sharedr>   r?   Úpymongo.write_concernr@   rA   Úpymongo.pyopenssl_contextrB   rC   rn   r‚   r�   r  rŸ   rF   Ú__annotations__rk   rU   ÚcontextmanagerrX   rZ   rÞ   rõ   ÚEnumrA  rO  r  r_  )rû  s   @rN   Ú<module>r$     s¶  øðô ?Ý "ã Û Û Û Û Û Ý ÷÷ ÷ ó ð Ý3Ý9ÝEõõð Ð÷
 /Ñ .ß 6Ñ 6Ý +Ý !ß RÑ RÝ Ý *Ý (÷ó ÷÷ õ 8Ý )Ý (Ý ,÷õ -ß 9ß CÝ 5Ý -Ý 1Ý 8ß ;ß HÝ .çÝ<å2Ý(ð €à€Ø&Ð ØÐ á/;Ø˜˜S˜•>°xô0€Ð,ó ñ
 ¨oÔ>€õ\ð ×Ñô	,ó ð	,ôX+Ð&ô X+÷vIñ I÷.u)ñ u)ôp!��T—Y‘Yô !ôH'��T—Y‘Yô 'õTFôv
$�w˜}Õ-ö v
$øðk ô  ØÐØÓð ús   Á G' Ç'G6Ç5G6