diff --git a/lib/src/jwk.dart b/lib/src/jwk.dart index 739e558..866bcd9 100644 --- a/lib/src/jwk.dart +++ b/lib/src/jwk.dart @@ -231,7 +231,7 @@ class JsonWebKey extends JsonObject { /// /// Other values MAY be used. Set? get keyOperations => - getTypedList('key_ops')?.toSet() as Set?; + getTypedList('key_ops')?.toSet() as Set?; /// The algorithm intended for use with the key. String? get algorithm => this['alg']; @@ -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 @@ -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 @@ -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 @@ -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; } @@ -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), @@ -416,7 +416,7 @@ class JsonWebKey extends JsonObject { class JsonWebKeySet extends JsonObject { /// An array of JWK values List get keys => - getTypedList('keys', factory: (v) => JsonWebKey.fromJson(v)) ?? const []; + getTypedList('keys', factory: (v) => JsonWebKey.fromJson(v)) ?? const []; /// Constructs a [JsonWebKeySet] from the list of [keys] factory JsonWebKeySet.fromKeys(Iterable keys) =>