google/webcrypto.dart

AesGcmSecretKey.importRawKey on Chrome - Expected a value of type 'CryptoKey' (in null), but got one of type 'CryptoKey'

Closed this issue · 1 comments

I am having problem with importing raw key on a web project.

This is the code:

final key = base64Decode("iP4P+MTq9GjUzZ2amDFmJIj+D/jE6vRo1M2dmpgxZiQ=");
final webkey = await AesGcmSecretKey.importRawKey(key);

and fails with:

Error: Expected a value of type 'CryptoKey' (in null), but got one of type 'CryptoKey' (in dart:html)
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 99:3        castError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 226:34       as
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 201:40  _argumentErrors
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39  dcall

Tried to run this on a different project and works just fine.

I guess there must be something specific in my project which conflicts with AesGcmSecretKey, but not really sure how to find it out.

Do you have any ideas where to start?

Right, so the issue was that my project loaded the older: webcrypto: ^0.5.2 automatically instead of: webcrypto: ^0.5.3, because of the other lib requiring ffi: 1.x.x.
In my case forcing: ffi: ^2.0.0 in dependency_overrides resolved the issue.