mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.09k stars 340 forks source link

Migrate dart:html and package:js to package:web and dart:js_interop #698

Closed svenopdehipt closed 1 month ago

svenopdehipt commented 2 months ago

Migrate packages to support wasm in the next stable release. Removed unused code in subtle.dart and update dependencies for the example project. I have also used the new index.html structure and tested it wasm on the current beta channel, but I have reverted the index.html because it doesn't work with the current stable release.

juliansteenbakker commented 1 month ago

Hi all, i am working on integrating #680, so this should not be needed anymore. Thank you anyway!

svenopdehipt commented 1 month ago

680 does still use package:js and not dart:js_interop

svenopdehipt commented 1 month ago

I have updated the code with the changes provided above

svenopdehipt commented 1 month ago

I have just tested all the changed code and noticed that the get random value does work for javascript but does not work for wasm. I will revert this change.

koji-1009 commented 1 month ago

Thanks! I understand that package:web completely replaces package:js, so I think this change will be necessary.

Since package:web ^0.5.0 requires Dart 3.3, it may be a good idea to update the package required dart version. However, in applications that do not use web, this change may seem disruptive. Nevertheless, plus_package has already been changed to require Dart 3.3 or higher. I would be happy for maintainers to consider this.

https://github.com/fluttercommunity/plus_plugins/issues/2653

svenopdehipt commented 1 month ago

I just noticed that the jsonwebkey file isn't used anymore and could also be deleted. Should I delete this?

paulking86 commented 1 month ago

@svenopdehipt - Thanks for your work on this! Is there any chance you can pull develop into this branch (or rebase) to resolve merge conflicts? 🙏

svenopdehipt commented 1 month ago

I have rebased the branch with the develop branch of your repo.

paulking86 commented 1 month ago

Rapid work @svenopdehipt - Thank you!

My only thoughts now are relating to @koji-1009's comment above. Should our pubspec.yaml now look like this instead?

environment:
  sdk: ">=3.3.0 <4.0.0"
  flutter: ">=3.19.0"
svenopdehipt commented 1 month ago

I do think that it would make sense to update the pubspec.yaml, because older flutter and dart versions aren't supported anyway due though the package:web dependency.

paulking86 commented 1 month ago

Keen to hear your thoughts @juliansteenbakker, as I know you were discussing this in #680!

paulking86 commented 1 month ago

Bump. Any updates on this?

juliansteenbakker commented 1 month ago

Seems all good! So what i'm gonna do is merge this, change the version constraints of flutter, and release it under a new major version. I created a separate branch where we can continue support for the current version 9, because the sudden change in flutter versions will require lots of people to update flutter, which can be a hassle in some projects.

juliansteenbakker commented 1 month ago

So, because these changes require a recent version of flutter, i have decided to make it an opt-in. I have publish v2.0.0-beta.1 of the flutter_secure_storage_web package, which you can use by setting the following line in your pubspec.yaml:

dependency_overrides:
  flutter_secure_storage_web: ^2.0.0-beta.1

I have also added this in the readme, so users can decide of themself to use this version, or stick with the old implementation which doesn't require the latest flutter version.