Skip to content

Conversation

@luizgustavo09
Copy link

@luizgustavo09 luizgustavo09 commented Nov 17, 2025

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:

let client = try await UberAuth.login(context: context)

Key changes:

  • Added async/await methods to UberAuth, AuthProviding, and NetworkProvider
  • Old completion-based APIs remain functional

Testing

  • Added 18 new async/await unit tests covering full authentication flow
  • Updated all mocks to support async/await
  • Verified backward compatibility - existing completion-based code still works

@CLAassistant
Copy link

CLAassistant commented Nov 17, 2025

CLA assistant check
All committers have signed the CLA.

@luizgustavo09 luizgustavo09 changed the title [WIP] Add swift concurrency for auth flow Add swift concurrency for auth flow Dec 4, 2025
@luizgustavo09 luizgustavo09 marked this pull request as ready for review December 4, 2025 16:40
@luizgustavo09 luizgustavo09 force-pushed the refactor/main/swift-concurrency branch from a1e693b to 97fb0fe Compare December 4, 2025 16:44
completion: @escaping (Result<Client, UberAuthError>) -> ())

func execute(authDestination: AuthDestination,
prefill: Prefill?) async throws -> Client
Copy link
Contributor

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.

Copy link
Author

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

/// @mockable
public protocol AuthProviding {

@available(*, deprecated, message: "This method is deprecated. Use the async method instead.")
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Author

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 {
Copy link
Contributor

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.

Copy link
Author

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

@luizgustavo09 luizgustavo09 changed the title Add swift concurrency for auth flow [WIP] Add swift concurrency for auth flow Jan 19, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@luizgustavo09 luizgustavo09 force-pushed the refactor/main/swift-concurrency branch from 7ef52b7 to c0d2d1f Compare January 20, 2026 14:08
@luizgustavo09 luizgustavo09 changed the title [WIP] Add swift concurrency for auth flow Add swift concurrency for auth flow Jan 20, 2026

/// Public interface for the uber-auth-ios library
public final class UberAuth: AuthManaging {
public final class UberAuth: UberAuthInterface, UberAuthAsyncInterface, AuthManaging {
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants