Created
July 19, 2022 15:42
-
-
Save slauzinho/7f251917bfbd11f9ee2ec0e02967ef01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
import jwtDecode from "jwt-decode"; | |
const token = | |
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkdXJnYSIsImV4cCI6MTY1OTk1NTI4NSwiaWF0IjoxNjU3NTM2MDg1LCJpc3MiOiJkdXJnYSIsImp0aSI6IjI2OTk1NWQyLTQwMzAtNGFkZS05YTgxLTg5MDg0NjQ1NTQwZSIsIm5iZiI6MTY1NzUzNjA4NCwic3ViIjoiMiIsInR5cCI6ImFjY2VzcyJ9.qWI5umsmYubVu1bSvje-nT9gUSi0PphsPnyWiY8_PDTYHHF-ATSNvsD2hZpUad7AgluUE-i1S103-GYiKkf6Ag"; | |
interface JWTPayload { | |
aud: string; | |
exp: number; | |
iat: number; | |
iss: string; | |
jti: string; | |
nbf: number; | |
sub: string; | |
type: string; | |
} | |
const decoded = jwtDecode<JWTPayload>(token); | |
console.log(`decoded:`, decoded.sub); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment