start_jwt 0.2.0 copy "start_jwt: ^0.2.0" to clipboard
start_jwt: ^0.2.0 copied to clipboard

JSON Web Token implemented as a standard Dart codec.

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:start_jwt/json_web_token.dart';

void main() {

    // 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);
    print ("Payload : " + payload.toString());
    
    // Validate a token.
    
    jwt.isValid(token);
    
    // Decode (i.e. extract) the payload from a JWT token.
    
    final decoded = jwt.decode(token);
    print ("Decoded : " + decoded.toString());
}

Status #

The API is very simple. 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.

Copyright (c) 2019 JarrodCColburn at https://github.com/JarrodCColburn.

Copyright (c) 2020 Benjamin Jung bsjung@gmail.com.

2
likes
10
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

JSON Web Token implemented as a standard Dart codec.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

crypto, cryptoutils

More

Packages that depend on start_jwt