jaguar_jwt 2.1.5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 90

Build Status

jaguar_jwt

JWT utilities for Dart and Jaguar.dart

Usage

Issuing JWT token

  final key = 'dfsdffasdfdgdfgdfg456456456';
  final claimSet = new JwtClaim(
      subject: 'kleak',
      issuer: 'teja',
      audience: <String>['example.com', 'hello.com'],
      payload: {'k': 'v'});
  String token = issueJwtHS256(claimSet, key);
  print(token);

Decoding JWT token

  final JwtClaim decClaimSet = verifyJwtHS256Signature(token, key);
  print(decClaimSet.toJson());

Validating JWT token

  decClaimSet.validate(issuer: 'teja', audience: 'hello.com');

Configuration

JwtClaimSet

JwtClaimSet is the model to holds JWT claim set information. To issue a JWT token, it needs:

  1. issuer
    Authority issuing the token. This will be used during authorization to verify that expected issuer has issued the token. Fills the iss field of the JWT token.
  2. Subject
    Subject of the JWT token. Usually stores the user ID of the user to which the token is issued. Fills the sub field of the JWT token.
  3. audience
    List of audience that accept this token. This will be used during authorization to verify that JWT token has expected audience for the service. Fills aud field in JWT token.
  4. expiry
    Time at which the token expires. Fills exp field in JWT token.
  5. jwtId
    Unique identifier across services that identifies the token. Fills jti field in JWT token.

Changelog

  • 2.1.2

  • Fixed when typ is not present

2.1.1

  • Dart 2 compatibility

example/example.dart

library jaguar_jwt.example;

import 'package:jaguar_jwt/jaguar_jwt.dart';

void main() {
  final key = 'dfsdffasdfdgdfgdfg456456456';
  final claimSet = new JwtClaim(
      subject: 'kleak',
      issuer: 'teja',
      audience: <String>['example.com', 'hello.com'],
      payload: {'k': 'v'});
  String token = issueJwtHS256(claimSet, key);
  print(token);

  final JwtClaim decClaimSet = verifyJwtHS256Signature(token, key);
  print(decClaimSet.toJson());

  decClaimSet.validate(issuer: 'teja', audience: 'hello.com');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jaguar_jwt: ^2.1.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jaguar_jwt/jaguar_jwt.dart';
  
Version Uploaded Documentation Archive
2.1.5 Aug 24, 2018 Go to the documentation of jaguar_jwt 2.1.5 Download jaguar_jwt 2.1.5 archive
2.1.4 Aug 7, 2018 Go to the documentation of jaguar_jwt 2.1.4 Download jaguar_jwt 2.1.4 archive
2.1.2 Jul 31, 2018 Go to the documentation of jaguar_jwt 2.1.2 Download jaguar_jwt 2.1.2 archive
2.1.1 Jul 11, 2018 Go to the documentation of jaguar_jwt 2.1.1 Download jaguar_jwt 2.1.1 archive
1.1.5 Feb 2, 2018 Go to the documentation of jaguar_jwt 1.1.5 Download jaguar_jwt 1.1.5 archive
0.3.9 Feb 2, 2018 Go to the documentation of jaguar_jwt 0.3.9 Download jaguar_jwt 0.3.9 archive
0.3.8 Feb 2, 2018 Go to the documentation of jaguar_jwt 0.3.8 Download jaguar_jwt 0.3.8 archive
0.3.7 Feb 2, 2018 Go to the documentation of jaguar_jwt 0.3.7 Download jaguar_jwt 0.3.7 archive
0.3.6 Feb 2, 2018 Go to the documentation of jaguar_jwt 0.3.6 Download jaguar_jwt 0.3.6 archive
0.3.5 Nov 4, 2017 Go to the documentation of jaguar_jwt 0.3.5 Download jaguar_jwt 0.3.5 archive

All 18 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
81
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:jaguar_jwt/jaguar_jwt.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.65 <3.0.0
auth_header ^2.1.1 2.1.2
crypto ^2.0.5 2.0.6
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.0.2
typed_data 1.1.6
Dev dependencies
test ^1.3.0