
    &g                     `    d Z ddlZddlZddlmZmZ ddlmZ d Zd Z	d Z
d Zd	 Zd
 Zd ZdS )zp
oauthlib.utils
~~~~~~~~~~~~~~

This module contains utility methods used by various parts of the OAuth 2 spec.
    N)quoteurlparse)	urldecodec                     t          | t                    s| | S t          | t          t          t          f          rd                    d | D                       S t          d| z            )z5Convert a list of scopes to a space separated string.N c                 ,    g | ]}t          |          S  str.0ss     O/var/www/api/venv/lib/python3.11/site-packages/oauthlib/oauth2/rfc6749/utils.py
<listcomp>z!list_to_scope.<locals>.<listcomp>   s    ///AQ///    z8Invalid scope (%s), must be string, tuple, set, or list.)
isinstancer   settuplelistjoin
ValueErrorscopes    r   list_to_scoper      sn    % ]	EC-	.	. ]xx/////000SV[[\\\r   c                     t          | t          t          t          f          rd | D             S | dS |                                                     d          S )z5Convert a space separated string to a list of scopes.c                 ,    g | ]}t          |          S r	   r
   r   s     r   r   z!scope_to_list.<locals>.<listcomp>   s    &&&1A&&&r   Nr   )r   r   r   r   stripsplitr   s    r   scope_to_listr      sU    %%s+,, (&&&&&&	t{{}}""3'''r   c                     t          t          t          |           j                            }d|v rt	          |d                   |d<   |S )Nr   )dictr   r   queryr   )uriparamss     r   params_from_urir%   "   sE    )HSMM/0011F&'w88wMr   c                     ddd}t          |           \  }}}}}}d|v r|                    dd          \  }}n'|                    |                                          }||fS )zuExtract hostname and port from URI.

    Will use default port for HTTP and HTTPS if none is present in the URI.
    80443)HTTPHTTPS:   )r   r   getupper)	r#   default_portsschnetlocpathparr"   fraports	            r   host_from_urir6   )   sw      M
 *2#&CsE3
f}}||C++  --4<r   c                     t          | t                    st          d          t          |                     d          d          S )ztEscape a string in an OAuth-compatible fashion.

    TODO: verify whether this can in fact be used for OAuth 2

    z#Only unicode objects are escapable.zutf-8   ~)safe)r   r   r   r   encode)us    r   escaper<   <   sE     a @>???'""....r   c                     t           j                                         | z
  }|j        |j        |j        dz  dz  z   dz  z   dz  }t          |          S )z9Generate a age parameter for MAC authentication draft 00.   i  i@B )datetimenowmicrosecondssecondsdaysr   )
issue_timetdages      r   generate_agerG   G   sV    					 	 :	-B?bj27R<$+>>  Cs88Or   c                     t           j                            d          rdS |                                                     d          S )zCheck if the uri is over ssl.OAUTHLIB_INSECURE_TRANSPORTTzhttps://)osenvironr-   lower
startswith)r#   s    r   is_secure_transportrN   O   s:    	z~~344 t99;;!!*---r   )__doc__r?   rJ   urllib.parser   r   oauthlib.commonr   r   r   r%   r6   r<   rG   rN   r	   r   r   <module>rR      s      				 ( ( ( ( ( ( ( ( % % % % % %] ] ]( ( (    &/ / /  . . . . .r   