パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.3.1

jwt_decode

JSON Web Token をデコードし、有効期限を確認して提供する簡単な Dart パッケージ

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
69.7万
いいね数
123
Pub ポイント
150

パッケージをインストール

flutter pub add jwt_decode

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

JSON Web タイクン (JWT) をデコードするためのシンプルな Dart パッケージで、ペイロードデータへの簡単なアクセスと有効期限の検証を可能にします。Android、iOS、Web、macOS、Windows、Linux など複数のプラットフォームで JWT のパースをサポートしています。認証システムや API インテグレーションなど、セキュアなトークン処理が必要なアプリケーションに最適です。`flutter pub add jwt_decode` による最小限の設定で、開発者は迅速に宣言を抽出し、トークンの有効性を検証できます。

用途

  • 認証ワークフロー
  • APIトークンの検証
  • ユーザー セッション管理
  • セキュアなデータ交換
  • トークン有効期限のチェック

主な機能

  • JWTのデコードを簡単に
  • 有効期限の検証
  • クロスプラットフォーム対応
  • 最小限のセットアップ
  • ペイロードクレーム抽出

適している対象

  • モバイルアプリ開発者
  • Webアプリケーションビルダー
  • バックエンドサービス統合者
  • セキュリティに焦点を当てたプロジェクト
  • 認証システムの実装者

注意事項

  • 署名を検証しません
  • セキュリティのための外部検証が必要です
  • デコードに限定され、署名は不可
  • 追加のチェックなしでは本番環境での使用は適していません
  • 正しいトークン形式に依存しています

元の 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.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト