This commit is contained in:
Jonas Roussel
2020-05-31 18:38:13 +02:00
parent 420b56a996
commit 3377ae8b0b
7 changed files with 63 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:jsonwebtoken/jsonwebtoken.dart';
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
abstract class JWTAlgorithm {
static const HS256 = HS256Algorithm();

View File

@ -1,6 +1,6 @@
import 'dart:convert';
import 'package:jsonwebtoken/jsonwebtoken.dart';
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
import './utils.dart';
@ -39,8 +39,8 @@ class JWT {
issuer: payload.remove('iss'),
subject: payload.remove('sub'),
);
} on JWTError catch (ex) {
throw ex;
} on JWTError {
rethrow;
} catch (ex) {
throw JWTInvalidError('jwt invalid');
}
@ -61,7 +61,7 @@ class JWT {
String sign(
String key, {
JWTAlgorithm algorithm = JWTAlgorithm.HS256,
Duration expiresIn = null,
Duration expiresIn,
bool noTimestamp = false,
}) {
final header = {'alg': algorithm.name, 'typ': 'JWT'};