Skip to content

Commit b4b9c98

Browse files
authored
[flutter_appauth_platform_interface] cleanup API docs and format code (MaikuB#117)
* update API docs * migrate example app 's XCode project * update changelog * format constructors * Revert "migrate example app 's XCode project" This reverts commit 508eb65. * fix grammar in changelog * add more API docs around properties related to additional parameters * update wording for platform-specific properties
1 parent 8437fd2 commit b4b9c98

11 files changed

+94
-65
lines changed

flutter_appauth_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.0.3]
2+
3+
* Added `preferEphemeralSession` to `AuthorizationRequest` and `AuthorizationTokenRequest` classes. Thanks to the PR from [Matthew Smith](https://github.com/matthewtsmith).
4+
15
## [1.0.2]
26

37
* Fixes [issue #86](https://github.com/MaikuB/flutter_appauth/issues/86) where there was an error on casting `tokenAdditionalParameters` property upon calling the `token()` method. Thanks to the PR from [Sven](https://github.com/svendroid)

flutter_appauth_platform_interface/lib/src/authorization_parameters.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import 'mappable.dart';
22

33
mixin AuthorizationParameters on Mappable {
4-
/// Hint to the Authorization Server about the login identifier the End-User might use to log in
4+
/// Hint to the Authorization Server about the login identifier the End-User might use to log in.
55
String loginHint;
66

7-
/// list of ASCII string values that specifies whether the Authorization Server prompts the End-User for reauthentication and consent
7+
/// List of ASCII string values that specifies whether the Authorization Server prompts the End-User for reauthentication and consent.
88
List<String> promptValues;
99

10-
/// Whether to use an ephemeral session and not share the cookies across the OS
10+
/// Whether to use an ephemeral session that prevents cookies and other browser data being shared with the user's normal browser session.
1111
///
12-
/// iOS only
12+
/// This property is only applicable to iOS versions 13 and above.
1313
bool preferEphemeralSession;
1414

1515
@override

flutter_appauth_platform_interface/lib/src/authorization_request.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ import 'authorization_parameters.dart';
22
import 'authorization_service_configuration.dart';
33
import 'common_request_details.dart';
44

5-
/// The details of an authorization request to get an authorization code
5+
/// The details of an authorization request to get an authorization code.
66
class AuthorizationRequest extends CommonRequestDetails
77
with AuthorizationParameters {
8-
AuthorizationRequest(String clientId, String redirectUrl,
9-
{String loginHint,
10-
List<String> scopes,
11-
AuthorizationServiceConfiguration serviceConfiguration,
12-
Map<String, String> additionalParameters,
13-
String issuer,
14-
String discoveryUrl,
15-
List<String> promptValues,
16-
bool allowInsecureConnections = false,
17-
bool preferEphemeralSession = false}) {
8+
AuthorizationRequest(
9+
String clientId,
10+
String redirectUrl, {
11+
String loginHint,
12+
List<String> scopes,
13+
AuthorizationServiceConfiguration serviceConfiguration,
14+
Map<String, String> additionalParameters,
15+
String issuer,
16+
String discoveryUrl,
17+
List<String> promptValues,
18+
bool allowInsecureConnections = false,
19+
bool preferEphemeralSession = false,
20+
}) {
1821
this.clientId = clientId;
1922
this.redirectUrl = redirectUrl;
2023
this.scopes = scopes;
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
class AuthorizationResponse {
2-
AuthorizationResponse(this.authorizationCode, this.codeVerifier,
3-
this.authorizationAdditionalParameters);
2+
AuthorizationResponse(
3+
this.authorizationCode,
4+
this.codeVerifier,
5+
this.authorizationAdditionalParameters,
6+
);
47

5-
/// The authorization code
8+
/// The authorization code.
69
final String authorizationCode;
710

8-
/// The code verifier generated by AppAuth when issue the authorization request. Use this when exchanging the [authorizationCode] for a token
11+
/// The code verifier generated by AppAuth when issue the authorization request. Use this when exchanging the [authorizationCode] for a token.
912
final String codeVerifier;
1013

11-
/// Additional parameters included in the response
14+
/// Additional parameters included in the response.
1215
final Map<String, dynamic> authorizationAdditionalParameters;
1316
}

flutter_appauth_platform_interface/lib/src/authorization_service_configuration.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
class AuthorizationServiceConfiguration {
22
AuthorizationServiceConfiguration(
3-
this.authorizationEndpoint, this.tokenEndpoint)
4-
: assert(tokenEndpoint != null && authorizationEndpoint != null,
3+
this.authorizationEndpoint,
4+
this.tokenEndpoint,
5+
) : assert(tokenEndpoint != null && authorizationEndpoint != null,
56
'Must specify both the authorization and token endpoints');
67

78
final String authorizationEndpoint;

flutter_appauth_platform_interface/lib/src/authorization_token_request.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ import 'token_request.dart';
66
/// Details required for a combined authorization and code exchange request
77
class AuthorizationTokenRequest extends TokenRequest
88
with AuthorizationParameters {
9-
AuthorizationTokenRequest(String clientId, String redirectUrl,
10-
{String loginHint,
11-
String clientSecret,
12-
List<String> scopes,
13-
AuthorizationServiceConfiguration serviceConfiguration,
14-
Map<String, String> additionalParameters,
15-
String issuer,
16-
String discoveryUrl,
17-
List<String> promptValues,
18-
bool allowInsecureConnections = false,
19-
bool preferEphemeralSession = false})
20-
: super(
9+
AuthorizationTokenRequest(
10+
String clientId,
11+
String redirectUrl, {
12+
String loginHint,
13+
String clientSecret,
14+
List<String> scopes,
15+
AuthorizationServiceConfiguration serviceConfiguration,
16+
Map<String, String> additionalParameters,
17+
String issuer,
18+
String discoveryUrl,
19+
List<String> promptValues,
20+
bool allowInsecureConnections = false,
21+
bool preferEphemeralSession = false,
22+
}) : super(
2123
clientId,
2224
redirectUrl,
2325
clientSecret: clientSecret,
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import 'token_response.dart';
22

3-
/// The details from making a successful combined authorization and token exchange request
3+
/// The details from making a successful combined authorization and token exchange request.
44
class AuthorizationTokenResponse extends TokenResponse {
55
AuthorizationTokenResponse(
6-
String accessToken,
7-
String refreshToken,
8-
DateTime accessTokenExpirationDateTime,
9-
String idToken,
10-
String tokenType,
11-
this.authorizationAdditionalParameters,
12-
Map<String, dynamic> tokenAdditionalParameters)
13-
: super(accessToken, refreshToken, accessTokenExpirationDateTime, idToken,
6+
String accessToken,
7+
String refreshToken,
8+
DateTime accessTokenExpirationDateTime,
9+
String idToken,
10+
String tokenType,
11+
this.authorizationAdditionalParameters,
12+
Map<String, dynamic> tokenAdditionalParameters,
13+
) : super(accessToken, refreshToken, accessTokenExpirationDateTime, idToken,
1414
tokenType, tokenAdditionalParameters);
1515

16+
/// Contains additional parameters returned by the authorization server from making the authorization request.
1617
final Map<String, dynamic> authorizationAdditionalParameters;
1718
}

flutter_appauth_platform_interface/lib/src/common_request_details.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@ import 'authorization_service_configuration.dart';
22
import 'mappable.dart';
33

44
class CommonRequestDetails implements Mappable {
5-
/// The client id
5+
/// The client id.
66
String clientId;
77

8-
/// The issuer
8+
/// The issuer.
99
String issuer;
1010

11-
/// The URL of where the discovery document can be found
11+
/// The URL of where the discovery document can be found.
1212
String discoveryUrl;
1313

14-
/// The redirect URL
14+
/// The redirect URL.
1515
String redirectUrl;
1616

17-
/// The request scopes
17+
/// The request scopes.
1818
List<String> scopes;
1919

20-
/// The details of the OAuth 2.0 endpoints that can be explicitly when discovery isn't used or not possible
20+
/// The details of the OAuth 2.0 endpoints that can be explicitly when discovery isn't used or not possible.
2121
AuthorizationServiceConfiguration serviceConfiguration;
2222

23-
/// Additional parameters to include in the request
23+
/// Additional parameters to include in the request.
2424
Map<String, String> additionalParameters;
2525

26-
/// Whether to allow non-HTTPS endpoints (only applicable on Android)
26+
/// Whether to allow non-HTTPS endpoints.
27+
///
28+
/// This property is only applicable to Android.
2729
bool allowInsecureConnections;
2830

2931
@override

flutter_appauth_platform_interface/lib/src/flutter_appauth_platform.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ abstract class FlutterAppAuthPlatform extends PlatformInterface {
2828
_instance = instance;
2929
}
3030

31-
/// Convenience method for authorizing and then exchanges the authorization grant code
31+
/// Convenience method for authorizing and then exchanges the authorization grant code.
3232
Future<AuthorizationTokenResponse> authorizeAndExchangeCode(
3333
AuthorizationTokenRequest request) {
3434
throw UnimplementedError(
3535
'authorizeAndExchangeCode() has not been implemented');
3636
}
3737

38-
/// Sends an authorization request
38+
/// Sends an authorization request.
3939
Future<AuthorizationResponse> authorize(AuthorizationRequest request) {
4040
throw UnimplementedError('authorize() has not been implemented');
4141
}
4242

43-
/// For exchanging tokens
43+
/// For exchanging tokens.
4444
Future<TokenResponse> token(TokenRequest request) {
4545
throw UnimplementedError('token() has not been implemented');
4646
}

flutter_appauth_platform_interface/lib/src/token_request.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'authorization_service_configuration.dart';
22
import 'common_request_details.dart';
33
import 'grant_types.dart';
44

5-
/// Details for a token exchange request
5+
/// Details for a token exchange request.
66
class TokenRequest with CommonRequestDetails {
77
TokenRequest(
88
String clientId,
@@ -34,16 +34,18 @@ class TokenRequest with CommonRequestDetails {
3434
this.allowInsecureConnections = allowInsecureConnections;
3535
}
3636

37-
/// The client secret
37+
/// The client secret.
3838
final String clientSecret;
3939

40-
/// The refresh token
40+
/// The refresh token.
4141
final String refreshToken;
4242

43-
/// The grant type. This would be inferred if it hasn't been set based on if a refresh token or authorization code has been specified
43+
/// The grant type.
44+
///
45+
/// If this is not specified then it will be inferred based on if [refreshToken] or [authorizationCode] has been specified.
4446
final String grantType;
4547

46-
/// The authorization code
48+
/// The authorization code.
4749
final String authorizationCode;
4850

4951
/// The code verifier to be sent with the authorization code. This should match the code verifier used when performing the authorization request
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
/// Details from making a successful token exchange
22
class TokenResponse {
33
TokenResponse(
4-
this.accessToken,
5-
this.refreshToken,
6-
this.accessTokenExpirationDateTime,
7-
this.idToken,
8-
this.tokenType,
9-
this.tokenAdditionalParameters);
4+
this.accessToken,
5+
this.refreshToken,
6+
this.accessTokenExpirationDateTime,
7+
this.idToken,
8+
this.tokenType,
9+
this.tokenAdditionalParameters,
10+
);
1011

12+
/// The access token returned by the authorization server.
1113
final String accessToken;
1214

15+
/// The refresh token returned by the authorization server.
1316
final String refreshToken;
1417

18+
/// Indicates when [accessToken] will expire.
19+
///
20+
/// To ensure applications have continue to use valid access tokens, they
21+
/// will generally use the refresh token to get a new access token
22+
/// before it expires.
1523
final DateTime accessTokenExpirationDateTime;
1624

25+
/// The id token returned by the authorization server.
1726
final String idToken;
1827

28+
/// The type of token returned by the authorization server.
1929
final String tokenType;
2030

31+
/// Contains additional parameters returned by the authorization server from making the token request.
2132
final Map<String, dynamic> tokenAdditionalParameters;
2233
}

0 commit comments

Comments
 (0)