diff --git a/cryptography/lib/src/browser/_javascript_bindings.dart b/cryptography/lib/src/browser/_javascript_bindings.dart index 95caede..c244c48 100644 --- a/cryptography/lib/src/browser/_javascript_bindings.dart +++ b/cryptography/lib/src/browser/_javascript_bindings.dart @@ -24,10 +24,10 @@ import 'package:meta/meta.dart'; /// Note that browsers support Web Cryptography only in secure contexts. @internal final bool isWebCryptoAvailable = - _subtle.isDefinedAndNotNull && _isSecureContext.toDart; + _subtle.isDefinedAndNotNull && (_isSecureContext?.toDart ?? false); -@JS('window.isSecureContext') -external JSBoolean get _isSecureContext; +@JS('isSecureContext') +external JSBoolean? get _isSecureContext; @JS('crypto.subtle') external JSAny get _subtle; diff --git a/cryptography/lib/src/cryptography/secret_key.dart b/cryptography/lib/src/cryptography/secret_key.dart index 88f5264..ab085e0 100644 --- a/cryptography/lib/src/cryptography/secret_key.dart +++ b/cryptography/lib/src/cryptography/secret_key.dart @@ -106,7 +106,7 @@ class SecretKeyData extends SecretKey { /// Generates _N_ random bytes. /// /// A description of the random number generator: - /// * In browsers, `window.crypto.getRandomValues() is used directly. + /// * In browsers, `crypto.getRandomValues()` is used directly. /// * In other platforms, _dart:math_ [Random.secure()] is used. /// /// You can give a custom random number generator. This can be useful for diff --git a/cryptography/lib/src/helpers/random_bytes_impl_browser.dart b/cryptography/lib/src/helpers/random_bytes_impl_browser.dart index d1bde10..9bd850f 100644 --- a/cryptography/lib/src/helpers/random_bytes_impl_browser.dart +++ b/cryptography/lib/src/helpers/random_bytes_impl_browser.dart @@ -51,5 +51,5 @@ void fillBytesWithSecureRandom(Uint8List bytes, {Random? random}) { } } -@JS('window.crypto.getRandomValues') +@JS('crypto.getRandomValues') external void _webCryptoRandom(JSUint8Array buffer);