
    5i\{                     ,   d Z ddlZddlmZ ddlZddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlZddlmZ ddlmZmZmZ  G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d      Z G d de      Z G d de      Zd Zy)zM
AWS client-side authentication: standard credentials providers and signing.
    N)NativeResource)HttpRequestHttpProxyOptions)ClientBootstrapClientTlsContext)Future)IntEnum)OptionalSequenceTuplec                        e Zd ZdZdZdZd fd	Ze fd       Ze	d        Z
e	d        Ze	d        Ze	d	        Zd
 Z xZS )AwsCredentialsa&  
    AwsCredentials are the public/private data needed to sign an authenticated AWS request.

    AwsCredentials are immutable.

    Args:
        access_key_id (str): Access key ID
        secret_access_key (str): Secret access key
        session_token (Optional[str]): Optional security token associated with
            the credentials.
        expiration (Optional[datetime.datetime]): Optional expiration datetime,
            that the credentials will no longer be valid past.
            Converted to UTC timezone and rounded down to nearest second.
            If not set, then credentials do not expire.

    Attributes:
        access_key_id (str): Access key ID
        secret_access_key (str): Secret access key
        session_token (Optional[str]): Security token associated with
            the credentials. None if not set.
        expiration (Optional[datetime.datetime]): Expiration datetime,
            that the credentials will no longer be valid past.
            None if credentials do not expire.
            Timezone is always UTC.
     l    c                 Z   t        |t              sJ t        |t              sJ t        |t              s|J || j                  }n8t        |j	                               }|dk  s|| j                  k\  rt        d      t        |           t        j                  ||||      | _
        y )Nr   z expiration datetime out of range)
isinstancestr_NONEXPIRING_TIMESTAMPint	timestampOverflowErrorsuper__init___awscrtcredentials_new_binding)selfaccess_key_idsecret_access_keysession_token
expirationexpiration_timestamp	__class__s         m/home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/awscrt/auth.pyr   zAwsCredentials.__init__2   s    ----+S111--1FFF #'#>#> #&z';';'=#> #a'+?4C^C^+^#$FGG// 	"    c                 T    | j                  |       }t        | |          ||_        |S )z+Construct from a pre-existing native object)__new__r   r   r   )clsbindingcredentialsr"   s      r#   _from_bindingzAwsCredentials._from_bindingF   s.     kk#&c;(*&r$   c                 @    t        j                  | j                        S N)r   credentials_access_key_idr   r   s    r#   r   zAwsCredentials.access_key_idN       00??r$   c                 @    t        j                  | j                        S r,   )r   credentials_secret_access_keyr   r.   s    r#   r   z AwsCredentials.secret_access_keyR   s    44T]]CCr$   c                 @    t        j                  | j                        S r,   )r   credentials_session_tokenr   r.   s    r#   r   zAwsCredentials.session_tokenV   r/   r$   c                     t        j                  | j                        }|| j                  k(  ry t        j                  j                  |t        j                  j                        S )N)tz)r   (credentials_expiration_timestamp_secondsr   r   datetimefromtimestamptimezoneutc)r   r   s     r#   r    zAwsCredentials.expirationZ   sO    DDT]]S	333$$229ARARAVAV2WWr$   c                     | S r,   r   )r   memos     r#   __deepcopy__zAwsCredentials.__deepcopy__c   s    r$   )NN)__name__
__module____qualname____doc__	__slots__r   r   classmethodr*   propertyr   r   r   r    r=   __classcell__r"   s   @r#   r   r      s    2 I 0"(   @ @ D D @ @ X Xr$   r   c                       e Zd Zy)AwsCredentialsProviderBaseN)r>   r?   r@   r   r$   r#   rH   rH   h   s     	r$   rH   c                       e Zd ZdZdZ fdZedd       Zedd       Ze	 	 	 	 dd       Z	edd       Z
ed	        Zed
        Zed        Zeddddddededej                   j"                  deeeeef         dee   dee   dee   fd       Zeddddedededej                   j"                  dee   dee   fd       Zd Z xZS )AwsCredentialsProvidera  
    Credentials providers source the AwsCredentials needed to sign an authenticated AWS request.

    This class provides `new_X()` functions for several built-in provider types.
    To define a custom provider, use the :meth:`new_delegate()` function.
    r   c                 0    t         |           || _        y r,   )r   r   r   )r   r(   r"   s     r#   r   zAwsCredentialsProvider.__init__|   s    r$   Nc                     t        |t              s|J |t        j                         }t        j                  |      } | |      S )a  
        Create the default provider chain used by most AWS SDKs.

        Generally:

        1.  Environment
        2.  Profile
        3.  (conditional, off by default) ECS
        4.  (conditional, on by default) EC2 Instance Metadata

        Args:
            client_bootstrap (Optional[ClientBootstrap]): Client bootstrap to use when initiating socket connection.
                If not set, uses the default static ClientBootstrap instead.

        Returns:
            AwsCredentialsProvider:
        )r   r   get_or_create_static_defaultr   &credentials_provider_new_chain_default)r'   client_bootstrapr(   s      r#   new_default_chainz(AwsCredentialsProvider.new_default_chain   sK    & *O<@P@XXX#.KKM@@AQR7|r$   c                     t        |t              sJ t        |t              sJ t        |t              s|J t        j                  |||      } | |      S )aE  
        Create a simple provider that just returns a fixed set of credentials.

        Args:
            access_key_id (str): Access key ID
            secret_access_key (str): Secret access key
            session_token (Optional[str]): Optional session token

        Returns:
            AwsCredentialsProvider:
        )r   r   r   credentials_provider_new_static)r'   r   r   r   r(   s        r#   
