Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions example/jose_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Future<void> example2() async {
algorithm: 'HS256');

// build the jws
var jws = builder.build();
var jws = await builder.build();

// output the compact serialization
print('jws compact serialization: ${jws.toCompactSerialization()}');
Expand Down Expand Up @@ -189,7 +189,7 @@ Future<void> example4() async {
builder.encryptionAlgorithm = 'A128CBC-HS256';

// build the jws
var jwe = builder.build();
var jwe = await builder.build();

// output the compact serialization
print('jwe compact serialization: ${jwe.toCompactSerialization()}');
Expand Down Expand Up @@ -257,7 +257,7 @@ Future<void> example6() async {
algorithm: 'HS256');

// build the jws
var jws = builder.build();
var jws = await builder.build();

// output the compact serialization
print('jwt compact serialization: ${jws.toCompactSerialization()}');
Expand Down Expand Up @@ -289,7 +289,7 @@ Future<void> example7() async {
builder.addRecipient(key, algorithm: 'RS512');

// build the jws
var jws = builder.build();
var jws = await builder.build();

// output the compact serialization
print('jwt compact serialization: ${jws.toCompactSerialization()}');
Expand All @@ -304,7 +304,7 @@ Future<void> example8() async {

final hash = utf8.encode('TEST');

var sig = key.sign(hash);
var sig = await key.sign(hash);
final valid = key.verify(hash, sig);

print('valid? $valid');
Expand Down Expand Up @@ -411,7 +411,7 @@ Future<void> example10() async {
builder.compressionAlgorithm = 'DEF';

// build the jws
var jwe = builder.build();
var jwe = await builder.build();

// output the compact serialization
print('jwe compact serialization: ${jwe.toCompactSerialization()}');
Expand Down
4 changes: 1 addition & 3 deletions lib/src/jwk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import 'package:http_parser/http_parser.dart';
import 'package:jose/src/jwa.dart';
import 'package:meta/meta.dart';
import 'package:x509/x509.dart' as x509;
import 'package:pointycastle/ecc/ecdh.dart' as ecdh;
import 'package:pointycastle/pointycastle.dart' as ecdh;
import 'package:pointycastle/ecc/api.dart' as ecdh;
import 'package:pointycastle/ecc/curves/brainpoolp256r1.dart' as ecdh;
import 'package:pointycastle/digests/sha256.dart' as ecdh;

import 'jose.dart';
Expand Down Expand Up @@ -262,6 +259,7 @@ class JsonWebKey extends JsonObject {
}

return alg
// ignore: invalid_use_of_visible_for_testing_member
.jwkFromCryptoKeyPair(KeyPair.symmetric(SymmetricKey(keyValue: key)));
}

Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ homepage: https://github.com/appsup-dart/jose
repository: https://github.com/appsup-dart/jose
funding:
- https://github.com/sponsors/rbellens
publish_to: 'none'

environment:
sdk: ^3.0.0
Expand All @@ -25,6 +26,7 @@ dependencies:
asn1lib: ^1.0.0
collection: ^1.15.0
archive: '>=3.6.1 <5.0.0'
pointycastle: ^3.9.1

dev_dependencies:
test: ^1.24.4
Expand Down
3 changes: 2 additions & 1 deletion test/jwe_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ DwwoHgQL4BQ6fCuuc26m93ClRTrYqjo418x5fDMyvr7KWkIMwVU6xcWJNg==
final compactJwt =
"eyJhbGciOiJFQ0RILUVTIiwidHlwIjoiSldUIiwiZW5jIjoiQTI1NkdDTSIsImVwayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwieCI6Ill0aDdLTUhUYzNFUUQwUHpnZ0FiN29fSDFadlFnQzFUOGdjMS1rZjFTanMiLCJ5IjoiQXZIeHF1T3RGZ1ZveHNYUHFjWGpfWjZhMDBDY0ZFMzJpRjdiY3hVZGFqdyJ9fQ..5pjvf-Iu4tII5jqf.5j3HuDUfDF4NryaG78Ib5Mpsp_bB4tfWiyffc07rzJZufR7bczu8PbNxpOCZGrTczdJR6I6nCfoe6uQRg7xw3D-4ARBVggs04bWhkt-QFLXMJ-k8_QLH6FER5ALUbw.cP7kgs48KkNoBPH6pn_YEA";

// ignore: unused_local_variable
final header = """{
"alg": "ECDH-ES",
"typ": "JWT",
Expand Down Expand Up @@ -398,7 +399,7 @@ DwwoHgQL4BQ6fCuuc26m93ClRTrYqjo418x5fDMyvr7KWkIMwVU6xcWJNg==
final secret = JsonWebKey.generateECDH('A256GCM',
publicKey: publicKey, privateKey: privateKey);

print("payload ${secret}");
print("payload $secret");

// should be: 86c7d0c862e836a999b537df8542ab91d5788514669edc9de916dd3f77d52a71ce9fa5e476205ee167a757523cc2c6813a9e4730e3b3b0c1588ff720425b3f6a4a
});
Expand Down