You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(auth): replace trait with runtime configuration flag (#844)
* fix(auth): replace trait with runtime configuration flag
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>
* fix(auth): add emitLocalSessionAsInitialSession to SupabaseClientOptions
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>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Initial session emitted after attempting to refresh the local stored session.
1420
-
This is incorrect behavior and will be fixed in the next major release since it’s a breaking change.
1421
-
For now, if you want to opt-in to the new behavior, add the trait `EmitLocalSessionAsInitialSession` to your Package.swift file when importing the Supabase dependency.
1420
+
This is incorrect behavior and will be fixed in the next major release since it's a breaking change.
1421
+
To opt-in to the new behavior now, set `emitLocalSessionAsInitialSession: true` in your AuthClient configuration.
1422
1422
The new behavior ensures that the locally stored session is always emitted, regardless of its validity or expiration.
1423
1423
If you rely on the initial session to opt users in, you need to add an additional check for `session.isExpired` in the session.
1424
1424
1425
1425
Check https://github.com/supabase/supabase-swift/pull/822 for more information.
Copy file name to clipboardExpand all lines: Sources/Supabase/Types.swift
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,13 @@ public struct SupabaseClientOptions: Sendable {
57
57
/// Set to `true` if you want to automatically refresh the token before expiring.
58
58
publicletautoRefreshToken:Bool
59
59
60
+
/// When `true`, emits the locally stored session immediately as the initial session,
61
+
/// regardless of its validity or expiration. When `false`, emits the initial session
62
+
/// after attempting to refresh the local stored session (legacy behavior).
63
+
///
64
+
/// Default is `false` for backward compatibility. This will change to `true` in the next major release.
65
+
publicletemitLocalSessionAsInitialSession:Bool
66
+
60
67
/// Optional function for using a third-party authentication system with Supabase. The function should return an access token or ID token (JWT) by obtaining it from the third-party auth client library.
61
68
/// Note that this function may be called concurrently and many times. Use memoization and locking techniques if this is not supported by the client libraries.
62
69
/// When set, the `auth` namespace of the Supabase client cannot be used.
@@ -71,6 +78,7 @@ public struct SupabaseClientOptions: Sendable {
0 commit comments