Skip to content

TestOrg0373/t-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Json Web Token (JWT) library for Dart

Meant for usage in our web server library but also perfectly suitable for usage independently. File issues here and see pub.dev page here.

Limitations

  • Currently only supports HS256 algorithm
  • Not verified to be safe for production
  • Not 100% compliant with the JWT standard yet

Getting started

Add dependency

$ dart pub add t_jwt

or add it manually to your pubspec.yaml file:

dependencies:
  t_jwt: ^replace-with-latest-version

Example usage:

import 'package:t_jwt/t_jwt.dart';

void main() {
  JWT jwt = JWT('your-secret-here');

  Map<String, String> header = {
    'alg': 'HS256',
    'typ': 'JWT'
  };

  Map<String, String> payload = {
    'name': 'Topography Digital',
    'username': 'topography.digital',
  };

  DateTime expiresAt = DateTime.now().add(Duration(days: 1));

  String signed = jwt.sign(header, payload, expiresAt);

  bool isVerified = jwt.verify(signed);
  
  // The token
  print(signed);
  
  // True or false depending on if the token is valid
  print(isVerified);
}

About

A simple library for signing and verifying JWTs in Dart lang. Currently only supports HMAC-256.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages