-
Notifications
You must be signed in to change notification settings - Fork 125
Add swift concurrency for auth flow #330
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
base: develop
Are you sure you want to change the base?
Add swift concurrency for auth flow #330
Conversation
Merge develop into main
Adds a new public protocol to back UberAuth static methods
a1e693b to
97fb0fe
Compare
| completion: @escaping (Result<Client, UberAuthError>) -> ()) | ||
|
|
||
| func execute(authDestination: AuthDestination, | ||
| prefill: Prefill?) async throws -> Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine converting this to throwing, but we lose the typed error. Can we add some comments saying that it throws an UberAuthError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point I'll document it on the code
Sources/UberAuth/AuthProviding.swift
Outdated
| /// @mockable | ||
| public protocol AuthProviding { | ||
|
|
||
| @available(*, deprecated, message: "This method is deprecated. Use the async method instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the deprecation plan? Is there a version in the future that we will remove these in? Any plan to keep the async version and closure version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the plan is not to remove them, maybe we should explore a different set of protocols or maybe a separate asynchronous package so people can check out the one they need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s the plan. I want to eventually remove the completion-based methods, but I've kept them for this release to ensure stability. Since the async version hasn't been widely tested yet, this allows partners to keep using the SDK without being forced to downgrade if they run into bugs.
| public typealias AuthCompletion = (Result<Client, UberAuthError>) -> () | ||
|
|
||
| /// @mockable | ||
| public protocol UberAuthInterface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we split these into two different interfaces? As it stands, conformers would need to implement the async methods even if they don't support them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I’ll refactor these into two interfaces
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
7ef52b7 to
c0d2d1f
Compare
|
|
||
| /// Public interface for the uber-auth-ios library | ||
| public final class UberAuth: AuthManaging { | ||
| public final class UberAuth: UberAuthInterface, UberAuthAsyncInterface, AuthManaging { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting it up. I think we may have the same problem here though, where a caller will need to support asynchronous/await to even use UberAuth.
I am fine with keeping this however if we're willing to make this a requirement for future upgrades.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically since UberAuth conforms to the UberAuthInterface and UberAuthAsyncInterface it's basically the same.
To make them truly separate we'd need to either (1) create an UberAuth and a UberAuthAsync or (2) create a new separate UberAuthAsync framework in the Package.swift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline. Since we're only supporting 15+ now this should be fine
Description
This PR adds modern async/await versions of all authentication methods while maintaining full backward compatibility with existing completion-based APIs.
New public API:
Key changes:
UberAuth,AuthProviding, andNetworkProviderTesting