Your IP : 52.14.7.103
B
���_� � @ s d dl Z d dlZd dlmZmZ y d dlmZ d dlmZm Z W n e
k
rX eZY nX eeef ed�dd�Z
eeef ed�d d
�Zeed�dd�Zeed
�dd�Zeeef ed
�dd�Zeeed�dd�Zeed�dd�Zeed
�dd�Zeeed�dd�Zeeed�dd�ZdS ) � N)�Any�Union)�
EllipticCurve)�decode_dss_signature�encode_dss_signature)�value�returnc C s. t | t�r| �d�S t | t�r"| S td��d S )Nzutf-8zExpected a string value)�
isinstance�str�encode�bytes� TypeError)r � r �:/opt/alt/python37/lib/python3.7/site-packages/jwt/utils.py�force_bytes s
r )�inputr c C sB t | t�r| �d�} t| �d }|dkr8| dd| 7 } t�| �S )N�ascii� r � =)r r
r �len�base64Zurlsafe_b64decode)r Zremr r r �base64url_decode s
r c C s t �| ��dd�S )Nr � )r Zurlsafe_b64encode�replace)r r r r �base64url_encode$ s r )�valr c C s0 | dk rt d��t| �}t|�dkr(d}t|�S )Nr zMust be a positive integer� )�
ValueError�bytes_from_intr r )r � int_bytesr r r �to_base64url_uint( s r c C s* t | t�r| �d�} t| �}tj|dd�S )Nr �big)� byteorder)r r
r r �int�
from_bytes)r �datar r r �from_base64url_uint4 s
r&