
    j                        d dl mZ d dlZd dlZd dlZd dlmZ ddlm	Z	 ej
        rddlmZ e G d d                      ZddZ G d dej                  Z G d dej                  ZdS )    )annotationsN)	dataclass   )
Neo4jError)_TAuthc                  4    e Zd ZU dZded<   dZded<   dd
ZdS )ExpiringAutha  Represents potentially expiring authentication information.

    This class is used with :meth:`.AuthManagers.expiration_based` and
    :meth:`.AsyncAuthManagers.expiration_based`.

    :param auth: The authentication information.
    :param expires_at:
        Unix timestamp (seconds since 1970-01-01 00:00:00 UTC)
        indicating when the authentication information expires.
        If :data:`None`, the authentication information is considered to not
        expire until the server explicitly indicates so.

    .. seealso::
        :meth:`.AuthManagers.expiration_based`,
        :meth:`.AsyncAuthManagers.expiration_based`

    .. versionadded:: 5.8

    .. versionchanged:: 5.9

        * Removed parameter and attribute ``expires_in`` (relative expiration
          time). Replaced with ``expires_at`` (absolute expiration time).
        * :meth:`.expires_in` can be used to create an :class:`.ExpiringAuth`
          with a relative expiration time.

    .. versionchanged:: 5.14 Stabilized from preview.
    r   authNzt.Optional[float]
expires_atsecondsfloatreturnc                T    t          | j        t          j                    |z             S )a6  Return a (flat) copy of this object with a new expiration time.

        This is a convenience method for creating an :class:`.ExpiringAuth`
        for a relative expiration time ("expires in" instead of "expires at").

            >>> import time, freezegun
            >>> with freezegun.freeze_time("1970-01-01 00:00:40"):
            ...     ExpiringAuth(("user", "pass")).expires_in(2)
            ExpiringAuth(auth=('user', 'pass'), expires_at=42.0)
            >>> with freezegun.freeze_time("1970-01-01 00:00:40"):
            ...     ExpiringAuth(("user", "pass"), time.time() + 2)
            ExpiringAuth(auth=('user', 'pass'), expires_at=42.0)

        :param seconds:
            The number of seconds from now until the authentication information
            expires.

        .. versionadded:: 5.9
        )r	   r
   time)selfr   s     `/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/neo4j/_auth_management.py
expires_inzExpiringAuth.expires_in?   s!    ( DIty{{W'<===    )r   r   r   r	   )__name__
__module____qualname____doc____annotations__r   r    r   r   r	   r	      sP          6 LLL$(J((((> > > > > >r   r	   r
   r   boolc                F    | j         }|d uo|t          j                    k     S )N)r   r   )r
   r   s     r   expiring_auth_has_expiredr   V   s$    JT!>j49;;&>>r   c                  V    e Zd ZdZej        dd            Zej        dd	            Zd
S )AuthManagera  Baseclass for authentication information managers.

    The driver provides some default implementations of this class in
    :class:`.AuthManagers` for convenience.

    Custom implementations of this class can be used to provide more complex
    authentication refresh functionality.

    .. warning::

        The manager **must not** interact with the driver in any way as this
        can cause deadlocks and undefined behaviour.

        Furthermore, the manager is expected to be thread-safe.

        The token returned must always belong to the same identity.
        Switching identities using the `AuthManager` is undefined behavior.
        You may use session-level authentication for such use-cases
        :ref:`session-auth-ref`.

    .. seealso:: :class:`.AuthManagers`

    .. versionadded:: 5.8

    .. versionchanged:: 5.12
        ``on_auth_expired`` was removed from the interface and replaced by
        :meth:`handle_security_exception`. The new method is called when the
        server returns any `Neo.ClientError.Security.*` error. It's signature
        differs in that it additionally receives the error returned by the
        server and returns a boolean indicating whether the error was handled.
    r   r   c                    dS )a  Return the current authentication information.

        The driver will call this method very frequently. It is recommended
        to implement some form of caching to avoid unnecessary overhead.

        .. warning::

            The method must only ever return auth information belonging to the
            same identity.
            Switching identities using the `AuthManager` is undefined behavior.
            You may use session-level authentication for such use-cases
            :ref:`session-auth-ref`.
        Nr   r   s    r   get_authzAuthManager.get_auth|   s	     	r   r
   errorr   r   c                    dS )a  Handle the server indicating authentication failure.

        The driver will call this method when the server returns any
        `Neo.ClientError.Security.*` error. The error will then be processed
        further as usual.

        :param auth:
            The authentication information that was used when the server
            returned the error.
        :param error:
            The error returned by the server.

        :returns:
            Whether the error was handled (:const:`True`), in which case the
            driver will mark the error as retryable
            (see :meth:`.Neo4jError.is_retryable`).

        .. versionadded:: 5.12
        Nr   r   r
   r#   s      r   handle_security_exceptionz%AuthManager.handle_security_exception   s	    . 	r   Nr   r   r
   r   r#   r   r   r   r   r   r   r   abcabstractmethodr"   r&   r   r   r   r   r   [   sg         @ 	     	     r   r   )	metaclassc                  V    e Zd ZdZej        dd            Zej        dd	            Zd
S )AsyncAuthManagera  Async version of :class:`.AuthManager`.

    .. seealso:: :class:`.AuthManager`

    .. versionadded:: 5.8

    .. versionchanged:: 5.12
        ``on_auth_expired`` was removed from the interface and replaced by
         :meth:`handle_security_exception`. See :class:`.AuthManager`.
    r   r   c                
   K   dS )zlAsync version of :meth:`.AuthManager.get_auth`.

        .. seealso:: :meth:`.AuthManager.get_auth`
        Nr   r!   s    r   r"   zAsyncAuthManager.get_auth   s       	r   r
   r#   r   r   c                
   K   dS )zzAsync version of :meth:`.AuthManager.on_auth_expired`.

        .. seealso:: :meth:`.AuthManager.on_auth_expired`
        Nr   r%   s      r   r&   z*AsyncAuthManager.handle_security_exception   s       	r   Nr'   r(   r)   r   r   r   r.   r.      sf        	 	 	    	     r   r.   )r
   r	   r   r   )
__future__r   r*   r   typingtdataclassesr   
exceptionsr   TYPE_CHECKINGapir   r	   r   ABCMetar   r.   r   r   r   <module>r9      s8  " # " " " " " 



      ! ! ! ! ! ! " " " " " " ?  3> 3> 3> 3> 3> 3> 3> 3>l? ? ? ?
I I I I ICK I I I IX          r   