o
    sh                     @  s   d Z ddlmZ ddlZddlmZ ejeje	dZ
ee
dZdd d	d
 e D D ZW d   n1 s;w   Y  dddZdS )a6  
These functions validate RP_ID and APP_ID according to simplified TLD+1 rules,
using a bundled copy of the public suffix list fetched from:

  https://publicsuffix.org/list/public_suffix_list.dat

Advanced APP_ID values pointing to JSON files containing valid facets are not
supported by this implementation.
    )annotationsN)urlparsezpublic_suffix_list.datrbc                 C  s   g | ]}|r| d s|qS )z//)
startswith).0entry r   E/var/www/html/env_mimamsha/lib/python3.10/site-packages/fido2/rpid.py
<listcomp>.   s    r
   c                 c  s    | ]
}| d  V  qdS )utf8N)decodestrip)r   liner   r   r	   	<genexpr>0   s    r   rp_idstroriginreturnboolc                 C  sx   | sdS t |}|j}|jdkr%|j|fdkr%|jdkr#|r#|ds%dS || kr+dS |r:|d|  r:| tvr:dS dS )zChecks if a Webauthn RP ID is usable for a given origin.

    :param rp_id: The RP ID to validate.
    :param origin: The origin of the request.
    :return: True if the RP ID is usable by the origin, False if not.
    Fhttps)http	localhostr   z
.localhostT.)r   hostnameschemeendswithsuffixes)r   r   urlhostr   r   r	   verify_rp_id5   s   
r   )r   r   r   r   r   r   )__doc__
__future__r   osurllib.parser   pathjoindirname__file__	tld_fnameopenf	readlinesr   r   r   r   r   r	   <module>   s   
