Closed Widcket closed 8 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
253209a
) 96.08% compared to head (7e08c9b
) 95.79%. Report is 14 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
📋 Changes
Currently, both native implementations (iOS and Android) provide credentials to the Dart layer that include an
expiresAt
value formatted as ISO 8601 date with UTC time zone. More specifically, the format used follows the RFC 3339's profile of ISO 8601 dates, which is somewhat more restrictive for the sake of simplicity:Among the fields that the RFC 3339 deems mandatory (that ISO 8601 does not) is the time zone. So, a RFC 3339 date must contain time zone information to be valid. The native implementations, in particular, use UTC as the time zone.
Besides passing RFC 3339
expiresAt
dates to the Dart layer, the native implementations expect that anyexpiresAt
dates received from the Dart layer also to be RFC 3339 dates. But, here comes the problem: the Dart layer generates the date strings from a DateTime object. ADateTime
can either be set as "local" time, or can be set as UTC. That is, DartDateTime
objects do not support time zones other than UTC and "local". And by default, they'll be set as "local", meaning that when formatted as ISO 8601 dates, they won't be RFC 3339 compliant:We were not setting the
expiresAt
dates as UTC on the Dart layer. But still, this did not cause issues in most cases, because the Dart layer was dealing withexpiresAt
dates coming from the native implementations. As mentioned before, those are RFC 3339 compliant, and thus contain time zone information –theZ
that signals UTC. It only caused issues when dealing withDateTime
objects created externally, that were not set as UTC –e.g. as described in https://github.com/auth0/auth0-flutter/issues/304To fix this issue, this PR enforces UTC for all
expiresAt
dates either coming from the native layer or going to the native layer, in the Dart layer.📎 References
Fixes https://github.com/auth0/auth0-flutter/issues/304 See also https://ijmacd.github.io/rfc3339-iso8601/
🎯 Testing
Unit tests were added. The fix was also tested manually on both Android and iOS.