new_staticz!AwsCredentialsProvider.new_static   sZ     ----+S111--1FFF99-IZ\ij7|r$   c                    t        |t              s|J t        |t              s|J t        |t              s|J t        |t              s|J |t        j                         }t	        j
                  ||||      } | |      S )a0  
        Creates a provider that sources credentials from key-value profiles
        loaded from the aws credentials file.

        Args:
            client_bootstrap (Optional[ClientBootstrap]): Client bootstrap to use when initiating socket connection.
                If not set, uses the static default ClientBootstrap instead.

            profile_name (Optional[str]): Name of profile to use.
                If not set, uses value from AWS_PROFILE environment variable.
                If that is not set, uses value of "default"

            config_filepath (Optional[str]): Path to profile config file.
                If not set, uses value from AWS_CONFIG_FILE environment variable.
                If that is not set, uses value of "~/.aws/config"

            credentials_filepath (Optional[str]): Path to profile credentials file.
                If not set, uses value from AWS_SHARED_CREDENTIALS_FILE environment variable.
                If that is not set, uses value of "~/.aws/credentials"

        Returns:
            AwsCredentialsProvider:
        )r   r   r   rM   r    credentials_provider_new_profile)r'   rO   profile_nameconfig_filepathcredentials_filepathr(   s         r#   new_profilez"AwsCredentialsProvider.new_profile   s    < *O<@P@XXX,,0DDD/3/?3JJJ.48L8TTT#.KKM::lO=QS7|r$   c                 <    t        j                  |      } | |      S )a  
        Creates a provider that sources credentials from running an external command or process.

        The command to run is sourced from a profile in the AWS config file, using the standard
        profile selection rules. The profile key the command is read from is "credential_process."
        Example::

            [default]
            credential_process=/opt/amazon/bin/my-credential-fetcher --argsA=abc

        On successfully running the command, the output should be a json data with the following
        format::

            {
                "Version": 1,
                "AccessKeyId": "accesskey",
                "SecretAccessKey": "secretAccessKey"
                "SessionToken": "....",
                "Expiration": "2019-05-29T00:21:43Z"
            }

        Version here identifies the command output format version.
        This provider is not part of the default provider chain.

        Args:
            profile_to_use (Optional[str]): Name of profile in which to look for credential_process.
                If not set, uses value from AWS_PROFILE environment variable.
                If that is not set, uses value of "default"

        Returns:
            AwsCredentialsProvider:
        )r    credentials_provider_new_process)r'   profile_to_user(   s      r#   new_processz"AwsCredentialsProvider.new_process   s    F ::>J7|r$   c                 :    t        j                         } | |      S )z
        Creates a provider that returns credentials sourced from environment variables.

        * AWS_ACCESS_KEY_ID
        * AWS_SECRET_ACCESS_KEY
        * AWS_SESSION_TOKEN

        Returns:
            AwsCredentialsProvider:
        )r   $credentials_provider_new_environment)r'   r(   s     r#   new_environmentz&AwsCredentialsProvider.new_environment   s     >>@7|r$   c                 <    t        j                  |      } | |      S )a  
        Creates a provider that sources credentials from an ordered sequence of providers.

        This provider uses the first set of credentials successfully queried.
        Providers are queried one at a time; a provider is not queried until the
        preceding provider has failed to source credentials.

        Args:
            providers (List[AwsCredentialsProvider]): List of credentials providers.

        Returns:
            AwsCredentialsProvider:
        )r   credentials_provider_new_chain)r'   	providersr(   s      r#   	new_chainz AwsCredentialsProvider.new_chain  s      88C7|r$   c                 V    t        |      sJ t        j                  |      } | |      S )a"  
        Creates a provider that sources credentials from a custom
        synchronous callback.

        Args:
            get_credentials: Callable which takes no arguments and returns
                :class:`AwsCredentials`.

        Returns:
            AwsCredentialsProvider:
        )callabler   !credentials_provider_new_delegate)r'   get_credentialsr(   s      r#   new_delegatez#AwsCredentialsProvider.new_delegate"  s,     (((;;OL7|r$   )loginscustom_role_arnrO   http_proxy_optionsendpointidentitytls_ctxrj   rk   rO   rl   c          	      T   t        |t              sJ t        |t              sJ t        |t              sJ t        |t              s|J t        |t              s|J |t	        j
                         }t        |t              sJ t        j                  |||||||      } | |      S )a  
        Creates a provider that sources credentials from the AWS Cognito Identity service.

        Args:
            endpoint (str): Cognito Identity service regional endpoint to source credentials from.

            identity (str): Cognito identity to fetch credentials relative to.

            tls_ctx (ClientTlsContext): Client TLS context to use when querying cognito credentials by HTTP.

            logins (Optional[Sequence[tuple[str, str]]]): Sequence of tuples specifying pairs of identity provider name
                and token values, representing established login contexts for identity authentication purposes.

            custom_role_arn (Optional[str]): ARN of the role to be assumed when multiple roles were received in the
                token from the identity provider.

            client_bootstrap (Optional[ClientBootstrap]): Client bootstrap to use when initiating a socket connection.
                If not set, uses the static default ClientBootstrap instead.

            http_proxy_options (Optional[HttpProxyOptions]): Optional HTTP proxy options.
                If None is provided then an HTTP proxy is not used.

        Returns:
            AwsCredentialsProvider:
        )r   r   r   r   r   rM   r    credentials_provider_new_cognito)	r'   rm   rn   ro   rj   rk   rO   rl   r(   s	            r#   new_cognitoz"AwsCredentialsProvider.new_cognito6  s    J (C((((C((('#3444/3/?3JJJ,.>?CUC]]]#.KKM*O<<<::  7|r$   )rO   rl   
