+
    Q(i                     Z    R t ^ RIt^ RIHtHtHt ^ RIHtHt R R lt	R R lt
R R	 ltR# )
zKUtilities for OAuth 2.0 Resource Indicators (RFC 8707) and PKCE (RFC 7636).N)urlparseurlsplit
urlunsplit)AnyUrlHttpUrlc                \    V ^8  d   QhR\         \        ,          \        ,          R\         /# )   urlreturn)strr   r   )formats   "[/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/mcp/shared/auth_utils.py__annotate__r   	   s#      cGmf&<      c                    \        V 4      p\        V4      p\        VP                  VP                  P                  4       VP                  P                  4       RR7      4      pV# )a(  Convert server URL to canonical resource URL per RFC 8707.

RFC 8707 section 2 states that resource URIs "MUST NOT include a fragment component".
Returns absolute URI with lowercase scheme/host for canonical form.

Args:
    url: Server URL to convert

Returns:
    Canonical resource URL string
 )schemenetlocfragment)r   r   r   _replacer   lowerr   )r	   url_strparsed	canonicals   &   r   resource_url_from_server_urlr   	   sV     #hG gF6??&--2E2E2GPVP]P]PcPcPepr?stIr   c                <    V ^8  d   QhR\         R\         R\        /# )r   requested_resourceconfigured_resourcer
   )r   bool)r   s   "r   r   r      s"     '6 '6s '6 '6QU '6r   c                   \        V 4      p\        V4      pVP                  P                  4       VP                  P                  4       8w  g8   VP                  P                  4       VP                  P                  4       8w  d   R# VP                  pVP                  p\        V4      \        V4      8  d   R# VP                  R4      '       g
   VR,          pVP                  R4      '       g
   VR,          pVP                  V4      # )a  Check if a requested resource URL matches a configured resource URL.

A requested resource matches if it has the same scheme, domain, port,
and its path starts with the configured resource's path. This allows
hierarchical matching where a token for a parent resource can be used
for child resources.

Args:
    requested_resource: The resource URL being requested
    configured_resource: The resource URL that has been configured

Returns:
    True if the requested resource matches the configured resource
F/)r   r   r   r   pathlenendswith
startswith)r   r   	requested
configuredrequested_pathconfigured_paths   &&    r   check_resource_allowedr)      s      +,I-.J :#4#4#:#:#<<	@P@P@V@V@X\f\m\m\s\s\u@u ^^N ooO >S11
 ""3''###C((3$$_55r   c                b    V ^8  d   QhR\         \        ,          R,          R\        R,          /# )r   
expires_inNr
   )intr   float)r   s   "r   r   r   I   s'     ) )sSy4'7 )EDL )r   c                X    V f   R# \         P                   ! 4       \        V 4      ,           # )zCalculate token expiry timestamp from expires_in seconds.

Args:
    expires_in: Seconds until token expiration (may be string from some servers)

Returns:
    Unix timestamp when token expires, or None if no expiry specified
N)timer,   )r+   s   &r   calculate_token_expiryr0   I   s"     99;Z((r   )__doc__r/   urllib.parser   r   r   pydanticr   r   r   r)   r0    r   r   <module>r5      s$    Q  7 7 $,'6T)r   