jaguar_jwt 1.1.5

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

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

0.3.9

  • Fixed expiry being offset rather than time

0.3.7

  • Fixed bug regarding expiry comparing with local time

0.3.6

  • Fixed bug regarding signatures without padding

0.3.5

  • All times are in UTC

0.3.4

  • Fixed iat (issued at) field

0.3.0

  • Simplified interface!
  • issueJwtHS256 function to issue a JWT HS256 based token
  • verifyJwtHS256Signature to verify the signature and structure of JWT token

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: "^1.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
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
0.3.4 Nov 4, 2017 Go to the documentation of jaguar_jwt 0.3.4 Download jaguar_jwt 0.3.4 archive
0.3.3 Jul 15, 2017 Go to the documentation of jaguar_jwt 0.3.3 Download jaguar_jwt 0.3.3 archive
0.3.2 Jul 15, 2017 Go to the documentation of jaguar_jwt 0.3.2 Download jaguar_jwt 0.3.2 archive
0.3.1 Jul 15, 2017 Go to the documentation of jaguar_jwt 0.3.1 Download jaguar_jwt 0.3.1 archive

All 14 versions...

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 11 hints.

    Strong-mode analysis of lib/src/jaguar_jwt.dart gave the following hint:

    line: 170 col: 31
    'BASE64URL' is deprecated and shouldn't be used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.0 <3.0.0
auth_header >=0.0.2 <0.1.0 0.0.3
crypto >=2.0.1 <3.0.0 2.0.5
Transitive dependencies
charcode 1.1.1
collection 1.14.10
convert 2.0.1
typed_data 1.1.5
Dev dependencies
test >=0.12.0 <0.13.0