Skip to content

feat: Google Signin#211

Open
IronTony wants to merge 6 commits intomainfrom
feat/google-signin
Open

feat: Google Signin#211
IronTony wants to merge 6 commits intomainfrom
feat/google-signin

Conversation

@IronTony
Copy link
Member

Related Issue(s)

N/A

Motivation

The @forward-software/react-auth library currently lacks built-in support for Google Sign-In. Users who want Google authentication need to manually wire up their own adapter, handling platform differences between web and React Native themselves. This PR adds an official Google Sign-In package that works out of the box on both platforms.

Description of Changes

  • Added a new @forward-software/react-auth-google package under packages/google-signin/ that provides a Google Sign-In AuthClient adapter for both web and React Native
  • Implemented native modules for iOS (Swift) and Android (Kotlin) to handle Google Sign-In via platform-specific APIs (Google Identity Services on web, CocoaPods on iOS, Android Credential Manager on Android)
  • Added a GoogleSignInButton component with platform-specific implementations for easy drop-in integration
  • Included support for nonce parameter to protect against replay attacks, configurable OAuth scopes, and server auth code retrieval
  • Added unit tests for GoogleAuthClient on both web and native platforms
  • Updated pnpm-workspace.yaml and pnpm-lock.yaml to include the new package

How to Test

  1. CI Checks: Verify that all automated tests (Vitest) and build steps pass successfully on this PR.
  2. Local Verification (Optional):
    -- Run pnpm install (or equivalent).
    -- Run the development server (pnpm dev or equivalent) for the library or examples to ensure Vite starts correctly.
    -- Run a build (pnpm build or equivalent) to ensure it completes successfully.
  3. Package-specific tests: Run pnpm --filter @forward-software/react-auth-google test to execute the Google Sign-In unit tests.

Checklist

  • My code follows the project's style guidelines
  • I have added or updated tests to cover the changes
  • I have updated relevant documentation
  • All tests are passing locally
  • CI checks are passing
  • I have reviewed my own code and lock file changes
  • I have checked for any potential security implications
  • I have verified the changes work as expected

Notes for Reviewers

  • This is a new package, so there are no breaking changes to existing functionality.
  • The package uses platform-specific entry points (index.ts for web, index.native.ts for React Native) resolved automatically by the bundler.
  • expo-modules-core and react-native are optional peer dependencies, allowing the package to be used in web-only projects without pulling in native dependencies.
  • The web implementation loads the Google Identity Services script on-demand with a 10-second timeout.

- Introduced a new package  that provides a Google Sign-In adapter for both web and React Native.
- Implemented native modules for iOS and Android to handle Google Sign-In functionality.
- Added configuration options for client IDs and token management.
- Included a  component for easy integration in applications.
- Updated  and  to include the new package and its dependencies.

This addition enhances the authentication capabilities of the  library.
…ions

- Added support for requesting server auth code in the Android implementation to facilitate scoped access tokens.
- Updated iOS implementation to handle additional OAuth scopes during sign-in.
- Introduced nonce parameter in web configuration to enhance security against replay attacks.
- Removed storage requirement check from the native GoogleAuthClient constructor to simplify initialization.
…tation improvements

- Added '@vitejs/plugin-react' and 'vite' as dependencies in the package.json for better integration.
- Updated README to clarify the loading of Google Identity Services with a timeout and emphasized the required 'storage' field in TypeScript for React Native.
- Introduced a nonce parameter in the GoogleSignInButton component to enhance security against replay attacks.
- Refactored ID token retrieval to use guard statements, enhancing error handling by rejecting promises when no ID token is returned.
- Updated GoogleSignInButton to configure the module before signing in, ensuring proper initialization.
@IronTony IronTony force-pushed the feat/google-signin branch from c86ed9c to e45dd58 Compare March 13, 2026 18:45
@IronTony IronTony marked this pull request as ready for review March 13, 2026 18:46
@IronTony IronTony requested a review from panz3r as a code owner March 13, 2026 18:46
@panz3r panz3r requested review from Copilot and removed request for panz3r March 13, 2026 20:10
@panz3r panz3r self-requested a review March 13, 2026 20:12
Copy link

Copilot AI left a 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 introduces a new @forward-software/react-auth-google package to provide an official Google Sign-In AuthClient adapter and drop-in sign-in button for both Web (Google Identity Services) and React Native (Expo Modules + native iOS/Android implementations).

Changes:

  • Added a new packages/google-signin package with web + native GoogleAuthClient, GoogleSignInButton, and shared types.
  • Added Expo native modules for iOS (Swift + CocoaPods) and Android (Kotlin + Credential Manager) to perform Google Sign-In.
  • Added Vitest unit tests and updated the pnpm workspace to include packages/*.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Expands workspace globs to include packages/* so the new package is picked up.
packages/google-signin/vitest.config.ts Adds Vitest config for the new package.
packages/google-signin/tsconfig.json Adds TS build configuration for the new package.
packages/google-signin/test/test-utils.ts Adds mock storage + JWT helpers for tests.
packages/google-signin/test/GoogleAuthClient.web.spec.ts Adds unit tests for web GoogleAuthClient.
packages/google-signin/test/GoogleAuthClient.native.spec.ts Adds unit tests for native GoogleAuthClient with mocked Expo native module.
packages/google-signin/src/types.ts Defines cross-platform public types/configuration.
packages/google-signin/src/web/index.ts Web entry re-exports.
packages/google-signin/src/web/gsi.ts Web GSI script loader + typed wrapper helpers.
packages/google-signin/src/web/GoogleSignInButton.tsx Web sign-in button component based on GSI.
packages/google-signin/src/web/GoogleAuthClient.ts Web AuthClient implementation with storage persistence.
packages/google-signin/src/native/index.ts Native entry re-exports (including module namespace).
packages/google-signin/src/native/GoogleSignInModule.ts JS wrapper around the Expo native module.
packages/google-signin/src/native/GoogleSignInButton.tsx React Native sign-in button that triggers native sign-in.
packages/google-signin/src/native/GoogleAuthClient.ts Native AuthClient implementation with refresh support.
packages/google-signin/src/index.ts Default (web) package root entry.
packages/google-signin/src/index.native.ts React Native package root entry.
packages/google-signin/package.json Defines package metadata, build/test scripts, and conditional exports.
packages/google-signin/react-auth-google.podspec CocoaPods spec for iOS integration (package root).
packages/google-signin/ios/react-auth-google.podspec CocoaPods spec colocated under ios/.
packages/google-signin/ios/GoogleSignInModule.swift iOS Expo module implementation using GoogleSignIn.
packages/google-signin/expo-module.config.json Expo module registration for iOS/Android.
packages/google-signin/android/build.gradle Android library build config + dependencies.
packages/google-signin/android/src/main/java/expo/modules/googlesignin/GoogleSignInModule.kt Android Expo module implementation using Credential Manager + Google Identity.
packages/google-signin/README.md Package documentation and usage examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Added support for web GSI in package.json, allowing for better integration with web applications.
- Refactored ID token expiration extraction in both web and native clients to use a dedicated base64 URL decode method for improved readability and maintainability.
- Updated GoogleSignInButton to use a more specific type for the style prop, enhancing type safety.
- Improved error handling in the loadGsiScript function to manage script loading timeouts and errors more effectively.
- Introduced a new 'label' prop to the GoogleSignInButton, allowing users to customize the button text.
- Default label set to 'Sign in with Google' for improved user experience.
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.

2 participants