Initial commit
This commit is contained in:
37
functions/jwtd.fish
Normal file
37
functions/jwtd.fish
Normal file
@@ -0,0 +1,37 @@
|
||||
function jwtd
|
||||
if test (count $argv) = 0
|
||||
echo "Usage: jwtd TOKEN" >/dev/stderr
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
if test -z (command -v jq); or test ! -x (command -v jq)
|
||||
echo "jq is not installed" >/dev/stderr
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
echo "# HEADERS"
|
||||
echo "$argv[1]" | jq -R 'split(".") | .[0] | @base64d | fromjson'
|
||||
echo ""
|
||||
|
||||
set body (echo "$argv[1]" | jq -R 'split(".") | .[1] | @base64d | fromjson')
|
||||
set timestamp (echo $body | jq -r '.exp')
|
||||
echo "# BODY"
|
||||
echo $body | jq
|
||||
echo ""
|
||||
|
||||
if test -n "$timestamp" -a "$timestamp" != null
|
||||
if test "$timestamp" -lt (date +"%s")
|
||||
echo -n "EXPIRED at: "
|
||||
else
|
||||
echo -n "Expires: "
|
||||
end
|
||||
|
||||
date --date="@$timestamp"
|
||||
else
|
||||
echo "NEVER EXPIRES!"
|
||||
end
|
||||
|
||||
echo "$argv[1]" | awk -F. '{print "Signature: " $3}'
|
||||
end
|
Reference in New Issue
Block a user