Skip to content

feat: Swift 6 strict concurrency compliance for WebAuth Part 2#1138

Open
sanchitmehtagit wants to merge 4 commits intodevelop/v3.0from
feat/swift6-strict-concurrency-webauth-part2
Open

feat: Swift 6 strict concurrency compliance for WebAuth Part 2#1138
sanchitmehtagit wants to merge 4 commits intodevelop/v3.0from
feat/swift6-strict-concurrency-webauth-part2

Conversation

@sanchitmehtagit
Copy link
Copy Markdown
Contributor

@sanchitmehtagit sanchitmehtagit commented Apr 8, 2026

Continues from #1123. Completes Swift 6 strict concurrency compliance for the WebAuth layer.

handles this : #1134

Changes

Auth0WebAuthfinal classstruct

  • Converted to struct to satisfy Sendable conformance without @unchecked Sendable
  • All builder methods now follow copy-and-return semantics (var copy = self)
  • lazy var redirectURL replaced with a computed property backed by _redirectURLlazy var is not Sendable-safe on structs and would cache a stale URL if useHTTPS() was called after first access
  • nonce removed as a mutable stored property; now computed from parameters (or generated randomly if absent), consistent with how state is handled
  • barrier is now let (immutable, safe to share across concurrency domains)
  • onCloseCallback type updated to @Sendable @MainActor () -> Void
  • presentationWindow property added for multi-window support

WebAuth protocol

  • Now inherits from Sendable
  • Async start() and logout(federated:) marked @MainActor
  • onClose(_:) callback parameter is now @Sendable

ASProvider

  • asProvider(...) factory marked @MainActor; accepts presentationWindow parameter
  • completionHandler wrapped in Task { @MainActor in } for safe actor hop
  • ASUserAgent converted to final class with Sendable conformance
  • currentSession and presentationWindow marked @MainActor
  • start() and finish(with:) dispatch via Task { @MainActor in }

Barrier / LoginTransaction

  • Barrier protocol now inherits from Sendable; QueueBarrier conforms via @unchecked Sendable
  • FinishTransaction typealias updated to @MainActor @Sendable

Combine start() publisher

  • Removed redundant Task { @MainActor in } wrapper — the callback-based start(_:) already dispatches to @MainActor internally; now consistent with how the logout() publisher is implemented

Migration guide (V3_MIGRATION_GUIDE.md)

  • Added "WebAuth is now Sendable" section covering the Sendable requirement for custom WebAuth conformances and the value semantics change — simplified around two clear cases: chaining (no change needed) vs imperative calls (must reassign return value)
  • Added "WebAuthProvider — now @Sendable @MainActor" to the typealiases section
  • Added "@mainactor on async Web Auth methods" section

Test plan

  • Build with -strict-concurrency=complete / Swift 6 mode — no concurrency warnings
  • Web Auth login and logout flows function correctly on iOS and macOS
  • Multi-window apps: presentationWindow(_:) presents the browser in the correct window
  • Ephemeral session flag is correctly propagated through the copy-based builder chain
  • Custom WebAuth mock/test double compiles after adding Sendable and @MainActor
  • Existing unit and integration tests pass

@sanchitmehtagit sanchitmehtagit added review:medium Medium review Swift v3.0 This label depicts this feature is part of Swift 3.0 Swift 6 compliance PR meany for Swift 6 strict concurrency compliance labels Apr 8, 2026
@sanchitmehtagit sanchitmehtagit marked this pull request as ready for review April 8, 2026 05:00
@sanchitmehtagit sanchitmehtagit requested a review from a team as a code owner April 8, 2026 05:00
Copy link
Copy Markdown
Contributor Author

@sanchitmehtagit sanchitmehtagit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update Examples.md

> .start { result in ... }
> ```
>
> Or reassign the return value when you need to configure conditionally:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webAuth = webAuth.presentationWindow(window)
We already have right examples in docs

Copy link
Copy Markdown
Contributor

@NandanPrabhu NandanPrabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add unit tests to ContentViewModel to check if webauth works correctly on conversion to struct

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

Labels

review:medium Medium review Swift v3.0 This label depicts this feature is part of Swift 3.0 Swift 6 compliance PR meany for Swift 6 strict concurrency compliance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants