Skip to content

Commit

Permalink
fix: type mismatch error on keyOperations getter (pull request #37 fr…
Browse files Browse the repository at this point in the history
…om samataro)

Fixed type mismatch error on keyOperations getter
  • Loading branch information
rbellens authored Oct 16, 2022
2 parents b8d11f3 + c6b4c5e commit 8afde0f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/src/jwk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class JsonWebKey extends JsonObject {
///
/// Other values MAY be used.
Set<String>? get keyOperations =>
getTypedList('key_ops')?.toSet() as Set<String>?;
getTypedList<String>('key_ops')?.toSet() as Set<String>?;

/// The algorithm intended for use with the key.
String? get algorithm => this['alg'];
Expand Down Expand Up @@ -279,7 +279,7 @@ class JsonWebKey extends JsonObject {
_assertCanDo('verify');
var verifier = _keyPair.publicKey!.createVerifier(_getAlgorithm(algorithm));
return verifier.verify(
data as Uint8List, Signature(signature as Uint8List));
Uint8List.fromList(data), Signature(Uint8List.fromList(signature)));
}

/// Encrypt content
Expand All @@ -291,9 +291,9 @@ class JsonWebKey extends JsonObject {
algorithm ??= this.algorithm;
var encrypter =
_keyPair.publicKey!.createEncrypter(_getAlgorithm(algorithm));
return encrypter.encrypt(data as Uint8List,
initializationVector: initializationVector as Uint8List?,
additionalAuthenticatedData: additionalAuthenticatedData as Uint8List?);
return encrypter.encrypt(Uint8List.fromList(data),
initializationVector: initializationVector != null ? Uint8List.fromList(initializationVector) : null,
additionalAuthenticatedData: additionalAuthenticatedData != null ? Uint8List.fromList(additionalAuthenticatedData) : null);
}

/// Decrypt content and validate decryption, if applicable
Expand All @@ -306,11 +306,11 @@ class JsonWebKey extends JsonObject {
algorithm ??= this.algorithm;
var decrypter =
_keyPair.privateKey!.createEncrypter(_getAlgorithm(algorithm));
return decrypter.decrypt(EncryptionResult(data as Uint8List,
initializationVector: initializationVector as Uint8List?,
authenticationTag: authenticationTag as Uint8List?,
return decrypter.decrypt(EncryptionResult(Uint8List.fromList(data),
initializationVector: initializationVector != null ? Uint8List.fromList(initializationVector) : null,
authenticationTag: authenticationTag != null ? Uint8List.fromList(authenticationTag) : null,
additionalAuthenticatedData:
additionalAuthenticatedData as Uint8List?));
additionalAuthenticatedData != null ? Uint8List.fromList(additionalAuthenticatedData) : null));
}

/// Encrypt key
Expand All @@ -322,7 +322,7 @@ class JsonWebKey extends JsonObject {
algorithm ??= this.algorithm;
var encrypter =
_keyPair.publicKey!.createEncrypter(_getAlgorithm(algorithm));
var v = encrypter.encrypt(decodeBase64EncodedBytes(key['k']) as Uint8List);
var v = encrypter.encrypt(Uint8List.fromList(decodeBase64EncodedBytes(key['k'])));
return v.data;
}

Expand All @@ -332,7 +332,7 @@ class JsonWebKey extends JsonObject {
algorithm ??= this.algorithm;
var decrypter =
_keyPair.privateKey!.createEncrypter(_getAlgorithm(algorithm));
var v = decrypter.decrypt(EncryptionResult(data as Uint8List));
var v = decrypter.decrypt(EncryptionResult(Uint8List.fromList(data)));
return JsonWebKey.fromJson({
'kty': 'oct',
'k': encodeBase64EncodedBytes(v),
Expand Down Expand Up @@ -416,7 +416,7 @@ class JsonWebKey extends JsonObject {
class JsonWebKeySet extends JsonObject {
/// An array of JWK values
List<JsonWebKey> get keys =>
getTypedList('keys', factory: (v) => JsonWebKey.fromJson(v)) ?? const [];
getTypedList<JsonWebKey>('keys', factory: (v) => JsonWebKey.fromJson(v)) ?? const [];

/// Constructs a [JsonWebKeySet] from the list of [keys]
factory JsonWebKeySet.fromKeys(Iterable<JsonWebKey> keys) =>
Expand Down

0 comments on commit 8afde0f

Please sign in to comment.