auth_jwt 0.2.0
auth_jwt: ^0.2.0 copied to clipboard
JWT 기반 인증 관리 패키지. Dio·GraphQL(gql) 연동으로 여러 Flutter 프로젝트에서 재사용 가능.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased #
0.2.0 - 2025-03-16 #
Added #
-
JWT 디코딩 유틸
decodeJwtPayload(String token)함수를 패키지에서 export.- payload를 서명 검증 없이 디코딩해
Map<String, dynamic>?로 반환. - exp, sub 등 클레임 조회용.
-
로그아웃 시 서버 호출
AuthOptions.logoutCallback:LogoutCallback?추가.logout()호출 시, 토큰 삭제 전에logoutCallback(accessToken)호출.- 서버 로그아웃 API(예: POST /auth/logout with Bearer)를 콜백에서 호출 가능.
-
예제 앱
- GraphQL 연동 예시 추가 (authLink + HttpLink, countries API 쿼리).
- JWT payload 미리보기 (decodeJwtPayload 사용).
- logoutCallback 사용 예시.
-
테스트
decodeJwtPayload테스트 (test/jwt_decode_test.dart).logoutCallback호출 여부 및 null 시 동작 테스트 (test/logout_callback_test.dart).- 토큰 만료 시 갱신 트리거, 갱신 실패 시 로그아웃 테스트 (
test/refresh_test.dart).
-
문서
- README 전면 정리: 기능 목록, 설치, 사용법, 저장소 구현, API 요약.
docs/API.md: 공개 API 요약 및 사용 예.- 주요 공개 타입에 dartdoc 주석 보강.
Changed #
- (없음)
Fixed #
- (없음)
0.1.0 - 2025-03-16 #
Added #
- 초기 릴리스.
AuthManager: 초기화, setTokens, logout, getValidAccessToken, authStateStream.AuthStorage인터페이스 및MemoryAuthStorage.AuthState: unauthenticated, authenticated, expired, refreshing.- 토큰 갱신: TokenRefreshRunner, 동시 갱신 방지.
- Dio 인터셉터: Bearer 추가, 401 시 갱신 후 재시도.
- GraphQL Auth Link: Bearer 헤더, 401 시 갱신 후 재요청.
- 예제 앱 (Dio 연동).
- 기본 테스트.