Fix all strong-mode warnings.
R=rnystrom@google.com, jmesserly@google.com
Review URL: https://codereview.chromium.org//1953643002 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e81b5c6..32df035 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# 1.0.2
+
+* Fix all strong-mode warnings.
+
+* Support `crypto` 1.0.0.
+
+* Support `http_parser` 3.0.0.
+
# 1.0.1
* Support `http_parser` 2.0.0.
diff --git a/lib/src/authorization_code_grant.dart b/lib/src/authorization_code_grant.dart
index 1cb45da..bd44c6a 100644
--- a/lib/src/authorization_code_grant.dart
+++ b/lib/src/authorization_code_grant.dart
@@ -240,7 +240,7 @@
Future<Client> _handleAuthorizationCode(String authorizationCode) async {
var startTime = new DateTime.now();
- var headers = {};
+ var headers = <String, String>{};
var body = {
"grant_type": "authorization_code",
diff --git a/lib/src/credentials.dart b/lib/src/credentials.dart
index 2a7087f..4531818 100644
--- a/lib/src/credentials.dart
+++ b/lib/src/credentials.dart
@@ -132,7 +132,7 @@
parsed['accessToken'],
refreshToken: parsed['refreshToken'],
tokenEndpoint: tokenEndpoint,
- scopes: scopes,
+ scopes: (scopes as List).map((scope) => scope as String),
expiration: expiration);
}
@@ -184,7 +184,7 @@
"endpoint.");
}
- var headers = {};
+ var headers = <String, String>{};
var body = {
"grant_type": "refresh_token",
diff --git a/lib/src/handle_access_token_response.dart b/lib/src/handle_access_token_response.dart
index c9e80fd..e0fb6f6 100644
--- a/lib/src/handle_access_token_response.dart
+++ b/lib/src/handle_access_token_response.dart
@@ -4,6 +4,7 @@
import 'dart:convert';
+import 'package:collection/collection.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
@@ -31,8 +32,10 @@
validate(condition, message) =>
_validate(response, tokenEndpoint, condition, message);
- var contentType = response.headers['content-type'];
- if (contentType != null) contentType = new MediaType.parse(contentType);
+ var contentTypeString = response.headers['content-type'];
+ var contentType = contentTypeString == null
+ ? null
+ : new MediaType.parse(contentTypeString);
// The spec requires a content-type of application/json, but some endpoints
// (e.g. Dropbox) serve it as text/javascript instead.
@@ -41,9 +44,12 @@
contentType.mimeType == "text/javascript"),
'content-type was "$contentType", expected "application/json"');
- var parameters;
+ Map<String, dynamic> parameters;
try {
- parameters = JSON.decode(response.body);
+ var untypedParameters = JSON.decode(response.body);
+ validate(untypedParameters is Map,
+ 'parameters must be a map, was "$parameters"');
+ parameters = DelegatingMap.typed(untypedParameters);
} on FormatException {
validate(false, 'invalid JSON');
}
@@ -71,7 +77,7 @@
'parameter "$name" was not a string, was "$value"');
}
- var scope = parameters['scope'];
+ var scope = parameters['scope'] as String;
if (scope != null) scopes = scope.split(" ");
var expiration = expiresIn == null ? null :
@@ -103,8 +109,11 @@
'with status ${response.statusCode}$reason.\n\n${response.body}');
}
- var contentType = response.headers['content-type'];
- if (contentType != null) contentType = new MediaType.parse(contentType);
+ var contentTypeString = response.headers['content-type'];
+ var contentType = contentTypeString == null
+ ? null
+ : new MediaType.parse(contentTypeString);
+
validate(contentType != null && contentType.mimeType == "application/json",
'content-type was "$contentType", expected "application/json"');
diff --git a/lib/src/resource_owner_password_grant.dart b/lib/src/resource_owner_password_grant.dart
index f67382b..5427ecc 100644
--- a/lib/src/resource_owner_password_grant.dart
+++ b/lib/src/resource_owner_password_grant.dart
@@ -45,7 +45,7 @@
"password": password
};
- var headers = {};
+ var headers = <String, String>{};
if (identifier != null) {
if (basicAuth) {
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index e7cc550..150fa17 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -4,8 +4,6 @@
import 'dart:convert';
-import 'package:crypto/crypto.dart';
-
/// Adds additional query parameters to [url], overwriting the original
/// parameters if a name conflict occurs.
Uri addQueryParameters(Uri url, Map<String, String> parameters) => url.replace(
@@ -13,5 +11,5 @@
String basicAuthHeader(String identifier, String secret) {
var userPass = Uri.encodeFull(identifier) + ":" + Uri.encodeFull(secret);
- return "Basic " + CryptoUtils.bytesToBase64(ASCII.encode(userPass));
+ return "Basic " + BASE64.encode(ASCII.encode(userPass));
}
diff --git a/pubspec.yaml b/pubspec.yaml
index bdf86d6..a8a05c0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: oauth2
-version: 1.0.2-dev
+version: 1.0.2
author: Dart Team <misc@dartlang.org>
homepage: http://github.com/dart-lang/oauth2
description: >
@@ -7,9 +7,10 @@
behalf of a user, and making authorized HTTP requests with the user's
OAuth2 credentials.
environment:
- sdk: '>=1.9.0 <2.0.0'
+ sdk: '>=1.13.0 <2.0.0'
dependencies:
+ collection: '^1.5.0'
http: '>=0.11.0 <0.12.0'
- http_parser: '>=1.0.0 <3.0.0'
+ http_parser: '>=1.0.0 <4.0.0'
dev_dependencies:
test: '>=0.12.0 <0.13.0'