
    e                     F    d Z ddlZddlmZ dedefdZdeeef   defdZy)a  `JOSE Base64`_ is defined as:

  - URL-safe Base64
  - padding stripped

.. _`JOSE Base64`:
    https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-37#appendix-C

.. Do NOT try to call this module "base64", as it will "shadow" the
   standard library.

    N)Uniondatareturnc                     t        | t              st        d      t        j                  |       j                  d      S )zJOSE Base64 encode.

    :param data: Data to be encoded.
    :type data: bytes

    :returns: JOSE Base64 string.
    :rtype: bytes

    :raises TypeError: if ``data`` is of incorrect type

    zargument should be bytes   =)
isinstancebytes	TypeErrorbase64urlsafe_b64encoderstripr   s    ,/usr/lib/python3/dist-packages/josepy/b64.py	b64encoder      s6     dE"233##D)0066    c                    t        | t              r	 | j                  d      } nt        | t
              st        d      t        j                  | ddt        |       dz  z
  z  z         S # t        $ r t	        d      w xY w)a^  JOSE Base64 decode.

    :param data: Base64 string to be decoded. If it's unicode, then
                 only ASCII characters are allowed.
    :type data: bytes or unicode

    :returns: Decoded data.
    :rtype: bytes

    :raises TypeError: if input is of incorrect type
    :raises ValueError: if input is unicode with non-ASCII characters

    asciiz5unicode argument should contain only ASCII charactersz#argument should be a str or unicoder      )
r   strencodeUnicodeEncodeError
ValueErrorr	   r
   r   urlsafe_b64decodelenr   s    r   	b64decoder   "   s     $	V;;w'D e$=>>##D41D	A3F+G$GHH " 	VTUU	Vs   A) )A>)__doc__r   typingr   r	   r   r   r    r   r   <module>r      sD     7E 7e 7"IE%*% I% Ir   