
    lKj                          d dl mZ d dl mZ d dl mZ d dl mZ d dlmZ ddlmZ ddlm	Z	 dd	l
mZ  G d
 d      Z G d de      Zy)    )OctKey)RSAKey)ECKey)OKPKey)add_params_to_qs   )client_secret_jwt_sign)private_key_jwt_sign)ASSERTION_TYPEc                   ,    e Zd ZdZdZdZddZd Zd Zy)	ClientSecretJWTa|  Authentication method for OAuth 2.0 Client. This authentication
    method is called ``client_secret_jwt``, which is using ``client_id``
    and ``client_secret`` constructed with JWT to identify a client.

    Here is an example of use ``client_secret_jwt`` with Requests Session::

        from authlib.integrations.requests_client import OAuth2Session

        token_endpoint = "https://example.com/oauth/token"
        session = OAuth2Session(
            "your-client-id",
            "your-client-secret",
            token_endpoint_auth_method="client_secret_jwt",
        )
        session.register_client_auth_method(ClientSecretJWT(token_endpoint))
        session.fetch_token(token_endpoint)

    :param token_endpoint: A string URL of the token endpoint
    :param claims: Extra JWT claims
    :param headers: Extra JWT headers
    :param alg: ``alg`` value, default is HS256
    client_secret_jwtHS256Nc                 B    || _         || _        || _        ||| _        y y )N)token_endpointclaimsheadersalg)selfr   r   r   r   s        l/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/authlib/oauth2/rfc7523/auth.py__init__zClientSecretJWT.__init__(   s)    ,?DH     c                     t        |j                  t              r|j                  }nt        j                  |j                        }t	        ||j
                  || j                  | j                  | j                        S N)	client_idr   r   headerr   )	
isinstanceclient_secretr   
import_keyr	   r   r   r   r   r   authr   keys       r   signzClientSecretJWT.sign/   sb    d((&1$$C##D$6$67C%nn);;<<
 	
r   c                     | j                   }|s|}| j                  ||      }t        |xs ddt        fd|fg      }|||fS )N client_assertion_typeclient_assertion)r   r#   r   r   )r   r!   methodurir   bodyr   r'   s           r   __call__zClientSecretJWT.__call__=   s\    ,, N99T>:JB(.9#%56
 GT!!r   )NNNN)	__name__
__module____qualname____doc__namer   r   r#   r+    r   r   r   r      s"    . D
C
"r   r   c                       e Zd ZdZdZdZd Zy)PrivateKeyJWTaw  Authentication method for OAuth 2.0 Client. This authentication
    method is called ``private_key_jwt``, which is using ``client_id``
    and ``private_key`` constructed with JWT to identify a client.

    Here is an example of use ``private_key_jwt`` with Requests Session::

        from authlib.integrations.requests_client import OAuth2Session

        token_endpoint = "https://example.com/oauth/token"
        session = OAuth2Session(
            "your-client-id",
            "your-client-private-key",
            token_endpoint_auth_method="private_key_jwt",
        )
        session.register_client_auth_method(PrivateKeyJWT(token_endpoint))
        session.fetch_token(token_endpoint)

    :param token_endpoint: A string URL of the token endpoint
    :param claims: Extra JWT claims
    :param headers: Extra JWT headers
    :param alg: ``alg`` value, default is RS256
    private_key_jwtRS256c                    t        |j                  t        t        t        f      r|j                  }nt        j
                  |j                        }t        ||j                  || j                  | j                  | j                        S r   )r   r   r   r   r   r   r
   r   r   r   r   r    s       r   r#   zPrivateKeyJWT.signh   si    d((65&*AB$$C##D$6$67C#nn);;<<
 	
r   N)r,   r-   r.   r/   r0   r   r#   r1   r   r   r3   r3   M   s    . D
C
r   r3   N)joserfc.jwkr   r   r   r   authlib.common.urlsr   	assertionr	   r
   clientr   r   r3   r1   r   r   <module>r;      s4        0 - + "=" ="@'
O '
r   