패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.3.1

jwt_decode

JSON 웹 토큰을 디코딩하고 만료일을 확인 및 제공하는 간단한 Dart 패키지

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
69.7만
좋아요
123
Pub 점수
150

패키지 설치

flutter pub add jwt_decode

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

JSON 웹 토큰(JWT)을 디코딩하기 위한 간단한 Dart 패키지로, 페이로드 데이터에 쉽게 접근하고 만료 날짜를 검증할 수 있습니다. Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼에서 JWT를 파싱하는 것을 지원합니다. 인증 시스템이나 API 통합과 같이 안전한 토큰 처리가 필요한 애플리케이션에 적합합니다. `flutter pub add jwt_decode`를 통해 최소한의 설정으로 개발자는 빠르게 클레임을 추출하고 토큰의 유효성을 검증할 수 있습니다.

사용 사례

  • 인증 워크플로우
  • API 토큰 검증
  • 사용자 세션 관리
  • 안전한 데이터 교환
  • 토큰 만료 확인

주요 기능

  • 간편한 JWT 디코딩
  • 유효 기간 검증
  • 크로스 플랫폼 지원
  • 최소 설정
  • 페이로드 클레임 추출

적합한 대상

  • 모바일 앱 개발자
  • 웹 애플리케이션 빌더
  • 백엔드 서비스 통합자
  • 보안 중심 프로젝트
  • 인증 시스템 구현자

고려 사항

  • 서명을 검증하지 않습니다
  • 보안을 위해 외부 검증이 필요합니다
  • 디코딩에 한정됨, 서명은 불가
  • 추가 검사 없이 생산에 적합하지 않습니다
  • 올바른 토큰 형식에 따라 다릅니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

jwt_decode

jwt_decode is a lightweight library for decoding JSON Web Tokens (JWTs) in Dart.

IMPORTANT: This library does not validate the tokens. It can decode any well-formed ones.

Installation

Add jwt_decode to your project's pubspec.yaml file:

dependencies:
  jwt_decode: ^0.3.1

Then run flutter pub get to install the package.

Using

Here's an example of how to use jwt_decode to decode a JWT:

import 'package:jwt_decode/jwt_decode.dart';

void main() {
  final String token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
  final Map<String, dynamic> decodedToken = Jwt.parseJwt(token);
  print(decodedToken);
}

This will output the following:

{
  "sub": "1234567890",
  "name": "John Doe",
  "iat": 1516239022,
  "exp": 1516239022
}

API Reference

Jwt.parseJwt(String token)

Parses the given JWT and returns a map containing the token's claims.

Jwt.getExpiryDate(String token)

Parses the given JWT and returns the DateTime object containing the token's expiry date if the token is valid and null if not.

Jwt.isExpired(String token)

Parses the given JWT and returns true if the token is still valid, and false otherwise.

Contributing

Contributions are welcome! Please see our Contributing Guidelines for more information.

License

jwt_decode is licensed under the BSD 3-clause license.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트