Viewing File: /opt/alt/python35/lib/python3.5/site-packages/jwt/__pycache__/__main__.cpython-35.opt-1.pyc



b'[@sddlmZmZddlZddlZddlZddlZddlmZm	Z	m
Z
mZddZddZ
d	d
ZddZdS)
)absolute_importprint_functionN)DecodeError__version__decodeencodecCsJ|jdkrtdi}x|jD]}|jdd\}}|dkr|ddkrt|dkrtttjt|dd}|jrt|}n%yt	|}Wntk
rYnXddd	d
ddi}||kr||}|||<q+Wt
|d|jd
|j}|jdS)Nz4Key is required when encoding. See --help for usage.=rexpr+trueTfalseFZnullkey	algorithmzutf-8)
r
ValueErrorpayloadsplitlenstrinttimeisdigitfloatrrr)argsrargkvZ	constantstokenr/__main__.pyencode_payload
s,.,

	r cCsy|jr|j}n3tjjr?tjjj}ntd|jd}t|d|j	d|j
}tj|SWn5t
k
r}zt
d|WYdd}~XnXdS)Nz*Cannot read from stdin: terminal not a TTYzutf-8rverifyz)There was an error decoding the token: %s)rsysstdinisattyreadlinestripIOErrorrrrr!jsondumpsr)rrdataerrrdecode_payload7s	r,cCsTd}tjddd|}|jdddddd	t|jd
ddd
ddddd|jdddd
ddddd|jdddddd}|jddd}d}|jdd d!d||jd"t|jd#dd$}|jd%dd&d d'|jd(d)dd*dd+dd,dd-|jd"t|S).Na
    Encodes or decodes JSON Web Tokens based on input.

    %(prog)s [options] <command> [options] input

    Decoding examples:

    %(prog)s --key=secret decode json.web.token
    %(prog)s decode --no-verify json.web.token

    Encoding requires the key option and takes space separated key/value pairs
    separated by equals (=) as input. Examples:

    %(prog)s --key=secret encode iss=me exp=1302049071
    %(prog)s --key=secret encode foo=bar exp=+10

    The exp key is special and can take an offset to current Unix time.
    progZpyjwtusagez-vz	--versionactionversionz	%(prog)s z--keydestrmetavarZKEYdefaulthelpzset the secret key to sign withz--algrZALGZHS256z0set crypto algorithm to sign with. default=HS256titlezPyJWT subcommandsdescriptionzvalid subcommandszadditional helprz use to encode a supplied payloadzfPayload to encode. Must be a space separated list of key/value
    pairs separated by equals (=) sign.rnargsrfuncrz'use to decode a supplied JSON web tokenrzJSON web token to decode.?z-nz--no-verifyZstore_falser!Tz2ignore signature and claims verification on decode)	argparseArgumentParseradd_argumentrZadd_subparsersZ
add_parserZset_defaultsr r,)r.
arg_parserZ
subparsersZ
encode_parserZpayload_helpZ
decode_parserrrrbuild_argparserJsR						r>cCst}y9|jtjdd}|j|}t|Wn<tk
r}ztd||jWYdd}~XnXdS)NrzThere was an unforseen error: )r>
parse_argsr"argvr8print	ExceptionZ
print_help)r=Z	argumentsoutputr+rrrmains	
rD)Z
__future__rrr:r(r"rrrrrr r,r>rDrrrr<module>s"*S
Back to Directory File Manager