thing_name
role_aliasc                N   t        |t              sJ t        |t              sJ t        |t              sJ t        |t              sJ t        |t              s|J |t	        j
                         }t        |t              sJ t        j                  ||||||      } | |      S )a[  
        Creates a provider that sources credentials from IoT's X509 credentials service.

        Args:
            endpoint (str): X509 service regional endpoint to source credentials from.
                            This is a per-account value that can be determined via the CLI:
                            `aws iot describe-endpoint --endpoint-type iot:CredentialProvider`

            thing_name (str): The name of the IoT thing to use to fetch credentials.

            role_alias (str): The name of the role alias to fetch credentials through.

            tls_ctx (ClientTlsContext): The client TLS context to use when establishing the http connection to IoT's X509 credentials service.

            client_bootstrap (Optional[ClientBootstrap]): Client bootstrap to use when initiating a socket connection.
                If not set, uses the static default ClientBootstrap instead.

            http_proxy_options (Optional[HttpProxyOptions]): Optional HTTP proxy options.
                If None is provided then an HTTP proxy is not used.

        Returns:
            AwsCredentialsProvider:
        )r   r   r   r   r   rM   r   credentials_provider_new_x509)r'   rm   rs   rt   ro   rO   rl   r(   s           r#   new_x509zAwsCredentialsProvider.new_x509o  s    D (C(((*c****c***'#3444,.>?CUC]]]#.KKM*O<<<77  7|r$   c                     t               fd}	 t        j                  | j                  |       S # t        $ r}j                  |       Y d}~S d}~ww xY w)a  
        Asynchronously fetch AwsCredentials.

        Returns:
            concurrent.futures.Future: A Future which will contain
            :class:`AwsCredentials` (or an exception) when the operation completes.
            The operation may complete on a different thread.
        c                    	 | r/j                  t        j                  j                  |              y t        j                  |      }j                  |       y # t        $ r}j                  |       Y d }~y d }~ww xY wr,   )set_exceptionawscrt
