jwt 0.1.4

  • README.md
  • Installing
  • Versions
  • 40

JSON Web Token

JSON Web Token (JWT) is a compact URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JavaScript Object Notation (JSON) object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or MACed and/or encrypted.

The JWT spec is implemented as a standard Dart Codec.

Example usage

import 'package:jwt/json_web_token.dart';

// Encode (i.e. sign) a payload into a JWT token.

final jwt = new JsonWebTokenCodec(secret: "My secret key");
final payload = {
  'iss': 'joe',
  'exp': 1300819380,
  'http://example.com/is_root': true
};
final token = jwt.encode(payload);

// Validate a token.

jwt.isValid(token);

// Decode (i.e. extract) the payload from a JWT token.

final payload = jwt.decode(token);

Status

The API is not stable. The intend is to strictly follow Dart conventions, i.e. make the API as 'dartish' as possible while maintaining simplicity. We are open to any suggestions towards that goal.

Credits

Copyright (c) 2014 George Moschovitis george.moschovitis@gmail.com.

Use this package as a library

1. Depend on it

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


dependencies:
  jwt: "^0.1.4"

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:jwt/base64.dart';

      import 'package:jwt/base64url.dart';

      import 'package:jwt/json_web_signature.dart';

      import 'package:jwt/json_web_token.dart';
  
Version Uploaded Documentation Archive
0.1.4 Mar 25, 2014 Go to the documentation of jwt 0.1.4 Download jwt 0.1.4 archive

Analysis

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

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1

Scores

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

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Use constrained dependencies.

    The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: crypto.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 18 errors 1 warning 11 hints.

    Strong-mode analysis of lib/base64.dart failed with the following error:

    line: 19 col: 3
    Invalid override. The type of 'Base64Encoder.convert' ('(List<int>) → String') isn't a subtype of 'Converter<dynamic, dynamic>.convert' ('(dynamic) → dynamic').

    Strong-mode analysis of lib/base64url.dart failed with the following error:

    line: 29 col: 3
    Invalid override. The type of 'Base64UrlEncoder.convert' ('(List<int>) → String') isn't a subtype of 'Converter<dynamic, dynamic>.convert' ('(dynamic) → dynamic').

    Similar analysis of the following files failed:

    • lib/json_web_signature.dart (error)
    • lib/json_web_token.dart (error)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use jwt.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
crypto any 2.0.3
Transitive dependencies
charcode 1.1.1
collection 1.14.9
convert 2.0.1
typed_data 1.1.5
Dev dependencies
unittest any