import hashlib
import base64


def get_auth0_code_challenge(code_verifier: str) -> str:
    """Get an Auth0 code challenge from a code verifier.

    :param code_verifier: A code challenge generated by
        :meth:`simplipy.util.auth.get_auth0_code_verifier`
    :type code_verifier: ``str``
    :rtype: ``str``
    """
    verifier = hashlib.sha256(code_verifier.encode("utf-8")).digest()
    challenge = base64.urlsafe_b64encode(verifier).decode("utf-8")
    return challenge.replace("=", "")