From b0d390f6b2682856bb4bc5c79cdde61191d71f35 Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:04:51 +1100 Subject: [PATCH] [flutter_appauth_platform_interface][flutter_appauth] migrate to null safety (#187) * migrate platform interface to null safety * update cirrus script * migrate plugin to null safety * address warnings in example app * updated constraints for plugin_platform_interface dependency * make clientId and redirectUrl non-nullable * updated plugin_platform_interface version requirement * update flutter_appauth_platform_interface for stable release * switch cirrus script to build on stable * make ios build task upgrade from stable * bump version for stable release --- .cirrus.yml | 2 + flutter_appauth/CHANGELOG.md | 4 ++ flutter_appauth/example/lib/main.dart | 52 +++++++++---------- flutter_appauth/example/pubspec.yaml | 7 ++- flutter_appauth/lib/src/flutter_appauth.dart | 6 +-- flutter_appauth/pubspec.yaml | 6 +-- .../CHANGELOG.md | 7 ++- .../lib/src/authorization_parameters.dart | 6 +-- .../lib/src/authorization_request.dart | 14 ++--- .../lib/src/authorization_response.dart | 8 +-- .../authorization_service_configuration.dart | 5 +- .../lib/src/authorization_token_request.dart | 16 +++--- .../lib/src/authorization_token_response.dart | 14 ++--- .../lib/src/common_request_details.dart | 16 +++--- .../lib/src/flutter_appauth_platform.dart | 6 +-- .../src/method_channel_flutter_appauth.dart | 12 ++--- .../lib/src/method_channel_mappers.dart | 20 +++---- .../lib/src/token_request.dart | 20 +++---- .../lib/src/token_response.dart | 12 ++--- .../pubspec.yaml | 8 +-- .../method_channel_flutter_appauth_test.dart | 10 ++-- 21 files changed, 130 insertions(+), 121 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index a540a259..72f48d21 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,5 +24,7 @@ task: pub_cache: folder: ~/.pub-cache build_script: + - flutter channel stable + - flutter upgrade - cd flutter_appauth/example - flutter build ios --no-codesign diff --git a/flutter_appauth/CHANGELOG.md b/flutter_appauth/CHANGELOG.md index c8cb4829..f6046a1d 100644 --- a/flutter_appauth/CHANGELOG.md +++ b/flutter_appauth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.0 + +* Migrated to null safety + ## 0.9.2+6 * [Android] community has reported that there seem to be instances where the plugin encounters a null intent on some devices upon processing a authorisation request. This resulted in a crash before but will now throw a `PlatformException`. Thanks to the PR from [Leon Havenga](https://github.com/li0nza) diff --git a/flutter_appauth/example/lib/main.dart b/flutter_appauth/example/lib/main.dart index 316b9a9f..c80d9801 100644 --- a/flutter_appauth/example/lib/main.dart +++ b/flutter_appauth/example/lib/main.dart @@ -13,10 +13,10 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { bool _isBusy = false; final FlutterAppAuth _appAuth = FlutterAppAuth(); - String _codeVerifier; - String _authorizationCode; - String _refreshToken; - String _accessToken; + String? _codeVerifier; + String? _authorizationCode; + String? _refreshToken; + String? _accessToken; final TextEditingController _authorizationCodeTextController = TextEditingController(); final TextEditingController _accessTokenTextController = @@ -44,7 +44,7 @@ class _MyAppState extends State { ]; final AuthorizationServiceConfiguration _serviceConfiguration = - AuthorizationServiceConfiguration( + const AuthorizationServiceConfiguration( 'https://demo.identityserver.io/connect/authorize', 'https://demo.identityserver.io/connect/token'); @@ -67,22 +67,22 @@ class _MyAppState extends State { visible: _isBusy, child: const LinearProgressIndicator(), ), - RaisedButton( + ElevatedButton( child: const Text('Sign in with no code exchange'), onPressed: _signInWithNoCodeExchange, ), - RaisedButton( + ElevatedButton( child: const Text('Exchange code'), onPressed: _authorizationCode != null ? _exchangeCode : null, ), - RaisedButton( + ElevatedButton( child: const Text('Sign in with auto code exchange'), onPressed: () => _signInWithAutoCodeExchange(), ), if (Platform.isIOS) Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( + child: ElevatedButton( child: const Text( 'Sign in with auto code exchange using ephemeral session (iOS only)', textAlign: TextAlign.center, @@ -91,7 +91,7 @@ class _MyAppState extends State { preferEphemeralSession: true), ), ), - RaisedButton( + ElevatedButton( child: const Text('Refresh token'), onPressed: _refreshToken != null ? _refresh : null, ), @@ -127,7 +127,7 @@ class _MyAppState extends State { Future _refresh() async { try { _setBusyState(); - final TokenResponse result = await _appAuth.token(TokenRequest( + final TokenResponse? result = await _appAuth.token(TokenRequest( _clientId, _redirectUrl, refreshToken: _refreshToken, discoveryUrl: _discoveryUrl, @@ -142,7 +142,7 @@ class _MyAppState extends State { Future _exchangeCode() async { try { _setBusyState(); - final TokenResponse result = await _appAuth.token(TokenRequest( + final TokenResponse? result = await _appAuth.token(TokenRequest( _clientId, _redirectUrl, authorizationCode: _authorizationCode, discoveryUrl: _discoveryUrl, @@ -159,7 +159,7 @@ class _MyAppState extends State { try { _setBusyState(); // use the discovery endpoint to find the configuration - final AuthorizationResponse result = await _appAuth.authorize( + final AuthorizationResponse? result = await _appAuth.authorize( AuthorizationRequest(_clientId, _redirectUrl, discoveryUrl: _discoveryUrl, scopes: _scopes, loginHint: 'bob'), ); @@ -187,7 +187,7 @@ class _MyAppState extends State { _setBusyState(); // show that we can also explicitly specify the endpoints rather than getting from the details from the discovery document - final AuthorizationTokenResponse result = + final AuthorizationTokenResponse? result = await _appAuth.authorizeAndExchangeCode( AuthorizationTokenRequest( _clientId, @@ -229,11 +229,11 @@ class _MyAppState extends State { void _processAuthTokenResponse(AuthorizationTokenResponse response) { setState(() { - _accessToken = _accessTokenTextController.text = response.accessToken; - _idTokenTextController.text = response.idToken; - _refreshToken = _refreshTokenTextController.text = response.refreshToken; + _accessToken = _accessTokenTextController.text = response.accessToken!; + _idTokenTextController.text = response.idToken!; + _refreshToken = _refreshTokenTextController.text = response.refreshToken!; _accessTokenExpirationTextController.text = - response.accessTokenExpirationDateTime?.toIso8601String(); + response.accessTokenExpirationDateTime!.toIso8601String(); }); } @@ -242,24 +242,24 @@ class _MyAppState extends State { // save the code verifier as it must be used when exchanging the token _codeVerifier = response.codeVerifier; _authorizationCode = - _authorizationCodeTextController.text = response.authorizationCode; + _authorizationCodeTextController.text = response.authorizationCode!; _isBusy = false; }); } - void _processTokenResponse(TokenResponse response) { + void _processTokenResponse(TokenResponse? response) { setState(() { - _accessToken = _accessTokenTextController.text = response.accessToken; - _idTokenTextController.text = response.idToken; - _refreshToken = _refreshTokenTextController.text = response.refreshToken; + _accessToken = _accessTokenTextController.text = response!.accessToken!; + _idTokenTextController.text = response.idToken!; + _refreshToken = _refreshTokenTextController.text = response.refreshToken!; _accessTokenExpirationTextController.text = - response.accessTokenExpirationDateTime?.toIso8601String(); + response.accessTokenExpirationDateTime!.toIso8601String(); }); } - Future _testApi(TokenResponse response) async { + Future _testApi(TokenResponse? response) async { final http.Response httpResponse = await http.get( - 'https://demo.identityserver.io/api/test', + Uri.parse('https://demo.identityserver.io/api/test'), headers: {'Authorization': 'Bearer $_accessToken'}); setState(() { _userInfo = httpResponse.statusCode == 200 ? httpResponse.body : ''; diff --git a/flutter_appauth/example/pubspec.yaml b/flutter_appauth/example/pubspec.yaml index 7512d12b..f9d10f9f 100644 --- a/flutter_appauth/example/pubspec.yaml +++ b/flutter_appauth/example/pubspec.yaml @@ -4,16 +4,15 @@ version: 1.0.0+1 publish_to: 'none' environment: - sdk: ">=2.6.0 <3.0.0" + sdk: '>=2.12.0-0 <3.0.0' dependencies: + cupertino_icons: ^1.0.2 flutter: sdk: flutter - - cupertino_icons: ^0.1.2 - http: ^0.12.0+1 flutter_appauth: path: ../ + http: ^0.13.0 dev_dependencies: flutter_test: diff --git a/flutter_appauth/lib/src/flutter_appauth.dart b/flutter_appauth/lib/src/flutter_appauth.dart index 7e123304..74a4f9fe 100644 --- a/flutter_appauth/lib/src/flutter_appauth.dart +++ b/flutter_appauth/lib/src/flutter_appauth.dart @@ -2,18 +2,18 @@ import 'package:flutter_appauth_platform_interface/flutter_appauth_platform_inte class FlutterAppAuth { /// Convenience method for authorizing and then exchanges code - Future authorizeAndExchangeCode( + Future authorizeAndExchangeCode( AuthorizationTokenRequest request) { return FlutterAppAuthPlatform.instance.authorizeAndExchangeCode(request); } /// Sends an authorization request - Future authorize(AuthorizationRequest request) { + Future authorize(AuthorizationRequest request) { return FlutterAppAuthPlatform.instance.authorize(request); } /// For exchanging tokens - Future token(TokenRequest request) { + Future token(TokenRequest request) { return FlutterAppAuthPlatform.instance.token(request); } } diff --git a/flutter_appauth/pubspec.yaml b/flutter_appauth/pubspec.yaml index fed833b4..d3892db0 100644 --- a/flutter_appauth/pubspec.yaml +++ b/flutter_appauth/pubspec.yaml @@ -1,16 +1,16 @@ name: flutter_appauth description: This plugin provides an abstraction around the Android and iOS AppAuth SDKs so it can be used to communicate with OAuth 2.0 and OpenID Connect providers -version: 0.9.2+6 +version: 1.0.0 homepage: https://github.com/MaikuB/flutter_appauth/tree/master/flutter_appauth environment: - sdk: '>=2.6.0 <3.0.0' + sdk: '>=2.12.0-0 <3.0.0' flutter: '>=1.12.13+hotfix.5' dependencies: flutter: sdk: flutter - flutter_appauth_platform_interface: ^2.0.0 + flutter_appauth_platform_interface: ^3.0.0 flutter: plugin: diff --git a/flutter_appauth_platform_interface/CHANGELOG.md b/flutter_appauth_platform_interface/CHANGELOG.md index e9eae000..83872efe 100644 --- a/flutter_appauth_platform_interface/CHANGELOG.md +++ b/flutter_appauth_platform_interface/CHANGELOG.md @@ -1,6 +1,11 @@ +## [3.0.0] + +* Migrated to null safety +* `AuthorizationServiceConfiguration` and `AuthorizationResponse` now have `const` constructors + ## [2.0.0] -* **BREAKING CHANGE** Removed the `toMap` methods so that it's not part of the public API surface. This was done as these methods were for internal use. Currently `flutter_appauth` (version 0.8.3) is constrained to depend on versions >= 1.0.2 and < 2.0.0. As it's possible that plugin consumers were calling the methods via the plugin, where the platform interface is a transitive dependency, the platform interface has been bumped to version 2.0.0 instead of 1.1.0 to be safe. +* **Breaking change** Removed the `toMap` methods so that it's not part of the public API surface. This was done as these methods were for internal use. Currently `flutter_appauth` (version 0.8.3) is constrained to depend on versions >= 1.0.2 and < 2.0.0. As it's possible that plugin consumers were calling the methods via the plugin, where the platform interface is a transitive dependency, the platform interface has been bumped to version 2.0.0 instead of 1.1.0 to be safe. * Added `preferEphemeralSession` to `AuthorizationRequest` and `AuthorizationTokenRequest` classes. Thanks to the PR from [Matthew Smith](https://github.com/matthewtsmith). ## [1.0.2] diff --git a/flutter_appauth_platform_interface/lib/src/authorization_parameters.dart b/flutter_appauth_platform_interface/lib/src/authorization_parameters.dart index 2cea12ce..173116bf 100644 --- a/flutter_appauth_platform_interface/lib/src/authorization_parameters.dart +++ b/flutter_appauth_platform_interface/lib/src/authorization_parameters.dart @@ -1,12 +1,12 @@ mixin AuthorizationParameters { /// Hint to the Authorization Server about the login identifier the End-User might use to log in. - String loginHint; + String? loginHint; /// List of ASCII string values that specifies whether the Authorization Server prompts the End-User for reauthentication and consent. - List promptValues; + List? promptValues; /// Whether to use an ephemeral session that prevents cookies and other browser data being shared with the user's normal browser session. /// /// This property is only applicable to iOS versions 13 and above. - bool preferEphemeralSession; + bool? preferEphemeralSession; } diff --git a/flutter_appauth_platform_interface/lib/src/authorization_request.dart b/flutter_appauth_platform_interface/lib/src/authorization_request.dart index 9cb8683d..0b57f32d 100644 --- a/flutter_appauth_platform_interface/lib/src/authorization_request.dart +++ b/flutter_appauth_platform_interface/lib/src/authorization_request.dart @@ -8,13 +8,13 @@ class AuthorizationRequest extends CommonRequestDetails AuthorizationRequest( String clientId, String redirectUrl, { - String loginHint, - List scopes, - AuthorizationServiceConfiguration serviceConfiguration, - Map additionalParameters, - String issuer, - String discoveryUrl, - List promptValues, + String? loginHint, + List? scopes, + AuthorizationServiceConfiguration? serviceConfiguration, + Map? additionalParameters, + String? issuer, + String? discoveryUrl, + List? promptValues, bool allowInsecureConnections = false, bool preferEphemeralSession = false, }) { diff --git a/flutter_appauth_platform_interface/lib/src/authorization_response.dart b/flutter_appauth_platform_interface/lib/src/authorization_response.dart index bd6daa8e..193e5127 100644 --- a/flutter_appauth_platform_interface/lib/src/authorization_response.dart +++ b/flutter_appauth_platform_interface/lib/src/authorization_response.dart @@ -1,17 +1,17 @@ /// Contains the response from making an authorization request. class AuthorizationResponse { - AuthorizationResponse( + const AuthorizationResponse( this.authorizationCode, this.codeVerifier, this.authorizationAdditionalParameters, ); /// The authorization code. - final String authorizationCode; + final String? authorizationCode; /// The code verifier generated by AppAuth when issue the authorization request. Use this when exchanging the [authorizationCode] for a token. - final String codeVerifier; + final String? codeVerifier; /// Additional parameters included in the response. - final Map authorizationAdditionalParameters; + final Map? authorizationAdditionalParameters; } diff --git a/flutter_appauth_platform_interface/lib/src/authorization_service_configuration.dart b/flutter_appauth_platform_interface/lib/src/authorization_service_configuration.dart index f3a5b7d6..f0f8c5e0 100644 --- a/flutter_appauth_platform_interface/lib/src/authorization_service_configuration.dart +++ b/flutter_appauth_platform_interface/lib/src/authorization_service_configuration.dart @@ -1,9 +1,8 @@ class AuthorizationServiceConfiguration { - AuthorizationServiceConfiguration( + const AuthorizationServiceConfiguration( this.authorizationEndpoint, this.tokenEndpoint, - ) : assert(tokenEndpoint != null && authorizationEndpoint != null, - 'Must specify both the authorization and token endpoints'); + ); final String authorizationEndpoint; diff --git a/flutter_appauth_platform_interface/lib/src/authorization_token_request.dart b/flutter_appauth_platform_interface/lib/src/authorization_token_request.dart index 0eaea507..85a0d4c9 100644 --- a/flutter_appauth_platform_interface/lib/src/authorization_token_request.dart +++ b/flutter_appauth_platform_interface/lib/src/authorization_token_request.dart @@ -9,14 +9,14 @@ class AuthorizationTokenRequest extends TokenRequest AuthorizationTokenRequest( String clientId, String redirectUrl, { - String loginHint, - String clientSecret, - List scopes, - AuthorizationServiceConfiguration serviceConfiguration, - Map additionalParameters, - String issuer, - String discoveryUrl, - List promptValues, + String? loginHint, + String? clientSecret, + List? scopes, + AuthorizationServiceConfiguration? serviceConfiguration, + Map? additionalParameters, + String? issuer, + String? discoveryUrl, + List? promptValues, bool allowInsecureConnections = false, bool preferEphemeralSession = false, }) : super( diff --git a/flutter_appauth_platform_interface/lib/src/authorization_token_response.dart b/flutter_appauth_platform_interface/lib/src/authorization_token_response.dart index e5e9fbef..a5692d94 100644 --- a/flutter_appauth_platform_interface/lib/src/authorization_token_response.dart +++ b/flutter_appauth_platform_interface/lib/src/authorization_token_response.dart @@ -3,16 +3,16 @@ import 'token_response.dart'; /// The details from making a successful combined authorization and token exchange request. class AuthorizationTokenResponse extends TokenResponse { AuthorizationTokenResponse( - String accessToken, - String refreshToken, - DateTime accessTokenExpirationDateTime, - String idToken, - String tokenType, + String? accessToken, + String? refreshToken, + DateTime? accessTokenExpirationDateTime, + String? idToken, + String? tokenType, this.authorizationAdditionalParameters, - Map tokenAdditionalParameters, + Map? tokenAdditionalParameters, ) : super(accessToken, refreshToken, accessTokenExpirationDateTime, idToken, tokenType, tokenAdditionalParameters); /// Contains additional parameters returned by the authorization server from making the authorization request. - final Map authorizationAdditionalParameters; + final Map? authorizationAdditionalParameters; } diff --git a/flutter_appauth_platform_interface/lib/src/common_request_details.dart b/flutter_appauth_platform_interface/lib/src/common_request_details.dart index 45f22e8a..5cc62d1e 100644 --- a/flutter_appauth_platform_interface/lib/src/common_request_details.dart +++ b/flutter_appauth_platform_interface/lib/src/common_request_details.dart @@ -2,28 +2,28 @@ import 'authorization_service_configuration.dart'; class CommonRequestDetails { /// The client id. - String clientId; + late String clientId; /// The issuer. - String issuer; + String? issuer; /// The URL of where the discovery document can be found. - String discoveryUrl; + String? discoveryUrl; /// The redirect URL. - String redirectUrl; + late String redirectUrl; /// The request scopes. - List scopes; + List? scopes; /// The details of the OAuth 2.0 endpoints that can be explicitly when discovery isn't used or not possible. - AuthorizationServiceConfiguration serviceConfiguration; + AuthorizationServiceConfiguration? serviceConfiguration; /// Additional parameters to include in the request. - Map additionalParameters; + Map? additionalParameters; /// Whether to allow non-HTTPS endpoints. /// /// This property is only applicable to Android. - bool allowInsecureConnections; + bool? allowInsecureConnections; } diff --git a/flutter_appauth_platform_interface/lib/src/flutter_appauth_platform.dart b/flutter_appauth_platform_interface/lib/src/flutter_appauth_platform.dart index 65def2cf..d6cf61b0 100644 --- a/flutter_appauth_platform_interface/lib/src/flutter_appauth_platform.dart +++ b/flutter_appauth_platform_interface/lib/src/flutter_appauth_platform.dart @@ -29,19 +29,19 @@ abstract class FlutterAppAuthPlatform extends PlatformInterface { } /// Convenience method for authorizing and then exchanges the authorization grant code. - Future authorizeAndExchangeCode( + Future authorizeAndExchangeCode( AuthorizationTokenRequest request) { throw UnimplementedError( 'authorizeAndExchangeCode() has not been implemented'); } /// Sends an authorization request. - Future authorize(AuthorizationRequest request) { + Future authorize(AuthorizationRequest request) { throw UnimplementedError('authorize() has not been implemented'); } /// For exchanging tokens. - Future token(TokenRequest request) { + Future token(TokenRequest request) { throw UnimplementedError('token() has not been implemented'); } } diff --git a/flutter_appauth_platform_interface/lib/src/method_channel_flutter_appauth.dart b/flutter_appauth_platform_interface/lib/src/method_channel_flutter_appauth.dart index 1c917f62..00612c64 100644 --- a/flutter_appauth_platform_interface/lib/src/method_channel_flutter_appauth.dart +++ b/flutter_appauth_platform_interface/lib/src/method_channel_flutter_appauth.dart @@ -14,8 +14,8 @@ const MethodChannel _channel = class MethodChannelFlutterAppAuth extends FlutterAppAuthPlatform { @override - Future authorize(AuthorizationRequest request) async { - final Map result = + Future authorize(AuthorizationRequest request) async { + final Map? result = await _channel.invokeMethod('authorize', request.toMap()); if (result == null) { return null; @@ -27,9 +27,9 @@ class MethodChannelFlutterAppAuth extends FlutterAppAuthPlatform { } @override - Future authorizeAndExchangeCode( + Future authorizeAndExchangeCode( AuthorizationTokenRequest request) async { - final Map result = await _channel.invokeMethod( + final Map? result = await _channel.invokeMethod( 'authorizeAndExchangeCode', request.toMap()); if (result == null) { return null; @@ -48,8 +48,8 @@ class MethodChannelFlutterAppAuth extends FlutterAppAuthPlatform { } @override - Future token(TokenRequest request) async { - final Map result = + Future token(TokenRequest request) async { + final Map? result = await _channel.invokeMethod('token', request.toMap()); if (result == null) { return null; diff --git a/flutter_appauth_platform_interface/lib/src/method_channel_mappers.dart b/flutter_appauth_platform_interface/lib/src/method_channel_mappers.dart index d0d6c464..814be0e9 100644 --- a/flutter_appauth_platform_interface/lib/src/method_channel_mappers.dart +++ b/flutter_appauth_platform_interface/lib/src/method_channel_mappers.dart @@ -6,9 +6,9 @@ import 'common_request_details.dart'; import 'grant_types.dart'; import 'token_request.dart'; -Map _convertCommonRequestDetailsToMap( +Map _convertCommonRequestDetailsToMap( CommonRequestDetails commonRequestDetails) { - return { + return { 'clientId': commonRequestDetails.clientId, 'issuer': commonRequestDetails.issuer, 'discoveryUrl': commonRequestDetails.discoveryUrl, @@ -21,7 +21,7 @@ Map _convertCommonRequestDetailsToMap( } extension AuthorizationRequestParameters on AuthorizationRequest { - Map toMap() { + Map toMap() { return _convertAuthorizationParametersToMap(this) ..addAll(_convertCommonRequestDetailsToMap(this)); } @@ -38,20 +38,20 @@ extension AuthorizationServiceConfigurationMapper } extension TokenRequestMapper on TokenRequest { - Map toMap() { + Map toMap() { return _convertTokenRequestToMap(this); } } extension AuthorizationTokenRequestMapper on AuthorizationTokenRequest { - Map toMap() { + Map toMap() { return _convertTokenRequestToMap(this) ..addAll(_convertAuthorizationParametersToMap(this)); } } -Map _convertTokenRequestToMap(TokenRequest tokenRequest) { - return { +Map _convertTokenRequestToMap(TokenRequest tokenRequest) { + return { 'clientSecret': tokenRequest.clientSecret, 'refreshToken': tokenRequest.refreshToken, 'authorizationCode': tokenRequest.authorizationCode, @@ -60,7 +60,7 @@ Map _convertTokenRequestToMap(TokenRequest tokenRequest) { }..addAll(_convertCommonRequestDetailsToMap(tokenRequest)); } -String _inferGrantType(TokenRequest tokenRequest) { +String? _inferGrantType(TokenRequest tokenRequest) { if (tokenRequest.grantType != null) { return tokenRequest.grantType; } @@ -75,9 +75,9 @@ String _inferGrantType(TokenRequest tokenRequest) { null, 'grantType', 'Grant type not specified and cannot be inferred'); } -Map _convertAuthorizationParametersToMap( +Map _convertAuthorizationParametersToMap( AuthorizationParameters authorizationParameters) { - return { + return { 'loginHint': authorizationParameters.loginHint, 'promptValues': authorizationParameters.promptValues, 'preferEphemeralSession': authorizationParameters.preferEphemeralSession, diff --git a/flutter_appauth_platform_interface/lib/src/token_request.dart b/flutter_appauth_platform_interface/lib/src/token_request.dart index 2bb2a82d..a2ae3130 100644 --- a/flutter_appauth_platform_interface/lib/src/token_request.dart +++ b/flutter_appauth_platform_interface/lib/src/token_request.dart @@ -7,13 +7,13 @@ class TokenRequest with CommonRequestDetails { String clientId, String redirectUrl, { this.clientSecret, - List scopes, - AuthorizationServiceConfiguration serviceConfiguration, - Map additionalParameters, + List? scopes, + AuthorizationServiceConfiguration? serviceConfiguration, + Map? additionalParameters, this.refreshToken, this.grantType, - String issuer, - String discoveryUrl, + String? issuer, + String? discoveryUrl, this.authorizationCode, this.codeVerifier, bool allowInsecureConnections = false, @@ -34,19 +34,19 @@ class TokenRequest with CommonRequestDetails { } /// The client secret. - final String clientSecret; + final String? clientSecret; /// The refresh token. - final String refreshToken; + final String? refreshToken; /// The grant type. /// /// If this is not specified then it will be inferred based on if [refreshToken] or [authorizationCode] has been specified. - final String grantType; + final String? grantType; /// The authorization code. - final String authorizationCode; + final String? authorizationCode; /// The code verifier to be sent with the authorization code. This should match the code verifier used when performing the authorization request - final String codeVerifier; + final String? codeVerifier; } diff --git a/flutter_appauth_platform_interface/lib/src/token_response.dart b/flutter_appauth_platform_interface/lib/src/token_response.dart index e4fd79f2..4e754825 100644 --- a/flutter_appauth_platform_interface/lib/src/token_response.dart +++ b/flutter_appauth_platform_interface/lib/src/token_response.dart @@ -10,24 +10,24 @@ class TokenResponse { ); /// The access token returned by the authorization server. - final String accessToken; + final String? accessToken; /// The refresh token returned by the authorization server. - final String refreshToken; + final String? refreshToken; /// Indicates when [accessToken] will expire. /// /// To ensure applications have continue to use valid access tokens, they /// will generally use the refresh token to get a new access token /// before it expires. - final DateTime accessTokenExpirationDateTime; + final DateTime? accessTokenExpirationDateTime; /// The id token returned by the authorization server. - final String idToken; + final String? idToken; /// The type of token returned by the authorization server. - final String tokenType; + final String? tokenType; /// Contains additional parameters returned by the authorization server from making the token request. - final Map tokenAdditionalParameters; + final Map? tokenAdditionalParameters; } diff --git a/flutter_appauth_platform_interface/pubspec.yaml b/flutter_appauth_platform_interface/pubspec.yaml index 208a2e9e..f0f54fa9 100644 --- a/flutter_appauth_platform_interface/pubspec.yaml +++ b/flutter_appauth_platform_interface/pubspec.yaml @@ -1,18 +1,18 @@ name: flutter_appauth_platform_interface description: A common platform interface for the flutter_appauth plugin. -version: 2.0.0 +version: 3.0.0 homepage: https://github.com/MaikuB/flutter_appauth/tree/master/flutter_appauth_platform_interface environment: - sdk: ">=2.6.0 <3.0.0" + sdk: '>=2.12.0-0 <3.0.0' flutter: ">=1.10.0" dependencies: flutter: sdk: flutter - plugin_platform_interface: ^1.0.2 + plugin_platform_interface: ^2.0.0 dev_dependencies: flutter_test: sdk: flutter - mockito: ^4.1.1 \ No newline at end of file + mockito: ^5.0.0-nullsafety.7 \ No newline at end of file diff --git a/flutter_appauth_platform_interface/test/method_channel_flutter_appauth_test.dart b/flutter_appauth_platform_interface/test/method_channel_flutter_appauth_test.dart index a8ca602e..8b3aca9c 100644 --- a/flutter_appauth_platform_interface/test/method_channel_flutter_appauth_test.dart +++ b/flutter_appauth_platform_interface/test/method_channel_flutter_appauth_test.dart @@ -27,7 +27,7 @@ void main() { expect( log, [ - isMethodCall('authorize', arguments: { + isMethodCall('authorize', arguments: { 'clientId': 'someClientId', 'issuer': null, 'redirectUrl': 'someRedirectUrl', @@ -51,7 +51,7 @@ void main() { expect( log, [ - isMethodCall('authorizeAndExchangeCode', arguments: { + isMethodCall('authorizeAndExchangeCode', arguments: { 'clientId': 'someClientId', 'issuer': null, 'redirectUrl': 'someRedirectUrl', @@ -87,7 +87,7 @@ void main() { expect( log, [ - isMethodCall('token', arguments: { + isMethodCall('token', arguments: { 'clientId': 'someClientId', 'issuer': null, 'redirectUrl': 'someRedirectUrl', @@ -113,7 +113,7 @@ void main() { expect( log, [ - isMethodCall('token', arguments: { + isMethodCall('token', arguments: { 'clientId': 'someClientId', 'issuer': null, 'redirectUrl': 'someRedirectUrl', @@ -138,7 +138,7 @@ void main() { expect( log, [ - isMethodCall('token', arguments: { + isMethodCall('token', arguments: { 'clientId': 'someClientId', 'issuer': null, 'redirectUrl': 'someRedirectUrl',