Conversation
📝 WalkthroughWalkthroughReplaced Base64 decoding implementation in Android module from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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.
🧹 Nitpick comments (1)
android/src/main/java/com/googleauth/GoogleAuthModule.kt (1)
867-867: Specify UTF-8 charset explicitly when decoding JWT payload.
String(ByteArray)uses the platform default charset. JWT payloads are defined as UTF-8 JSON. While the default is almost always UTF-8 on Android, it's safer to be explicit.Proposed fix
- val payload = String(Base64.decode(parts[1], Base64.URL_SAFE)) + val payload = String(Base64.decode(parts[1], Base64.URL_SAFE), Charsets.UTF_8)Apply in both
parseTokenExpiration(Line 867) andextractEmailFromIdToken(Line 883).Also applies to: 883-883
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@android/src/main/java/com/googleauth/GoogleAuthModule.kt` at line 867, The JWT payload is decoded using the platform default charset; update both parseTokenExpiration and extractEmailFromIdToken to construct the String from the decoded bytes with an explicit UTF-8 charset (use the result of Base64.decode(parts[1], Base64.URL_SAFE) and pass it to String(..., Charsets.UTF_8)) so the JWT JSON is always interpreted as UTF-8.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@android/src/main/java/com/googleauth/GoogleAuthModule.kt`:
- Line 867: The JWT payload is decoded using the platform default charset;
update both parseTokenExpiration and extractEmailFromIdToken to construct the
String from the decoded bytes with an explicit UTF-8 charset (use the result of
Base64.decode(parts[1], Base64.URL_SAFE) and pass it to String(...,
Charsets.UTF_8)) so the JWT JSON is always interpreted as UTF-8.
Summary
This PR replaces the usage of
java.util.Base64withandroid.util.Base64to ensure full compatibility across all supported Android API levels.Problem
java.util.Base64is not available to android SDK < 26, but the minSdk is 24. This results injava.lang.NoClassDefFoundError: java.util.Base64that stops google auth process.Proposed Solution
java.util.Base64with the most appropriateandorid.util.Base64in order to grant backwards compatibility to < 26 android versions.Testing
Summary by CodeRabbit