Skip to content

Commit 5e22705

Browse files
Francesco GiucastroFrancesco Giucastro
authored andcommitted
feat: update Google Sign-In package with new dependencies and documentation 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.
1 parent 16f2e57 commit 5e22705

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/google-signin/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npm install @forward-software/react-auth @forward-software/react-auth-google
1414

1515
### Platform requirements
1616

17-
**Web** - No additional dependencies. The package loads Google Identity Services (GSI) script automatically.
17+
**Web** - No additional dependencies. The package loads the Google Identity Services (GSI) script automatically (with a 10-second timeout).
1818

1919
**React Native / Expo** - Requires a development build (not compatible with Expo Go):
2020

@@ -97,6 +97,7 @@ const googleAuth = new GoogleAuthClient({
9797
ux_mode: 'popup', // 'popup' | 'redirect'
9898
redirect_uri: undefined, // required if ux_mode is 'redirect'
9999
hosted_domain: undefined, // restrict to a G Suite domain
100+
nonce: undefined, // binds the ID token to a session (replay attack prevention)
100101
});
101102
```
102103

@@ -203,7 +204,9 @@ const googleAuth = new GoogleAuthClient({
203204
});
204205
```
205206

206-
> **Note:** On React Native, a `storage` adapter is **required**. The adapter throws an error if none is provided. Use [react-native-mmkv](https://github.com/mrousavy/react-native-mmkv) (recommended) or wrap AsyncStorage with the `TokenStorage` interface.
207+
> **Note:** On React Native, `storage` is a **required** field in the TypeScript type. Your project will not compile without providing a `TokenStorage` implementation. Use [react-native-mmkv](https://github.com/mrousavy/react-native-mmkv) (recommended) or wrap AsyncStorage with the `TokenStorage` interface.
208+
>
209+
> **Android scopes:** Android Credential Manager does not support OAuth scopes directly. If you request scopes beyond `openid`, `profile`, and `email`, the adapter will include a `serverAuthCode` in the response. Exchange this code on your backend for scoped access tokens via the Google OAuth2 token endpoint.
207210
208211
### GoogleSignInButton (React Native)
209212

packages/google-signin/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"react-dom": "catalog:",
4242
"rimraf": "^6.1.3",
4343
"typescript": "catalog:",
44+
"@vitejs/plugin-react": "catalog:",
45+
"vite": "catalog:",
4446
"vitest": "^4.0.18"
4547
},
4648
"peerDependencies": {

packages/google-signin/src/web/GoogleSignInButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function GoogleSignInButton({
6666
err instanceof Error ? err : new Error('Failed to initialize Google Sign-In')
6767
);
6868
}
69-
}, [config.clientId, config.ux_mode, config.redirect_uri, config.hosted_domain, theme, size, text, shape, width]);
69+
}, [config.clientId, config.ux_mode, config.redirect_uri, config.hosted_domain, config.nonce, theme, size, text, shape, width]);
7070

7171
useEffect(() => {
7272
initialize();

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)