t_jwt 1.0.0 copy "t_jwt: ^1.0.0" to clipboard
t_jwt: ^1.0.0 copied to clipboard

outdated

A simple library for signing and verifying JWTs in Dart lang.

Is this library safe for production? #

Not yet. This will be updated when it eventually is tested and verified by a third-party. Some features are entirely unfinished or not working.

What is a JWT? #

JWT stands for JSON Web Token, which is a compact and secure way to transmit data between parties in a JSON format. JWTs are used for authentication and authorization purposes and consist of three parts: a header, a payload, and a signature. The header contains information about the algorithm used to sign the token, the payload contains the user's data or claims, and the signature is used to verify the token's authenticity. JWTs are commonly used in web applications, APIs, and mobile applications.

A JWT Looks roughly like: xxxxx.yyyyy.zzzzz

Getting started #

import 'package:t_jwt/t_jwt.dart';

void main() {
  var jwt = JWT();

  var header = {
    'alg': 'HS256',
    'typ': 'JWT'
  };

  var 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);

  print(signed);
  print(isVerified);
}
copied to clipboard
1
likes
140
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.16 - 2025.03.31

A simple library for signing and verifying JWTs in Dart lang.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

crypto

More

Packages that depend on t_jwt