exceptions	from_coder   r*   
set_result	Exception)
error_coder(   r)   efutures       r#   _on_completez<AwsCredentialsProvider.get_credentials.<locals>._on_complete  si    ((():):)D)DZ)PQ"0">">w"GK%%k2 ($$Q''(s   0A &A 	A?$A::A?N)r   r   $credentials_provider_get_credentialsr   r   rz   )r   r   r   r   s      @r#   rh   z&AwsCredentialsProvider.get_credentials  sY     		(	$88U   	$  ##	$s    4 	AAAr,   )NNNN)r>   r?   r@   rA   rB   r   rC   rP   rS   rY   r]   r`   rd   ri   r   r{   ior   r
   r   r   r   r   rr   rw   rh   rE   rF   s   @r#   rJ   rJ   s   s    I   4  &  " !%' 'R # #J    $  &  ;?-1:>=A6 6 	6
 YY//6 XeCHo676 &c]6 '76 !))9 :6 6p  ;?=A1 1 	1
 1 YY//1 '71 !))9 :1 1fr$   rJ   c                        e Zd ZdZdZ	 dZ	 dZy)AwsSigningAlgorithmz"AWS signing algorithm enumeration.r         N)r>   r?   r@   rA   V4V4_ASYMMETRICV4_S3EXPRESSr   r$   r#   r   r     s    ,	
BM*L*r$   r   c                       e Zd ZdZdZ	 dZy)AwsSignatureTypez=Which sort of signature should be computed from the signable.r   r   N)r>   r?   r@   rA   HTTP_REQUEST_HEADERSHTTP_REQUEST_QUERY_PARAMSr   r$   r#   r   r     s    G
 !"r$   r   c                   &    e Zd ZdZdZ	 dZ	 dZ	 dZy)AwsSignedBodyValuez
    Values for use with :attr:`AwsSigningConfig.signed_body_value`.

    Some services use special values (e.g. "UNSIGNED-PAYLOAD") when the body
    is not being signed in the usual way.
    @e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855zUNSIGNED-PAYLOADz"STREAMING-AWS4-HMAC-SHA256-PAYLOADz!STREAMING-AWS4-HMAC-SHA256-EVENTSN)r>   r?   r@   rA   EMPTY_SHA256UNSIGNED_PAYLOAD"STREAMING_AWS4_HMAC_SHA256_PAYLOAD!STREAMING_AWS4_HMAC_SHA256_EVENTSr   r$   r#   r   r     s-     VL*)@)M&J(K%Br$   r   c                       e Zd ZdZdZ	 dZy)AwsSignedBodyHeaderTypez
    Controls if signing adds a header containing the canonical request's signed body value.

    See :attr:`AwsSigningConfig.signed_body_value`.
    r   r   N)r>   r?   r@   rA   NONEX_AMZ_CONTENT_SHA_256r   r$   r#   r   r     s     D^r$   r   c                   X    e Zd ZdZdZdZej                  ej                  dddddddde
j                  ddf fd	Zd	 Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Z xZS )AwsSigningConfiga  
    Configuration for use in AWS-related signing.

    AwsSigningConfig is immutable.

    It is good practice to use a new config for each signature, or the date might get too old.

    Args:
        algorithm (AwsSigningAlgorithm): Which signing algorithm to use.

        signature_type (AwsSignatureType): Which sort of signature should be
            computed from the signable.

        credentials_provider (AwsCredentialsProvider): Credentials provider
            to fetch signing credentials with. If the algorithm is
            :attr:`AwsSigningAlgorithm.V4_ASYMMETRIC`, ECC-based credentials will be derived from the
            fetched credentials.

        region (str): If the algorithm is :attr:`AwsSigningAlgorithm.V4`, the region to sign against.
            If the algorithm is :attr:`AwsSigningAlgorithm.V4_ASYMMETRIC`, the value of the
            "X-amzn-region-set" header (added in signing).

        service (str): Name of service to sign a request for.

        date (Optional[datetime.datetime]): Date and time to use during the
            signing process. If None is provided then
            `datetime.datetime.now(datetime.timezone.utc)` is used.
            Naive dates (lacking timezone info) are assumed to be in local time.

        should_sign_header (Optional[Callable[[str], bool]]):
            Optional function to control which headers are
            a part of the canonical request.

            Skipping auth-required headers will result in an unusable signature.
            Headers injected by the signing process are not skippable.
            This function does not override the internal check function
            (x-amzn-trace-id, user-agent), but rather supplements it.
            In particular, a header will get signed if and only if it returns
            true to both the internal check (skips x-amzn-trace-id, user-agent)
            and this function (if defined).

        use_double_uri_encode (bool): Whether to double-encode the resource path
            when constructing the canonical request (assuming the path is already
            encoded). Default is True. All services except S3 use double encoding.

        should_normalize_uri_path (bool): Whether the resource paths are
            normalized when building the canonical request. Default is True.

        signed_body_value (Optional[str]): If set, this value is used as the
            canonical request's body value. Typically, this is the SHA-256
            of the payload, written as lowercase hex. If this has been
            precalculated, it can be set here. Special values used by certain
            services can also be set (see :class:`AwsSignedBodyValue`). If `None`
            is passed (the default), the typical value will be calculated from
            the payload during signing.

        signed_body_header_type (AwsSignedBodyHeaderType): Controls if signing
            adds a header containing the canonical request's signed body value.
            Default is to not add a header.

        expiration_in_seconds (Optional[int]): If set, and signature_type is
            :attr:`AwsSignatureType.HTTP_REQUEST_QUERY_PARAMS`, then signing will add "X-Amz-Expires"
            to the query string, equal to the value specified here.

        omit_session_token (bool): If set True, the "X-Amz-Security-Token"
            query param is omitted from the canonical request.
            The default False should be used for most services.
    _priv_should_sign_cb)	algorithmsignature_typecredentials_providerregionservicedateshould_sign_headeruse_double_uri_encodeshould_normalize_uri_pathsigned_body_valuesigned_body_header_typeexpiration_in_secondsomit_session_tokenN TFc                 ~   t        |t              sJ t        |t              sJ t        |t              s|J t        |t              sJ t        |t              sJ t              sJ |
 t        |
t              rt        |
      dkD  sJ t        |t              sJ ||dkD  sJ t        | %          |7t        j                  j                  t        j                  j                        }|j                         }| _        fd}nd }|d}t!        j"                  ||||||||||	|
