-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added missing error codes for AuthException (#995)
* Add auth error codes enum * Add error code parameter for the auth exception * Handle error_code parameter * Add error_code for the getSessionFromUrl exception * Add basic asserts for error_codes * Replace AuthException with AuthSessionMissingException * Adjust logic to JS implementation. - Introduce api versioning - Change AuthErrorCode to ErrorCode * more alignment with the JS SDK * fix: use docker compose v2 * update auth server version and fix failing tests * fix failing test --------- Co-authored-by: dshukertjr <[email protected]>
- Loading branch information
1 parent
c68d44d
commit 4e0270a
Showing
14 changed files
with
412 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:gotrue/src/constants.dart'; | ||
import 'package:http/http.dart'; | ||
|
||
// Parses the API version which is 2YYY-MM-DD. */ | ||
const String _apiVersionRegex = | ||
r'^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])'; | ||
|
||
/// Represents the API versions supported by the package. | ||
/// Represents the API version specified by a [name] in the format YYYY-MM-DD. | ||
class ApiVersion { | ||
const ApiVersion({ | ||
required this.name, | ||
required this.timestamp, | ||
}); | ||
|
||
final String name; | ||
final DateTime timestamp; | ||
|
||
/// Parses the API version from the string date. | ||
static ApiVersion? fromString(String version) { | ||
if (!RegExp(_apiVersionRegex).hasMatch(version)) { | ||
return null; | ||
} | ||
|
||
final DateTime? timestamp = DateTime.tryParse('${version}T00:00:00.0Z'); | ||
if (timestamp == null) return null; | ||
return ApiVersion(name: version, timestamp: timestamp); | ||
} | ||
|
||
/// Parses the API version from the response headers. | ||
static ApiVersion? fromResponse(Response response) { | ||
final version = response.headers[Constants.apiVersionHeaderName]; | ||
return version != null ? fromString(version) : null; | ||
} | ||
|
||
/// Returns true if this version is the same or after [other]. | ||
bool isSameOrAfter(ApiVersion other) { | ||
return timestamp.isAfter(other.timestamp) || name == other.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.