Skip to content
pubscout

corsac_jwt

2.0.2, released a year ago by memspace.app

Lightweight implementation of JSON Web Tokens (JWT) for Dart and Flutter.

WASM-ready
$ flutter pub add corsac_jwt
Source repository

What it does

Allows you to create, sign, parse, and validate JSON Web Tokens (JWT) using various algorithms like HS256, RS256, and ES256. It provides builders for claims and tools to verify token signatures and validate standard claims such as expiration and issuer.

AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to generate and sign JWTs in your Dart backend or client application.
  • You need to parse and verify incoming JWT signatures and validate their claims.

Skip it when

  • You require complex auth provider integrations (like Firebase or OAuth client flows) rather than raw token handling.

Strengths

  • Supports multiple signing algorithms (HS256, RS256, ES256).
  • Lightweight and straightforward API for building, signing, and validating tokens.

Weaknesses

  • Relies on manual verification and claim validation logic compared to full authentication SDKs.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4
import 'package:corsac_jwt/corsac_jwt.dart';

void main() {
  var builder = new JWTBuilder();
  var token = builder
    ..issuer = 'https://api.foobar.com'
    ..expiresAt = new DateTime.now().add(new Duration(minutes: 3))
    ..setClaim('data', {'userId': 836})
    ..getToken();

  var signer = new JWTHmacSha256Signer('sharedSecret');
  var signedToken = builder.getSignedToken(signer);
  var decodedToken = new JWT.parse(signedToken.toString());
  print(decodedToken.verify(signer));
}

Alternatives

Packages that do the same job and could replace corsac_jwt.

Works with

Packages commonly used together with corsac_jwt: ones it builds on, ones built on it, and its own family.