-
-
Notifications
You must be signed in to change notification settings - Fork 199
fix(auth): replace trait with runtime configuration flag #844
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
Conversation
Replaces the EmitLocalSessionAsInitialSession trait with a runtime configuration flag to resolve compatibility issues with Xcode projects and align with Apple's trait guidelines. ## Changes - Added `emitLocalSessionAsInitialSession: Bool` property to `AuthClient.Configuration` - Defaults to `false` for backward compatibility - Will change to `true` in next major release - Replaced conditional compilation (`#if EmitLocalSessionAsInitialSession`) with runtime checks - Updated deprecation warning to reference the new configuration option - Added tests for both behaviors (old and new) - Removed `EmitLocalSessionAsInitialSession` trait from Package@swift-6.1.swift ## Benefits - Works in all project types (Xcode, SPM, CocoaPods) - No recompilation required to change behavior - Better discoverability through autocomplete and docs - Complies with Apple's trait guidelines (traits must be strictly additive) ## Migration Users who want the new behavior can now set: ```swift AuthClient( // ... other config emitLocalSessionAsInitialSession: true ) ``` Resolves compatibility issues where Xcode projects cannot enable package traits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds support for the emitLocalSessionAsInitialSession flag in SupabaseClientOptions.AuthOptions so users can configure this behavior when creating a SupabaseClient. - Added emitLocalSessionAsInitialSession property to SupabaseClientOptions.AuthOptions - Updated both initializers to include the new parameter - Pass the flag through to AuthClient initialization in SupabaseClient This ensures users can configure the flag whether they create an AuthClient directly or use SupabaseClient. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Pull Request Overview
This PR replaces the Swift 6.1 experimental package trait EmitLocalSessionAsInitialSession with a runtime configuration option emitLocalSessionAsInitialSession. This change provides a more accessible way for users to opt into the new behavior where the locally stored session is emitted immediately as the initial session, rather than waiting for a refresh attempt first.
Key changes:
- Removed the
Package@swift-6.1.swiftfile that used the experimental trait feature - Added
emitLocalSessionAsInitialSessionconfiguration parameter throughout the Auth client initialization chain - Replaced compile-time
#if EmitLocalSessionAsInitialSessionconditionals with runtimeif configuration.emitLocalSessionAsInitialSessionchecks - Updated tests to use the new runtime configuration instead of conditional compilation
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Package@swift-6.1.swift | Removed file that defined the experimental package trait |
| Sources/Auth/AuthClient.swift | Replaced conditional compilation directives with runtime checks based on the new configuration property |
| Sources/Auth/AuthClientConfiguration.swift | Added emitLocalSessionAsInitialSession configuration property with documentation |
| Sources/Supabase/Types.swift | Added emitLocalSessionAsInitialSession to auth options with default value for backward compatibility |
| Sources/Supabase/SupabaseClient.swift | Threaded through the new configuration parameter to AuthClient initialization |
| Tests/AuthTests/AuthClientTests.swift | Replaced conditional test expectations with separate test variants for both behavior modes |
|
Amazing! Thank you for looking into it so SWIFTly :) |
|
Seems to be working as intended. Going to production with it. Thanks! |
Summary
Replaces the
EmitLocalSessionAsInitialSessiontrait with a runtime configuration flag to resolve compatibility issues with Xcode projects and align with Apple's trait guidelines.Problem
The current trait-based approach has several issues:
Solution
Implemented a runtime configuration flag
emitLocalSessionAsInitialSession: BoolinAuthClient.Configuration:falsefor backward compatibilityChanges
emitLocalSessionAsInitialSession: Boolproperty toAuthClient.Configuration#if EmitLocalSessionAsInitialSession) with runtime checksEmitLocalSessionAsInitialSessiontrait from Package@swift-6.1.swiftMigration
Users who want the new behavior can now set:
Or using configuration:
Test Plan
swift build)Breaking Changes
None. The default behavior remains unchanged (
false). This will change totruein the next major release (v3.0.0).🤖 Generated with Claude Code