feat: Upgrade Auth0.swift to v3.0.2 - #909
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bumps the native iOS/macOS SDK dependency from 2.23.0 to 3.0.1 across the podspecs, Package.swift, and Package.resolved lockfiles, and updates every native call site for the v3 breaking changes: the Authentication -> MFAClient split for OTP login/MFA challenge, WebAuth.clearSession -> logout, CredentialsManager.store/clear becoming throwing calls, CredentialsManager.user -> userProfile(), UserInfo -> UserProfile, and Credentials.expiresIn -> expiresAt. Also updates the Dart-facing multifactorChallenge API: authenticatorId is now required and the types parameter is removed, since Auth0.swift v3's MFAClient.challenge(with:mfaToken:) has no equivalent for challenge-type filtering.
…test suite Fixes a remaining compile error in WebAuthLoginMethodHandler.swift: Auth0.swift v3 made WebAuthentication.safariProvider @MainActor-isolated, which broke the default-argument closure and its call site. Also adds UIScene support (SceneDelegate.swift + Info.plist manifest) and bumps the example app's CocoaPods deployment target to 15.0, both needed to actually launch the example app on current Xcode/iOS Simulator versions. Migrates the darwin plugin's XCTest suite (previously untouched by the v3 dependency bump) to the new SDK shape: Telemetry -> Auth0ClientInfo, UserInfo -> UserProfile, expiresIn -> expiresAt, throwing CredentialsStorage, Request<T,E> -> any Requestable/TokenRequestable (via new MockRequest/MockTokenRequest test doubles), the Authentication -> MFAClient split for OTP login and MFA challenge, and the new WebAuthError cases. All 358 RunnerTests unit tests pass.
The macOS test target was missing 8 MFA-related test files that are referenced by other test files. This caused compilation errors in GitHub Actions when building macOS tests, specifically: - SpyMFAClient not found (defined in MfaSpies.swift) - Other MFA test infrastructure missing Added the following test files to the macOS RunnerTests target: - MfaSpies.swift - MfaGetAuthenticatorsMethodHandlerTests.swift - MfaEnrollTotpMethodHandlerTests.swift - MfaEnrollPhoneMethodHandlerTests.swift - MfaEnrollEmailMethodHandlerTests.swift - MfaEnrollPushMethodHandlerTests.swift - MfaChallengeMethodHandlerTests.swift - MfaVerifyMethodHandlerTests.swift These files already existed in the iOS test target and are shared via relative path (../ios/Tests/Mfa/).
9c259b3 to
b78b3a2
Compare
| callback(self.credentialsManager.store(credentials: credentials)) | ||
| do { | ||
| try self.credentialsManager.store(credentials: credentials) | ||
| callback(true) |
There was a problem hiding this comment.
store now throws a typed CredentialsManagerError, but this collapses it to a bare false — the caller can't tell why the save failed. Map the caught error to a FlutterError, the way ClearApiCredentialsMethodHandler does in this same PR. Right now the two credential handlers are inconsistent and the new throwing contract buys nothing.
| callback(self.credentialsManager.clear()) | ||
| do { | ||
| try self.credentialsManager.clear() | ||
| callback(true) |
There was a problem hiding this comment.
Same issue: the thrown error is discarded. Either propagate FlutterError(from: CredentialsManagerError) or state why clear intentionally stays boolean-only.
| // were removed in Auth0.swift v3. These two method handlers use the dedicated `MFAClient` | ||
| // instead (see Auth0.swift's V3_MIGRATION_GUIDE.md), so they need an `MFAClient` rather than | ||
| // the `Authentication` client passed to every other handler here. | ||
| var mfaClientProvider: (_ account: Account) -> MFAClient = { account in |
There was a problem hiding this comment.
This bypasses everything clientProvider sets up (lines 55–65): no .using(inLibrary:version:) and no useDPoP(). So loginWithOTP and multifactorChallenge now go out without the SDK user-agent header, and ignore useDPoP even when the caller requested it. Apply the same using(...)/DPoP setup to the MFA client — note it needs the userAgent/arguments, which the current closure signature ((_ account: Account)) doesn't take.
| final String mfaToken; | ||
| final List<ChallengeType>? types; | ||
| final String? authenticatorId; | ||
| final String authenticatorId; |
There was a problem hiding this comment.
authenticatorId is now required and types removed on the shared platform-interface, but only the Swift native side is updated to match. Android's MultifactorChallengeApiRequestHandler.kt still reads request.data["types"] and treats authenticatorId as optional — after this merges, every Android multifactorChallenge call receives types == null and a shape it doesn't expect. The Dart signature change and the Android handler need to move together.
| dependencies: [ | ||
| .package(url: "https://github.com/auth0/Auth0.swift", exact: "2.23.0"), | ||
| .package(url: "https://github.com/auth0/JWTDecode.swift", exact: "3.3.0"), | ||
| .package(url: "https://github.com/auth0/Auth0.swift", from: "3.0.0"), |
There was a problem hiding this comment.
SPM floats to any 3.x here while the podspecs pin exact 3.0.1 (and the PR title says 3.0.2). SPM and CocoaPods consumers can resolve to different Auth0.swift builds and CI only exercises one. Pick one version and match it across Package.swift + all three podspecs.
|
|
||
| s.dependency 'Auth0', '2.23.0' | ||
| s.dependency 'JWTDecode', '3.3.0' | ||
| s.dependency 'Auth0', '3.0.1' |
There was a problem hiding this comment.
Two things on this line: (a) version mismatch with Package.swift's from: "3.0.0" and the 3.0.2 in the PR title — reconcile; (b) the 3.0 bump silently inherits Auth0.swift's new defaults (scope gaining offline_access, minTTL default 0 → 60), which are runtime behavior shifts for existing apps the moment this merges. Confirm intended or gate/document.
There was a problem hiding this comment.
Deleting these means the example apps re-resolve to whatever 3.x is newest on each build — non-reproducible. Regenerate pinned to the chosen version, or gitignore them deliberately.
…andlers now return flutter result on storing and clearing
Summary
Key Changes
Dependency Updates
API Migration
.webAuthError()to.authenticationError()for WebAuth errorsTest Suite Updates
Test Plan