|||      | _        y )Nr   c                      |       S )N)namer   )r   r   s    r#   should_sign_header_wrapperz=AwsSigningConfig.__init__.<locals>.should_sign_header_wrapper|  s    )t44r$   )r   r   r   rJ   r   rf   lenr   r   r   r7   nowr9   r:   r   r   r   signing_config_newr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   s          `        r#   r   zAwsSigningConfig.__init__X  s`     )%8999.*:;;;.0FGK_Kggg&#&&&'3'''*+/A/III (Z8I3-OTWXiTjmnTnoo13JKKK$,0E0III<$$(():):)>)>?DNN$	$6!)5 *.& ($%!22 &!%#! r$   c                     t         j                  D ci c]  }||j                  |t        | |            ! }}t        di |S c c}w )z
        Return an AwsSigningConfig with the same attributes, except for those
        attributes given new values by whichever keyword arguments are specified.
        r   )r   _attributesgetgetattr)r   kwargsxargss       r#   replacezAwsSigningConfig.replace  sI    
 =M<X<XYq6::aq!122YY'$'' Zs   $Ac                 R    t        t        j                  | j                              S )z3AwsSigningAlgorithm: Which signing algorithm to use)r   r   signing_config_get_algorithmr   r.   s    r#   r   zAwsSigningConfig.algorithm  s     #7#G#G#VWWr$   c                 R    t        t        j                  | j                              S )zOAwsSignatureType: Which sort of signature should be computed from the signable.)r   r   !signing_config_get_signature_typer   r.   s    r#   r   zAwsSigningConfig.signature_type  s       I I$-- XYYr$   c                 @    t        j                  | j                        S )z
        AwsCredentialsProvider: Credentials provider to fetch signing credentials with.
        If the algorithm is :attr:`AwsSigningAlgorithm.V4_ASYMMETRIC`, ECC-based credentials will be derived
        from the fetched credentials.
        )r   'signing_config_get_credentials_providerr   r.   s    r#   r   z%AwsSigningConfig.credentials_provider  s     >>t}}MMr$   c                 @    t        j                  | j                        S )z
        str: If signing algorithm is :attr:`AwsSigningAlgorithm.V4`, the region to sign against.
        If the algorithm is :attr:`AwsSigningAlgorithm.V4_ASYMMETRIC`, the value of the
        "X-amzn-region-set header" (added in signing).
        )r   signing_config_get_regionr   r.   s    r#   r   zAwsSigningConfig.region  s     00??r$   c                 @    t        j                  | j                        S )z*str: Name of service to sign a request for)r   signing_config_get_servicer   r.   s    r#   r   zAwsSigningConfig.service  s     11$--@@r$   c                 @    t        j                  | j                        S )a;  
        datetime.datetime: Date and time to use during the signing process.

        If None is provided, then `datetime.datetime.now(datetime.timezone.utc)`
        at time of object construction is used.

        It is good practice to use a new config for each signature, or the date might get too old.
        )r   signing_config_get_dater   r.   s    r#   r   zAwsSigningConfig.date  s     ..t}}==r$   c                     | j                   S )aW  
        Optional[Callable[[str], bool]]: Optional function to control which
        headers are a part of the canonical request.

        Skipping auth-required headers will result in an unusable signature.
        Headers injected by the signing process are not skippable.
        This function does not override the internal check function
        (x-amzn-trace-id, user-agent), but rather supplements it. In particular,
        a header will get signed if and only if it returns true to both
        the internal check (skips x-amzn-trace-id, user-agent) and this function (if defined).
        )r   r.   s    r#   r   z#AwsSigningConfig.should_sign_header  s     (((r$   c                 @    t        j                  | j                        S )z
        bool: Whether to double-encode the resource path when constructing
        the canonical request (assuming the path is already encoded).

        By default, all services except S3 use double encoding.
        )r   (signing_config_get_use_double_uri_encoder   r.   s    r#   r   z&AwsSigningConfig.use_double_uri_encode  s     ??NNr$   c                 @    t        j                  | j                        S )zn
        bool: Whether the resource paths are normalized when building the
        canonical request.
        )r   ,signing_config_get_should_normalize_uri_pathr   r.   s    r#   r   z*AwsSigningConfig.should_normalize_uri_path  s     CCDMMRRr$   c                 @    t        j                  | j                        S )a  
        Optional[str]: What to use as the canonical request's body value.
        If `None` is set (the default), a value will be calculated from
        the payload during signing. Typically, this is the SHA-256 of the
        payload, written as lowercase hex. If this has been precalculated,
        it can be set here. Special values used by certain services can also
        be set (see :class:`AwsSignedBodyValue`).
        )r   $signing_config_get_signed_body_valuer   r.   s    r#   r   z"AwsSigningConfig.signed_body_value  s     ;;DMMJJr$   c                 R    t        t        j                  | j                              S )z
        AwsSignedBodyHeaderType: Controls if signing adds a header containing
        the canonical request's signed body value.
        )r   r   *signing_config_get_signed_body_header_typer   r.   s    r#   r   z(AwsSigningConfig.signed_body_header_type  s!     'w'Y'YZ^ZgZg'hiir$   c                 R    t        j                  | j                        }|dk(  rdS |S )a  
        Optional[int]: If set, and signature_type is :attr:`AwsSignatureType.HTTP_REQUEST_QUERY_PARAMS`,
        then signing will add "X-Amz-Expires" to the query string, equal to the
        value specified here. Otherwise, this is None has no effect.
        r   N)r   (signing_config_get_expiration_in_secondsr   )r   r    s     r#   r   z&AwsSigningConfig.expiration_in_seconds  s)     EEdmmT
