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
2 changes: 1 addition & 1 deletion .github/workflows/chrome.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
run: dart pub get

- name: Test chrome
run: dart test -j 1 -p chrome
run: dart test --timeout 2x -j 1 -p chrome
13 changes: 11 additions & 2 deletions lib/src/platform_check/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ class PlatformWeb extends Platform {
static bool useBuiltInRng = false;

PlatformWeb() {
useBuiltInRng = false;
try {
Random.secure();
useBuiltInRng = true;
} on UnsupportedError {
useBuiltInRng = false;
// Random.secure() normally throws this error if
// no cryptographically secure random number source is available.
} catch (e) {
// For Node.js with dart2js compiler, the UnknownJsTypeError error is expected.
// This error is internal to 'dart:_js_helper' so we need to inspect the runtimeType.
if (!(e.runtimeType.toString() == 'UnknownJsTypeError')) {
rethrow;
}
}
}

Expand Down Expand Up @@ -48,7 +56,8 @@ class _JsBuiltInEntropySource implements EntropySource {
@override
Uint8List getBytes(int len) {
return Uint8List.fromList(
List<int>.generate(len, (i) => _src.nextInt(256)));
List<int>.generate(len, (i) => _src.nextInt(256)),
);
}
}

Expand Down