Pass webClientId parameter to ios serverClientId config#24
Pass webClientId parameter to ios serverClientId config#24OrkhanAlikhanov wants to merge 1 commit intosbaiahmed1:mainfrom
webClientId parameter to ios serverClientId config#24Conversation
📝 WalkthroughWalkthroughThe change adds support for passing an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ios/GoogleAuth.swift`:
- Around line 40-41: Normalize webClientId before passing it to
createGoogleSignInConfiguration: trim whitespace and if the resulting string is
empty, set webClientId to nil so a blank/whitespace-only value is not forwarded
as serverClientID to GIDConfiguration; update the code around the webClientId
extraction and the call to createGoogleSignInConfiguration (and any parameter
named serverClientID inside that function) to use the trimmed-or-nil value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| let webClientId = params["webClientId"] as? String | ||
| let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Inspect webClientId extraction, validation, and serverClientID forwarding.
# Expected: webClientId should be normalized and/or validated before reaching GIDConfiguration.
rg -n -C3 'webClientId|serverClientID|isValidClientIdFormat|validateConfiguration' ios/GoogleAuth.swiftRepository: sbaiahmed1/react-native-google-auth
Length of output: 2862
Normalize webClientId before forwarding it as serverClientID.
Currently, webClientId is extracted without trimming or validation. A blank or whitespace-only value will be passed as a non-nil serverClientID to GIDConfiguration, silently misconfiguring the ID-token audience. Normalize blank values to nil by trimming whitespace and treating empty strings as absent, similar to the validation applied to iosClientId elsewhere in the function.
🛡️ Suggested normalization
- let webClientId = params["webClientId"] as? String
- let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)
+ let rawWebClientId = (params["webClientId"] as? String)?
+ .trimmingCharacters(in: .whitespacesAndNewlines)
+ let webClientId = rawWebClientId?.isEmpty == false ? rawWebClientId : nil
+ let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let webClientId = params["webClientId"] as? String | |
| let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain) | |
| let rawWebClientId = (params["webClientId"] as? String)? | |
| .trimmingCharacters(in: .whitespacesAndNewlines) | |
| let webClientId = rawWebClientId?.isEmpty == false ? rawWebClientId : nil | |
| let configuration = try createGoogleSignInConfiguration(clientId: clientId, webClientId: webClientId, hostedDomain: hostedDomain) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ios/GoogleAuth.swift` around lines 40 - 41, Normalize webClientId before
passing it to createGoogleSignInConfiguration: trim whitespace and if the
resulting string is empty, set webClientId to nil so a blank/whitespace-only
value is not forwarded as serverClientID to GIDConfiguration; update the code
around the webClientId extraction and the call to
createGoogleSignInConfiguration (and any parameter named serverClientID inside
that function) to use the trimmed-or-nil value.
Closes #23
Consequences of this PR? Not sure
Summary by CodeRabbit
New Features
Improvements