o
    ɶd                     @   s.   d dl m  mZ d dlZG dd deZdS )    Nc                   @   s<   e Zd ZdZdd Zdd Zdd Zefdd	Zd
d ZdS )SecurityTokenContainer<   c                 C   s    || _ || _tj|dd| _d S )NF)jwtZverify)security_tokensession_key_supplierr   decode)selfr   r    r	   Eusr/lib/python3.10/site-packages/oci/auth/security_token_container.py__init__   s   zSecurityTokenContainer.__init__c                 C   s   | j S N)r   r   r	   r	   r
   get_jwt   s   zSecurityTokenContainer.get_jwtc                 C   s   |  d S )Nr   _expired_with_jitterr   r	   r	   r
   valid      zSecurityTokenContainer.validc                 C   s   |  | S r   r   )r   jitterr	   r	   r
   valid_with_jitter   r   z(SecurityTokenContainer.valid_with_jitterc                 C   s   t t }|| jd | kS )ai  
        Checks expiry with some jitter to account for clock skews on the client and also, for
        non-skewed clients, the scenario where the token was valid when we checked but became
        invalid before we sent a request (this should be rare).

        Regarding clock skew, in this context we are only worried about the scenario where the
        client's time is behind the server time as then tokens look like they will be valid for
        longer than they are and calls could fail with 401s.

        If the client's time is ahead of the server time that's not great but it would just lead
        to tokens being refreshed more often, this would not cause hard failures but could lead
        to higher perceived latency on the client

        :param int jitter:
            The amount of jitter, in seconds, to apply to the expiry time in the token
        exp)inttimer   )r   r   Ztime_nowr	   r	   r
   r      s   z+SecurityTokenContainer._expired_with_jitterN)	__name__
__module____qualname__ZDEFAULT_EXPIRY_JITTER_SECONDSr   r   r   r   r   r	   r	   r	   r
   r   	   s    r   )Zoci._vendor.jwt_vendorr   r   objectr   r	   r	   r	   r
   <module>   s   