v2.0.1
jwt_decoder
이 작은 라이브러리는 JSON 웹 토큰을 디코딩하는 데 도움을 주며, JWT가 이미 만료되었는지 여부를 확인할 수도 있습니다.
552좋아요 57.2만30일 다운로드160Pub 점수
AndroidiOSWebmacOSWindowsLinux
Dart/Flutter용 JSON 웹 토큰 디코더
^1.25.8아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
This is a small library for decoding a json web token for dart / flutter. Since the header and payload is base64 encoded you can easily know the stored data with no password, you can also know if the token is expired or not.
If you like this library there's a version for Vue here. And for React here
main () {
String yourToken = "Your JWT";
Map<String, dynamic> decodedToken = JwtDecoder.decode(yourToken);
/*
If the token has a valid format, you will get a Map<String, dynamic>
Your decoded token can look like:
{
"sub": "1234567890",
"name": "Gustavo",
"iat": 1516239022,
"exp": 1516239022,
"randomKey": "something else"
}
*/
}
main () {
String yourToken = "Your JWT";
bool hasExpired = JwtDecoder.isExpired(yourToken);
// You will get a true / false response
// true: if the token is already expired
// false: if the token is not expired
}
main () {
String yourToken = "Your JWT";
DateTime expirationDate = JwtDecoder.getExpirationDate(token);
// 2025-01-13 13:04:18.000
print(expirationDate);
}
// Token payload must include an 'iat' field
main () {
String yourToken = "Your JWT";
Duration tokenTime = JwtDecoder.getTokenTime(token);
// 15
print(tokenTime.inDays);
}
MIT