From bd481694cd608306e44b995f49ad7b9462388f91 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Thu, 19 Mar 2026 12:04:42 -0700 Subject: [PATCH 1/3] example: remove and ignore pubspec.lock --- .gitignore | 2 +- example/pubspec.lock | 549 ------------------------------------------- 2 files changed, 1 insertion(+), 550 deletions(-) delete mode 100644 example/pubspec.lock diff --git a/.gitignore b/.gitignore index 96486fd9..e420cab6 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,7 @@ migrate_working_dir/ # Flutter/Dart/Pub related # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock +pubspec.lock **/doc/api/ .dart_tool/ .packages diff --git a/example/pubspec.lock b/example/pubspec.lock deleted file mode 100644 index e619be81..00000000 --- a/example/pubspec.lock +++ /dev/null @@ -1,549 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 - url: "https://pub.dev" - source: hosted - version: "72.0.0" - _macros: - dependency: transitive - description: dart - source: sdk - version: "0.3.2" - analyzer: - dependency: transitive - description: - name: analyzer - sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 - url: "https://pub.dev" - source: hosted - version: "6.7.0" - args: - dependency: transitive - description: - name: args - sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 - url: "https://pub.dev" - source: hosted - version: "2.6.0" - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - convert: - dependency: "direct main" - description: - name: convert - sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 - url: "https://pub.dev" - source: hosted - version: "3.1.2" - coverage: - dependency: transitive - description: - name: coverage - sha256: "88b0fddbe4c92910fefc09cc0248f5e7f0cd23e450ded4c28f16ab8ee8f83268" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - crypto: - dependency: transitive - description: - name: crypto - sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" - url: "https://pub.dev" - source: hosted - version: "3.0.6" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 - url: "https://pub.dev" - source: hosted - version: "1.0.8" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" - url: "https://pub.dev" - source: hosted - version: "2.1.3" - file: - dependency: transitive - description: - name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" - url: "https://pub.dev" - source: hosted - version: "7.0.0" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_driver: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - frontend_server_client: - dependency: transitive - description: - name: frontend_server_client - sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 - url: "https://pub.dev" - source: hosted - version: "4.0.0" - fuchsia_remote_debug_protocol: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - glob: - dependency: transitive - description: - name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" - url: "https://pub.dev" - source: hosted - version: "3.2.1" - http_parser: - dependency: transitive - description: - name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - integration_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - io: - dependency: transitive - description: - name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - js: - dependency: transitive - description: - name: js - sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf - url: "https://pub.dev" - source: hosted - version: "0.7.1" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" - url: "https://pub.dev" - source: hosted - version: "10.0.5" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" - url: "https://pub.dev" - source: hosted - version: "3.0.5" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" - url: "https://pub.dev" - source: hosted - version: "3.0.1" - logging: - dependency: transitive - description: - name: logging - sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 - url: "https://pub.dev" - source: hosted - version: "1.3.0" - macros: - dependency: transitive - description: - name: macros - sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" - url: "https://pub.dev" - source: hosted - version: "0.1.2-main.4" - matcher: - dependency: transitive - description: - name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb - url: "https://pub.dev" - source: hosted - version: "0.12.16+1" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec - url: "https://pub.dev" - source: hosted - version: "0.11.1" - meta: - dependency: transitive - description: - name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 - url: "https://pub.dev" - source: hosted - version: "1.15.0" - mime: - dependency: transitive - description: - name: mime - sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" - url: "https://pub.dev" - source: hosted - version: "2.0.0" - node_preamble: - dependency: transitive - description: - name: node_preamble - sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" - url: "https://pub.dev" - source: hosted - version: "2.0.2" - package_config: - dependency: transitive - description: - name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.dev" - source: hosted - version: "2.1.0" - path: - dependency: transitive - description: - name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - platform: - dependency: transitive - description: - name: platform - sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" - url: "https://pub.dev" - source: hosted - version: "3.1.5" - pool: - dependency: transitive - description: - name: pool - sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" - url: "https://pub.dev" - source: hosted - version: "1.5.1" - process: - dependency: transitive - description: - name: process - sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" - url: "https://pub.dev" - source: hosted - version: "5.0.2" - pub_semver: - dependency: transitive - description: - name: pub_semver - sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - shelf: - dependency: transitive - description: - name: shelf - sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 - url: "https://pub.dev" - source: hosted - version: "1.4.1" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" - url: "https://pub.dev" - source: hosted - version: "3.0.2" - shelf_static: - dependency: transitive - description: - name: shelf_static - sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 - url: "https://pub.dev" - source: hosted - version: "1.1.3" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" - url: "https://pub.dev" - source: hosted - version: "2.0.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b - url: "https://pub.dev" - source: hosted - version: "2.1.2" - source_maps: - dependency: transitive - description: - name: source_maps - sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" - url: "https://pub.dev" - source: hosted - version: "0.10.12" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - sync_http: - dependency: transitive - description: - name: sync_http - sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" - url: "https://pub.dev" - source: hosted - version: "0.3.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test: - dependency: "direct dev" - description: - name: test - sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" - url: "https://pub.dev" - source: hosted - version: "1.25.7" - test_api: - dependency: transitive - description: - name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" - url: "https://pub.dev" - source: hosted - version: "0.7.2" - test_core: - dependency: transitive - description: - name: test_core - sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" - url: "https://pub.dev" - source: hosted - version: "0.6.4" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 - url: "https://pub.dev" - source: hosted - version: "1.4.0" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" - url: "https://pub.dev" - source: hosted - version: "14.2.5" - watcher: - dependency: transitive - description: - name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - web: - dependency: transitive - description: - name: web - sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb - url: "https://pub.dev" - source: hosted - version: "1.1.0" - web_socket: - dependency: transitive - description: - name: web_socket - sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83" - url: "https://pub.dev" - source: hosted - version: "0.1.6" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f" - url: "https://pub.dev" - source: hosted - version: "3.0.1" - webcrypto: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.5.7" - webdriver: - dependency: transitive - description: - name: webdriver - sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e" - url: "https://pub.dev" - source: hosted - version: "3.0.3" - webkit_inspection_protocol: - dependency: transitive - description: - name: webkit_inspection_protocol - sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" - url: "https://pub.dev" - source: hosted - version: "1.2.1" - yaml: - dependency: transitive - description: - name: yaml - sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" - url: "https://pub.dev" - source: hosted - version: "3.1.2" -sdks: - dart: ">=3.5.0 <4.0.0" - flutter: ">=3.19.0" From 46b5e4987ffb0e06eded360d07aa43040d394340 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Thu, 19 Mar 2026 12:23:04 -0700 Subject: [PATCH 2/3] fix file formatting --- lib/src/webcrypto/webcrypto.rsapss.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/webcrypto/webcrypto.rsapss.dart b/lib/src/webcrypto/webcrypto.rsapss.dart index 5fa3bc9c..13fd57b4 100644 --- a/lib/src/webcrypto/webcrypto.rsapss.dart +++ b/lib/src/webcrypto/webcrypto.rsapss.dart @@ -681,4 +681,4 @@ final class RsaPssPublicKey { /// /// [1]: https://www.rfc-editor.org/rfc/rfc7517 Future> exportJsonWebKey() => _impl.exportJsonWebKey(); -} \ No newline at end of file +} From 37f2037439d3935197894388e28fd6e9b31869ce Mon Sep 17 00:00:00 2001 From: kevmoo Date: Thu, 19 Mar 2026 12:40:46 -0700 Subject: [PATCH 3/3] more cleanup --- analysis_options.yaml | 4 --- example/analysis_options.yaml | 29 ---------------- example/lib/main.dart | 18 +++++----- example/pubspec.yaml | 2 +- example/test/widget_test.dart | 15 +++----- .../boringssl/lookup/symbols.generated.dart | 2 +- lib/src/crypto_subtle.dart | 2 +- lib/src/flutter/webcrypto_plugin.dart | 2 +- lib/src/impl_ffi/impl_ffi.dart | 2 -- lib/src/impl_interface/impl_interface.dart | 2 -- lib/src/impl_js/impl_js.dart | 3 +- lib/src/impl_js/impl_js.random.dart | 18 +++++----- lib/src/impl_js/impl_js.utils.dart | 13 ++++--- lib/src/impl_stub/impl_stub.dart | 2 -- lib/src/testing/webcrypto/aesctr.dart | 2 -- lib/src/webcrypto/webcrypto.dart | 2 +- lib/webcrypto.dart | 2 +- test/crypto_subtle_test.dart | 34 ++++++++++++------- tool/generate_symbols_table.dart | 2 +- 19 files changed, 62 insertions(+), 94 deletions(-) delete mode 100644 example/analysis_options.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml index f514eded..8d4fb5a0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -13,7 +13,3 @@ # limitations under the License. include: package:flutter_lints/flutter.yaml -analyzer: - exclude: - # Cannot analyze subprojects - - example/** diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml deleted file mode 100644 index 61b6c4de..00000000 --- a/example/analysis_options.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/example/lib/main.dart b/example/lib/main.dart index 1f96bda5..68d7ddb9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -20,12 +20,14 @@ import 'package:convert/convert.dart' show hex; import 'package:webcrypto/webcrypto.dart'; void main() { - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatefulWidget { + const MyApp({super.key}); + @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -50,17 +52,17 @@ class _MyAppState extends State { ), Text( 'input', - textScaleFactor: 1.2, - style: TextStyle(fontWeight: FontWeight.bold), + textScaler: const TextScaler.linear(1.2), + style: const TextStyle(fontWeight: FontWeight.bold), ), _textEntry(), - SizedBox(height: 50), + const SizedBox(height: 50), Text( 'output', - textScaleFactor: 1.2, - style: TextStyle(fontWeight: FontWeight.bold), + textScaler: const TextScaler.linear(1.2), + style: const TextStyle(fontWeight: FontWeight.bold), ), - Text('$_output'), + Text(_output), ], ), ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a4c9f5d7..3dab49e8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -45,6 +45,6 @@ dev_dependencies: flutter_driver: sdk: flutter test: ^1.5.2 - + flutter_lints: ^6.0.0 flutter: uses-material-design: true diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 152631d1..6115d372 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -19,23 +19,16 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:webcrypto_example/main.dart'; void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { + testWidgets('Verify SHA-1 hashing title', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data.startsWith('Running on:'), - ), - findsOneWidget, - ); + // Verify that the title is present. + expect(find.text('SHA-1 Hashing'), findsOneWidget); }); } diff --git a/lib/src/boringssl/lookup/symbols.generated.dart b/lib/src/boringssl/lookup/symbols.generated.dart index 7dbef621..b0e91405 100644 --- a/lib/src/boringssl/lookup/symbols.generated.dart +++ b/lib/src/boringssl/lookup/symbols.generated.dart @@ -18,7 +18,7 @@ /// /// This file is generated from `src/symbols.yaml` using: /// `tool/generate_symbols_table.dart` -library symbols.generated; +library; /// BoringSSL symbols used in `package:webcrypto`. enum Sym { diff --git a/lib/src/crypto_subtle.dart b/lib/src/crypto_subtle.dart index 55631943..dd979929 100644 --- a/lib/src/crypto_subtle.dart +++ b/lib/src/crypto_subtle.dart @@ -14,7 +14,7 @@ /// This library attempts to expose the definitions necessary to use the /// browsers `window.crypto.subtle` APIs. -library common; +library; import 'dart:js_interop'; import 'dart:typed_data'; diff --git a/lib/src/flutter/webcrypto_plugin.dart b/lib/src/flutter/webcrypto_plugin.dart index 8e2b41d8..672c3a8a 100644 --- a/lib/src/flutter/webcrypto_plugin.dart +++ b/lib/src/flutter/webcrypto_plugin.dart @@ -26,7 +26,7 @@ /// Having the `web` annotation is important for correct platform detection by /// `pub.dev`, but since this package otherwise relies on _conditional imports_ /// this plugin does nothing. -library webcrypto_plugin; +library; import 'dart:async'; diff --git a/lib/src/impl_ffi/impl_ffi.dart b/lib/src/impl_ffi/impl_ffi.dart index 7f985909..a030045a 100644 --- a/lib/src/impl_ffi/impl_ffi.dart +++ b/lib/src/impl_ffi/impl_ffi.dart @@ -14,8 +14,6 @@ // ignore_for_file: non_constant_identifier_names -library impl_ffi; - import 'dart:async'; import 'dart:ffi' show Allocator; import 'dart:typed_data'; diff --git a/lib/src/impl_interface/impl_interface.dart b/lib/src/impl_interface/impl_interface.dart index 845a177f..a9537d77 100644 --- a/lib/src/impl_interface/impl_interface.dart +++ b/lib/src/impl_interface/impl_interface.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -library impl_stub; - import 'dart:typed_data'; import 'dart:async'; diff --git a/lib/src/impl_js/impl_js.dart b/lib/src/impl_js/impl_js.dart index 7e4f0bd8..17dde315 100644 --- a/lib/src/impl_js/impl_js.dart +++ b/lib/src/impl_js/impl_js.dart @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -library impl_js; - import 'dart:async'; import 'dart:typed_data'; +import 'dart:js_interop'; import 'package:webcrypto/src/impl_interface/impl_interface.dart'; diff --git a/lib/src/impl_js/impl_js.random.dart b/lib/src/impl_js/impl_js.random.dart index a5355b33..22bae9f2 100644 --- a/lib/src/impl_js/impl_js.random.dart +++ b/lib/src/impl_js/impl_js.random.dart @@ -21,15 +21,17 @@ final class _RandomImpl implements RandomImpl { void fillRandomBytes(TypedData destination) { try { subtle.getRandomValues(destination); - } on subtle.JSDomException catch (e) { - throw _translateDomException(e); - } on Error catch (e) { - final errorName = e.toString(); - if (errorName != 'JavaScriptError') { - rethrow; + } catch (e) { + if (e.isA()) { + throw _translateDomException(e as subtle.JSDomException); } - - throw _translateJavaScriptException(); + if (e is Error) { + final errorName = e.toString(); + if (errorName == 'JavaScriptError') { + throw _translateJavaScriptException(); + } + } + rethrow; } } } diff --git a/lib/src/impl_js/impl_js.utils.dart b/lib/src/impl_js/impl_js.utils.dart index 3a7b8de2..85477a50 100644 --- a/lib/src/impl_js/impl_js.utils.dart +++ b/lib/src/impl_js/impl_js.utils.dart @@ -131,11 +131,14 @@ Future _handleDomException( }) async { try { return await fn(); - } on subtle.JSDomException catch (e) { - throw _translateDomException( - e, - invalidAccessErrorIsArgumentError: invalidAccessErrorIsArgumentError, - ); + } catch (e) { + if (e.isA()) { + throw _translateDomException( + e as subtle.JSDomException, + invalidAccessErrorIsArgumentError: invalidAccessErrorIsArgumentError, + ); + } + rethrow; } } diff --git a/lib/src/impl_stub/impl_stub.dart b/lib/src/impl_stub/impl_stub.dart index c0d24b51..34528735 100644 --- a/lib/src/impl_stub/impl_stub.dart +++ b/lib/src/impl_stub/impl_stub.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -library webcrypto.impl_stub; - import 'dart:typed_data'; import 'package:webcrypto/src/impl_interface/impl_interface.dart'; diff --git a/lib/src/testing/webcrypto/aesctr.dart b/lib/src/testing/webcrypto/aesctr.dart index 3e75e784..66ae2863 100644 --- a/lib/src/testing/webcrypto/aesctr.dart +++ b/lib/src/testing/webcrypto/aesctr.dart @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -library aesctr_test; - import 'package:webcrypto/webcrypto.dart'; import '../utils/utils.dart'; import '../utils/testrunner.dart'; diff --git a/lib/src/webcrypto/webcrypto.dart b/lib/src/webcrypto/webcrypto.dart index 2f64612d..7c44879b 100644 --- a/lib/src/webcrypto/webcrypto.dart +++ b/lib/src/webcrypto/webcrypto.dart @@ -18,7 +18,7 @@ /// expect that the contents of these streams is buffered when operating /// in the browser. /// This could be documented for each method or at library level. -library webcrypto; +library; import 'dart:convert'; import 'dart:async'; diff --git a/lib/webcrypto.dart b/lib/webcrypto.dart index 2d369400..ace27b93 100644 --- a/lib/webcrypto.dart +++ b/lib/webcrypto.dart @@ -43,6 +43,6 @@ /// mismatching curves where it becomes an [ArgumentError]. /// /// @docImport 'src/webcrypto/webcrypto.dart'; -library webcrypto; +library; export 'src/webcrypto/webcrypto.dart'; diff --git a/test/crypto_subtle_test.dart b/test/crypto_subtle_test.dart index 3c114a08..190a8a39 100644 --- a/test/crypto_subtle_test.dart +++ b/test/crypto_subtle_test.dart @@ -123,24 +123,34 @@ void main() { test('getRandomValues: too long', () { try { subtle.window.crypto.getRandomValues(Uint8List(1000000).toJS); - } on subtle.JSDomException catch (e) { - // dart2js throws QuotaExceededError - expect(e.name, 'QuotaExceededError'); - } on Error catch (e) { - // dart2wasm throws JavaScriptError - expect(e.toString(), 'JavaScriptError'); + } catch (e) { + if (e.isA()) { + // dart2js throws QuotaExceededError + expect((e as subtle.JSDomException).name, 'QuotaExceededError'); + return; + } + if (e is Error && e.toString() == 'JavaScriptError') { + // dart2wasm throws JavaScriptError + return; + } + rethrow; } }); test('getRandomValues: not supported type', () { try { subtle.window.crypto.getRandomValues(Float32List(32).toJS); - } on subtle.JSDomException catch (e) { - // dart2js throws TypeMismatchError - expect(e.name, 'TypeMismatchError'); - } on Error catch (e) { - // dart2wasm throws JavaScriptError - expect(e.toString(), 'JavaScriptError'); + } catch (e) { + if (e.isA()) { + // dart2js throws TypeMismatchError + expect((e as subtle.JSDomException).name, 'TypeMismatchError'); + return; + } + if (e is Error && e.toString() == 'JavaScriptError') { + // dart2wasm throws JavaScriptError + return; + } + rethrow; } }); }); diff --git a/tool/generate_symbols_table.dart b/tool/generate_symbols_table.dart index 735f0151..a4181d62 100644 --- a/tool/generate_symbols_table.dart +++ b/tool/generate_symbols_table.dart @@ -92,7 +92,7 @@ Future main() async { '///', '/// This file is generated from `src/symbols.yaml` using:', '/// `tool/generate_symbols_table.dart`', - 'library symbols.generated;', + 'library;', '', '/// BoringSSL symbols used in `package:webcrypto`.', 'enum Sym {',