Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Aug 8, 2025

What kind of change does this PR introduce?

Feature - implements identity linking functionality using OpenID Connect credentials.

What is the current behavior?

Currently, the Swift Auth client only supports signing in with OIDC credentials but doesn't provide a way to link additional identities to an existing user account using OIDC.

What is the new behavior?

  • Added linkIdentityWithIdToken method to AuthClient that allows linking an OIDC identity to the current user
  • Refactored existing signInWithIdToken method to support both sign-in and identity linking flows through an internal _signInWithIdToken helper
  • Added linkIdentity property to OpenIDConnectCredentials to distinguish between sign-in and linking operations
  • Improved code formatting consistency throughout the affected files

The new method follows the same pattern as other identity linking methods in the client.

Additional context

This implements the OIDC identity linking functionality referenced in the branch name (clibs-283). The implementation maintains backward compatibility while adding the new linking capability.

Close #588

🤖 Generated with Claude Code

@coveralls
Copy link

coveralls commented Aug 8, 2025

Pull Request Test Coverage Report for Build 17051035318

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 16 of 18 (88.89%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 77.47%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Sources/Auth/AuthClient.swift 15 17 88.24%
Files with Coverage Reduction New Missed Lines %
Sources/Auth/AuthClient.swift 1 88.54%
Totals Coverage Status
Change from base Build 16828663196: 0.03%
Covered Lines: 5529
Relevant Lines: 7137

💛 - Coveralls

grdsdev and others added 5 commits September 15, 2025 08:24
- Add linkIdentityWithIdToken method to AuthClient
- Refactor signInWithIdToken to support identity linking
- Add linkIdentity property to OpenIDConnectCredentials
- Improve code formatting consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove private _signInWithIdToken helper method
- Inline the implementation directly in linkIdentityWithIdToken
- Update test to include Authorization header in expected request
- Add session storage setup for linkIdentityWithIdToken test
@grdsdev grdsdev force-pushed the guilherme/clibs-283-supabase-swift-implement-linkidentity-with-oidc branch from da36f30 to 53609c6 Compare September 15, 2025 12:10
- Add event monitoring to verify userUpdated event is triggered
- Assert correct event sequence: [.initialSession, .userUpdated]
- Verify session state is properly updated
- Follow consistent testing pattern with other auth tests
- Add assertAuthStateChanges convenience methods to reduce code duplication
- Support both action-based and post-action event assertion patterns
- Refactor testSignOut, testSignInAnonymously, and testLinkIdentityWithIdToken to use new methods
- Improve test readability and maintainability
- Reduce boilerplate code in auth state change tests
- Remove expectedEventCount parameter from convenience methods
- Use expectedEvents.count to determine number of events to collect
- Reduces API surface and eliminates redundant parameter
- Makes the methods more intuitive and less error-prone
- Refactor testLinkIdentityWithIdToken to use action-based assertAuthStateChanges
- Add proper error location tracking with fileID, filePath, line, and column parameters
- Remove unused post-action assertAuthStateChanges method
- Improve test structure by combining action execution with event assertion
- Fix indentation in commented testGenerateLink_signUp test
- Replace _signIn helper with direct api.execute call
- Add explicit session manager update after successful API call
- Add explicit eventEmitter.emit(.userUpdated) for proper event handling
- Ensure consistent behavior with other identity linking methods
- Improve code clarity by removing unnecessary abstraction layer
@grdsdev grdsdev merged commit 661e321 into main Sep 15, 2025
19 checks passed
@grdsdev grdsdev deleted the guilherme/clibs-283-supabase-swift-implement-linkidentity-with-oidc branch September 15, 2025 14:06
supabase-releaser bot pushed a commit that referenced this pull request Sep 15, 2025
## [2.32.0](v2.31.2...v2.32.0) (2025-09-15)

### Features

* **auth:** implement linkIdentity with OIDC ([#776](#776)) ([661e321](661e321))
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.

Link apple identity natively
3 participants