Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use strictly-typed result and error types [SDK-2977] #558

Merged
merged 4 commits into from
Dec 1, 2021
Merged

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Nov 30, 2021

Changes

⚠️ THIS PR CONTAINS BREAKING CHANGES

Currently, the Result type (aliased to Auth0Result) has the error typed as Error instead of the specific error type (e.g. WebAuthError, CredentialsManagerError, etc), so the error has to be casted, and the compiler cannot enforce that Web Auth only produces WebAuthError errors, and the Credentials Manager only produces CredentialsManagerError, and so on. This unnecessarily complicates the error handling and degrades the DX.

This PR replaces Auth0Result with more specific alternatives:

  • AuthenticationResult<T> -> Result<T, AuthenticationError>
  • ManagementResult<T> -> Result<T, ManagementError>
  • WebAuthResult<T> -> Result<T, WebAuthError>
  • CredentialsManagerResult<T> -> Result<T, CredentialsManagerError>

Additionally, the Credentials Manager was updated to use a Result type, like the rest of the library.

Testing

The Credentials Manager changes have been tested manually in test apps, by performing Web Auth login, saving the credentials, and then retrieving them, as follows:

Using Cocoapods

  • iOS 15.0 (simulator)
  • macOS 11.6.1
  • macOS 11.6.1 Catalyst

Using Carthage

  • iOS 15.0 (simulator)
  • macOS 11.6.1
  • macOS 11.6.1 Catalyst Carthage does not support building XCFrameworks for macCatalyst

Using SPM

  • iOS 15.0 (simulator)
  • macOS 11.6.1
  • macOS 11.6.1 Catalyst
  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@Widcket Widcket added the review:large Large review label Nov 30, 2021
@Widcket Widcket changed the title Use strictly-typed result and error types Use strictly-typed result and error types [SDK-2977] Dec 1, 2021
@Widcket Widcket marked this pull request as ready for review December 1, 2021 01:05
@Widcket Widcket requested a review from a team as a code owner December 1, 2021 01:05
@Widcket Widcket merged commit c08e936 into beta Dec 1, 2021
@Widcket Widcket deleted the v2/result-types branch December 1, 2021 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:large Large review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants