refactor: combine the storage interface for storage and pkce in gotrue_client#1087
refactor: combine the storage interface for storage and pkce in gotrue_client#1087Vinzent03 wants to merge 19 commits into
Conversation
c006dd1 to
0ae2b71
Compare
|
Thanks for this PR, but honestly, I am not a huge fan of these refactorings. I feel like the library is deviating more and more from supabase-js, which makes it hard to maintain. Unless there is something broken, I'd say we keep it the way it is, and maybe we can revisit it when a major version release comes. |
|
I'm quite confused, because the whole goal of this pr is to align with supabase-js .
So this pr makes it easier to maintain the similarity to the js sdk. |
|
It's a refactoring that doesn't really solve any issues that users are asking for. We can probably wait for a major version bump for changes like this. |
|
This pull request has been inactive for 90 days. If you plan to continue working on this PR, please leave a comment to keep it open. |
|
This pull request was automatically closed due to inactivity. If you'd like to continue this work, please reopen the PR or create a new one. |
| /// Dispose the instance to free up resources. | ||
| Future<void> dispose() async { | ||
| _targetLifecycleState = null; | ||
| await _restoreSessionCancellableOperation.cancel(); |
There was a problem hiding this comment.
This code was actually not functional before as one cannot really cancel a future. Canceling this future would just call the onCancel function, but that is not specified here. So it would have just been fine to call recoverSession() directly.
What kind of change does this PR introduce?
refactor with breaking changes and fixes
What is the current behavior?
The session gets stored by the supabase_flutter package by listening to auth events. The session is stored by a different class/interface than the pkce token. This adds unnecessary complexity and is a difference to the supabase-js sdk.
What is the new behavior?
The gotrue package manages the session storage itself (like in supabase-js) and uses the same interface as the pkce token.
Reasons for this pr:
persistSessionfield, which is now used to explicitly turn on the session broadcasting. fixes Version 2.7.0 prevents reading data on web under certain conditions #1085I deprecated both
localStorage(used for session storage bysupabase_flutter) andpkceAsyncStorage(used bysupabaseto store the pkce token) and replace them with a unified storage interfaceasyncStorage, which uses theGotrueAsyncStorageclass, which was previously used for pkce only. Though I refactored the arguments of the methods to use positional arguments instead of named arguments. This is much more idiomatic to other storage packages and common for methods with just one or two arguments. To support existing configuration as best as possible I created a new class, which combines both deprecated config options (localStorageandpkceAsyncStorage) into one and decides by the suffix of the storage key to use the session storage or pkce storage. Note that an implementation of theGotrueAsyncStorageclass still needs to be refactored, but that only affects the method signature and not the implementation itself.Additionally, I noticed that many document comments were outdated, because of the 'new' options classes for each package, so I updated them.
Breaking Changes
GotrueAsyncStorageclassAdditional context
I think this is a great refactoring that does not affect many people, because I don't think many flutter user customize the storage. But it makes it easier and more streamlined for the ones that do so and opens new easier usage ways outside of flutter with auth session storage now built-in.