
    #	h:                         S SK r S SKrS SKrS SKrS SKr\R
                  " \5      rS rS r	 " S S\
5      r " S S\
5      r " S S	\5      r\r\r\R                   \l        g)
    Nc                 4     U R                  SS9$ !   U s $ = f)Nzutf-8)encoding)encode)raws    J/var/www/html/env/lib/python3.13/site-packages/msal/oauth2cli/assertion.py
_str2bytesr      s$    zz7z++
s    c                 r    [         R                  " [        R                  " U 5      5      R	                  5       $ N)base64urlsafe_b64encodebinasciia2b_hexdecode)
thumbprints    r   _encode_thumbprintr      s'    ##H$4$4Z$@AHHJJ    c                   .    \ rS rSr  SS jr SS jrSrg)AssertionCreator   Nc                     [        S5      e)a  Create an assertion in bytes, based on the provided claims.

All parameter names are defined in https://tools.ietf.org/html/rfc7521#section-5
except the expires_in is defined here as lifetime-in-seconds,
which will be automatically translated into expires_at in UTC.
z Will be implemented by sub-class)NotImplementedError)	selfaudienceissuersubject
expires_at
expires_in	issued_atassertion_idkwargss	            r   create_normal_assertion(AssertionCreator.create_normal_assertion   s     ""DEEr   c                 D   ^  [        XX4U4U 4S jj[        US-
  S5      S9$ )zCreate an assertion as a callable,
which will then compute the assertion later when necessary.

This is a useful optimization to reuse the client assertion.
c                 0   > TR                   " XU4SU0UD6$ )Nr   )r!   )aiser    r   s        r   <lambda>@AssertionCreator.create_regenerative_assertion.<locals>.<lambda>)   s    ,,Q1MMfMr   <   r   )r   )AutoRefreshermax)r   r   r   r   r   r    s   `     r   create_regenerative_assertion.AssertionCreator.create_regenerative_assertion!   s-     7 N:b=!,. 	.r    )NX  NN)Nr1   )__name__
__module____qualname____firstlineno__r!   r.   __static_attributes__r0   r   r   r   r      s    IL)-	F >A
.r   r   c                   (    \ rS rSrSrSS jrS rSrg)r,   .   zCache the output of a factory, and auto-refresh it when necessary. Usage::

r = AutoRefresher(time.time, expires_in=5)
for i in range(15):
    print(r())  # the timestamp change only after every 5 seconds
    time.sleep(1)
c                 *    Xl         X l        0 U l        g r
   )_factory_expires_in_buf)r   factoryr   s      r   __init__AutoRefresher.__init__6   s    %	r   c                 H   Su  p[         R                   " 5       nU R                  R                  US5      U::  a:  [        R	                  S5        X R                  5       XU R                  -   0U l        O[        R	                  S5        U R                  R                  U5      $ )N)r   valuer   zRegenerating new assertionzReusing still valid assertion)timer<   getloggerdebugr:   r;   )r   
EXPIRES_ATVALUEnows       r   __call__AutoRefresher.__call__:   sv    1
iik99==Q'3.LL564CSCS=STDILL89yy}}U##r   )r<   r;   r:   N)i  )r2   r3   r4   r5   __doc__r>   rI   r6   r0   r   r   r,   r,   .   s    $r   r,   c                   8    \ rS rSr SSS.S jjr   SS jrSrg)	JwtAssertionCreatorE   N)sha256_thumbprintc                    Xl         X l        U=(       d    0 U l        U(       a  [        U5      U R                  S'   U(       a  [        U5      U R                  S'   gg)a  Construct a Jwt assertion creator.

Args:

    key (str):
        An unencrypted private key for signing, in a base64 encoded string.
        It can also be a cryptography ``PrivateKey`` object,
        which is how you can work with a previously-encrypted key.
        See also https://github.com/jpadilla/pyjwt/pull/525
    algorithm (str):
        "RS256", etc.. See https://pyjwt.readthedocs.io/en/latest/algorithms.html
        RSA and ECDSA algorithms require "pip install cryptography".
    sha1_thumbprint (str): The x5t aka X.509 certificate SHA-1 thumbprint.
    headers (dict): Additional headers, e.g. "kid" or "x5c" etc.
    sha256_thumbprint (str): The x5t#S256 aka X.509 certificate SHA-256 thumbprint.
zx5t#S256x5tN)key	algorithmheadersr   )r   rR   rS   sha1_thumbprintrT   rO   s         r   r>   JwtAssertionCreator.__init__F   sK    * "}"'9:K'LDLL$"4_"EDLL r   c
           	      @   SSK n[        R                  " 5       nUUU=(       d    UU=(       d    X-   U=(       d    UU=(       d    [        [        R                  " 5       5      S.nU(       a  XS'   UR                  U	=(       d    0 5         UR                  XR                  U R                  U R                  S9n[        U5      $ !   U R                  R                  S5      (       d   U R                  R                  S5      (       a  [        R                  S5        e = f)	zCreate a JWT Assertion.

Parameters are defined in https://tools.ietf.org/html/rfc7523#section-3
Key-value pairs in additional_claims will be added into payload as-is.
r   N)audisssubexpiatjtinbf)rS   rT   RSESzSome algorithms requires "pip install cryptography". See https://pyjwt.readthedocs.io/en/latest/installation.html#cryptographic-dependencies-optional)jwtrB   struuiduuid4updater   rR   rS   rT   r   
startswithrD   	exception)r   r   r   r   r   r   r   r   
not_beforeadditional_claimsr    ra   rH   payloadstr_or_bytess                  r   r!   +JwtAssertionCreator.create_normal_assertionc   s     	iik$f3#"2#43tzz|#4 'EN(.B/		::T^^T\\ & SLl++	~~((..$..2K2KD2Q2Q  wx s   9C AD)rS   rT   rR   )NN)NNr1   NNNN)r2   r3   r4   r5   r>   r!   r6   r0   r   r   rM   rM   E   s(    <@F F< OR:>"r   rM   )rB   r   r   rc   logging	getLoggerr2   rD   r   r   objectr   r,   rM   Signer	JwtSignerr!   sign_assertionr0   r   r   <module>rs      sq         
		8	$K.v .2$F $.=* =B 
	.FF	 r   