ivmjwt 0.1.5 copy "ivmjwt: ^0.1.5" to clipboard
ivmjwt: ^0.1.5 copied to clipboard

This library is designed to work with JWT (RFC7519). The primerary purpose is issue and verify tokens signed RSA (SHA-256)

example/example.dart

import 'dart:convert';
import 'package:ivmjwt/ivmjwt.dart';

/// Create new, RS256 signed JWT
///
Future<void> issue() async {
  /// The token expire time is composed based on a property from claims "maxAge"
  /// If this property  is missing it will default to 3600. If the claims has
  /// the 'exp' key - its value will be used directly instead of calculating it
  /// from maxAge.
  final _claims = json.decode(
          '{\"iss\": \"Ivmanto.com\", \"maxAge\": 7200, \"ivmanto\": \"dev\"}')
      as Map<String, dynamic>;

  /// Instantiate segment payload and ivmJWT objects
  final segmentPayload = SegmentPayload.fromJson(_claims);
  final ivmjwt = IvmJWT(segmentPayload);

  /// call the issue method for RS256 signed token creation.
  final result = await ivmjwt.issueJWTRS256();

  /// Consume the result
  ///
  /// Expected result format
  /// ```json
  /// {"token": "xxx", "publicKey": {"keys":[]}}
  ///```
  ///
  print(result);
}

/// Verify RS256 signed JWT
///
void verify() async {
  const token = 'token_value';
  const jwks = '{"keys": []}';

  /// Expect bool if the token is valid or not
  final result = await IvmJWT.decodeJWTRS256(token, jwks);
  print(result);
}
0
likes
40
pub points
0%
popularity

Publisher

verified publisherivmanto.com

This library is designed to work with JWT (RFC7519). The primerary purpose is issue and verify tokens signed RSA (SHA-256)

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

ivmjv, json_annotation, meta, pointycastle, uuid_type

More

Packages that depend on ivmjwt