!Qt6J6r$   c                 @    t        j                  | j                        S )z
        bool: Whether the "X-Amz-Security-Token" query param is omitted
        from the canonical request. This should be False for most services.
        )r   %signing_config_get_omit_session_tokenr   r.   s    r#   r   z#AwsSigningConfig.omit_session_token
  s     <<T]]KKr$   )r>   r?   r@   rA   rB   r   r   r   r   r   r   r   r   r   rD   r   r   r   r   r   r   r   r   r   r   r   r   r   rE   rF   s   @r#   r   r     sv   CH (IK" /11 0 E E&*$('++/#')@)E)E'+$); z( X X Z Z N N @ @ A A 	> 	> ) ) O O S S 	K 	K j j 7 7 L Lr$   r   c                      t         t              sJ t        |t              sJ t                fd}t	        j
                   ||       S )a$  
    Perform AWS HTTP request signing.

    The :class:`awscrt.http.HttpRequest` is transformed asynchronously,
    according to the :class:`AwsSigningConfig`.

    When signing:

    1.  It is good practice to use a new config for each signature,
        or the date might get too old.

    2.  Do not add the following headers to requests before signing, they may be added by the signer:
        x-amz-content-sha256,
        X-Amz-Date,
        Authorization

    3.  Do not add the following query params to requests before signing, they may be added by the signer:
        X-Amz-Signature,
        X-Amz-Date,
        X-Amz-Credential,
        X-Amz-Algorithm,
        X-Amz-SignedHeaders

    Args:
        http_request (awscrt.http.HttpRequest): The HTTP request to sign.
        signing_config (AwsSigningConfig): Configuration for signing.

    Returns:
        concurrent.futures.Future: A Future whose result will be the signed
        :class:`awscrt.http.HttpRequest`. The future will contain an exception
        if the signing process fails.
    c                     	 | r/j                  t        j                  j                  |              y j	                         y # t
        $ r}j                  |       Y d }~y d }~ww xY wr,   )rz   r{   r|   r}   r~   r   )r   r   r   http_requests     r#   r   z&aws_sign_request.<locals>._on_complete:  sY    	$$$V%6%6%@%@%LM!!,/ 	$  ##	$s   0A A 	A*A%%A*)r   r   r   r   r   sign_request_aws)r   signing_configr   r   s   `  @r#   aws_sign_requestr     sL    D lK000n&6777XF$ \><HMr$   )rA   r   r{   r   awscrt.exceptionsawscrt.httpr   r   	awscrt.ior   r   concurrent.futuresr   r7   enumr	   typingr
   r   r   r   rH   rJ   r   r   r   r   r   r   r   r$   r#   <module>r      s     !  5 7 %   , ,R^ Rj	 	K7 K\

+' 
+w  C C*_g _OL~ OLd1r$   