-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for app state argument #485
base: main
Are you sure you want to change the base?
Changes from all commits
345af81
5b62459
21d4717
aff5623
430eda3
0ce9619
78d0140
8cd51f3
594cabe
6439b38
ba9e026
eb66057
0b69944
088c8c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,25 @@ class AuthorizationParams { | |
@JS() | ||
@anonymous | ||
class RedirectLoginOptions { | ||
external Object? get appState; // TODO: use `JSAny?` when migrating to WASM | ||
external AuthorizationParams? get authorizationParams; | ||
external String? get fragment; | ||
|
||
external factory RedirectLoginOptions( | ||
{final AuthorizationParams authorizationParams, final String fragment}); | ||
external factory RedirectLoginOptions({ | ||
final Object? appState, | ||
final AuthorizationParams authorizationParams, | ||
final String fragment, | ||
}); | ||
} | ||
|
||
@JS() | ||
@anonymous | ||
class RedirectLoginResult { | ||
external Object? get appState; // TODO: use `JSAny?` when migrating to WASM | ||
|
||
external factory RedirectLoginResult({ | ||
final Object? appState, | ||
}); | ||
} | ||
|
||
@JS() | ||
|
@@ -177,12 +191,17 @@ class PopupConfigOptions { | |
class Auth0Client { | ||
external Auth0Client(final Auth0ClientOptions options); | ||
external Future<void> loginWithRedirect([final RedirectLoginOptions options]); | ||
external Future<void> loginWithPopup( | ||
[final PopupLoginOptions? options, final PopupConfigOptions? config]); | ||
external Future<void> handleRedirectCallback([final String? url]); | ||
external Future<void> loginWithPopup([ | ||
final PopupLoginOptions? options, | ||
final PopupConfigOptions? config, | ||
]); | ||
external Future<RedirectLoginResult> handleRedirectCallback([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The app state is defined in the RedirectLoginResult, so we need it here too. |
||
final String url, | ||
]); | ||
external Future<void> checkSession(); | ||
external Future<WebCredentials> getTokenSilently( | ||
[final GetTokenSilentlyOptions? options]); | ||
external Future<WebCredentials> getTokenSilently([ | ||
final GetTokenSilentlyOptions? options, | ||
]); | ||
external Future<bool> isAuthenticated(); | ||
external Future<void> logout([final LogoutOptions? logoutParams]); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,22 @@ class JsInteropUtils { | |
|
||
return obj; | ||
} | ||
|
||
// TODO: replace with `dartify` from `dart:js_interop_unsafe` when migrating to WASM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added these here, to make the migration to WASM easier. Then we only need to change these two, instead of all callsites |
||
/// Convert the Javascript object [obj] to a Dart object. | ||
/// | ||
/// This method should only be used to convert objects | ||
/// that do not fit into a static interop definition. | ||
/// | ||
/// See https://api.dart.dev/dart-js_interop/JSAnyUtilityExtension/dartify.html | ||
static Object? dartifyObject(final Object? obj) => dartify(obj); | ||
|
||
// TODO: replace with `jsify` from `dart:js_interop_unsafe` when migrating to WASM | ||
/// Convert the Dart object [obj] to a plain Javascript object. | ||
/// | ||
/// This method should only be used to convert objects | ||
/// that do not fit into a static interop definition. | ||
/// | ||
/// See https://api.dart.dev/dart-js_interop/NullableObjectUtilExtension/jsify.html | ||
static Object? jsifyObject(final Object? obj) => jsify(obj); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ dependency_overrides: | |
|
||
dev_dependencies: | ||
build_runner: ^2.1.8 | ||
collection: ^1.18.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the |
||
dart_jsonwebtoken: ^2.7.1 | ||
flutter_lints: ^2.0.1 | ||
flutter_test: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property & getter are new. We provide these now, so that:
a) users can retrieve the app state
b) we do not need to change the API for initialize/onLoad (the app state is web only anyway? Or so I think?)
In the future, we might want to move the redirect state to the result of
onLoad() / initialize()
directly. That would make the API cleaner, but that does involve a breaking change, so the plugin would have to do this in version 2.0.0