Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Dart 2.0 updates #7

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Dart 2.0 updates
  • Loading branch information
shamblett committed Oct 1, 2018
commit d4d2c4bf26d7d4179687058615fda6b4218c4dc3
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.0.0

- Dart 2.0 updates

# 1.1.0

## 1.0.0

- Initial version
Expand Down
11 changes: 5 additions & 6 deletions lib/src/algorithms/rs256.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ library just_jwt.algorithms.rs256;
import 'dart:convert';
import 'dart:typed_data';

import 'package:bignum/bignum.dart';
import 'package:pointycastle/pointycastle.dart' as pointy;
import 'package:pointycastle/src/impl/secure_random_base.dart';
import 'package:pointycastle/src/registry/factory_config.dart';
import 'package:pointycastle/src/registry/registry.dart';
import 'package:pointycastle/src/ufixnum.dart';
import 'package:rsa_pkcs/rsa_pkcs.dart';

Expand All @@ -31,7 +30,7 @@ Signer createRS256Signer(String pem) {

return (String toSign) {
var message = new Uint8List.fromList(toSign.codeUnits);
return signer.generateSignature(message).bytes;
return signer.generateSignature(message);
};
}

Expand All @@ -46,7 +45,7 @@ Verifier createRS256Verifier(String pem) {
var rawKey = pair.public;
if (rawKey == null) throw new ArgumentError.value(pem, 'publicPem', 'Public PEM is not valid!');

var publicKey = new pointy.RSAPublicKey(rawKey.modulus, new BigInteger(rawKey.publicExponent));
var publicKey = new pointy.RSAPublicKey(rawKey.modulus, new BigInt(rawKey.publicExponent));
return _createVerifier(publicKey);
}

Expand All @@ -55,8 +54,8 @@ Verifier createRS256Verifier(String pem) {
/// Parameters are Base64urlUInt-encoded values as described in:
/// RFC 7518 - JSON WEB Algorithms (https://tools.ietf.org/html/rfc7518#section-6.3)
Verifier createJwaRS256Verifier(String encodedModulus, String encodedExponent) {
var n = new BigInteger.fromBytes(1, BASE64.decode(encodedModulus));
var e = new BigInteger.fromBytes(1, BASE64.decode(encodedExponent));
var n = new BigInt.fromBytes(1, BASE64.decode(encodedModulus));
var e = new BigInt.fromBytes(1, BASE64.decode(encodedExponent));
var publicKey = new pointy.RSAPublicKey(n, e);

return _createVerifier(publicKey);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/signatures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ library just_jwt.signatures;
typedef bool Verifier(String message, List<int> signature);

/// Returns a signature of the [message].
typedef List<int> Signer(String message);
typedef Signature Signer(String message);
14 changes: 8 additions & 6 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: just_jwt
description: A JWT library for Dart.
version: 1.3.1
version: 2.0.0
author: Tomas Szabo <[email protected]>
homepage: https://github.com/deftomat/JustJWT

environment:
sdk: '>=1.16.0 <2.0.0'
sdk: '>=2.0.0-dev <3.0.0'

dependencies:
crypto: '^2.0.1'
pointycastle: '^0.10.0'
rsa_pkcs: '^0.1.2'
collection: '^1.9.1'
pointycastle:
git: git://github.com/PointyCastle/pointycastle.git
rsa_pkcs:
git: git://github.com/amaurel/rsa_pkcs.git
collection: '^1.14.11'

dev_dependencies:
test: '^0.12.15'
test: '^1.3.4'