Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: apply fedcm migration #19

Merged
merged 3 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
quoteProps: 'consistent',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
};
19 changes: 15 additions & 4 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: "index"
title: "Module API"
sidebar_label: "Reference"
id: 'index'
title: 'Module API'
sidebar_label: 'Reference'
custom_edit_url: null
displayed_sidebar: apiSidebar
---
Expand Down Expand Up @@ -74,6 +74,17 @@ The following are available for the Web. [Read the value descriptions here](http

---

### OneTapCreateAccountParams

Ƭ **OneTapCreateAccountParams**: `Object` extends [`OneTapSignInParams`](#onetapsigninparams) with:

| Name | Type | Description |
| ----------------------------- | --------- | ----------------------------------------------------------------------------------------------- |
| `accountName?` | `string` | iOS only. An account name present on the device that should be used. |
| `requestVerifiedPhoneNumber?` | `boolean` | Android only. Whether to request for a verified phone number during sign-ups. False by default. |

---

### RequestAuthorizationParams

Ƭ **RequestAuthorizationParams**: `Object`
Expand Down Expand Up @@ -137,7 +148,7 @@ On the Web, the signatures of `signIn`, `presentExplicitSignIn`, and `createAcco
| :---------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- |
| `signIn` | (`params`: [`OneTapSignInParams`](#onetapsigninparams)) => `Promise`\<[`OneTapUser`](#onetapuser)\> |
| `presentExplicitSignIn` | (`params`: [`OneTapSignInParams`](#onetapsigninparams)) => `Promise`\<[`OneTapUser`](#onetapuser)\> |
| `createAccount` | (`params`: [`OneTapSignInParams`](#onetapsigninparams)) => `Promise`\<[`OneTapUser`](#onetapuser)\> |
| `createAccount` | (`params`: [`OneTapCreateAccountParams`](#onetapcreateaccountparams)) => `Promise`\<[`OneTapUser`](#onetapuser)\> |
| `requestAuthorization` | (`options`: [`RequestAuthorizationParams`](#requestauthorizationparams)) => `Promise`\<[`AuthorizationResponse`](#authorizationresponse)\> |
| `signOut` | (`emailOrUniqueId`: `string`) => `Promise`\<`null`\> |

Expand Down
2 changes: 1 addition & 1 deletion docs/buttons/native.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You may _not_ want to use it because it's not very visually appealing - but you
![signin button](/img/signin-button.png)

```tsx
import { GoogleSigninButton } from "@react-native-google-signin/google-signin";
import { GoogleSigninButton } from '@react-native-google-signin/google-signin';

<GoogleSigninButton
size={GoogleSigninButton.Size.Wide}
Expand Down
24 changes: 12 additions & 12 deletions docs/buttons/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ One-tap UI may not always be available: This happens if user has [opted out](htt
The Google Sign-In button serves as a fallback. Tapping it will open the regular Google Sign-In dialog.

```tsx
import { WebGoogleSigninButton } from "@react-native-google-signin/google-signin";
import { WebGoogleSigninButton } from '@react-native-google-signin/google-signin';

<WebGoogleSigninButton />;
```
Expand All @@ -27,14 +27,14 @@ import { WebGoogleSigninButton } from "@react-native-google-signin/google-signin

All props are optional.

| Name | Type | Description |
| ---------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `type?` | `"standard"` \| `"icon"` | Optional. The type of the sign-in button. |
| `theme?` | `"outline"` \| `"filled_blue"` \| `"filled_black"` | Optional. The theme of the sign-in button. |
| `size?` | `"large"` \| `"medium"` \| `"small"` | Optional. The size of the sign-in button. |
| `text?` | `"signin_with"` \| `"signup_with"` \| `"continue_with"` \| `"signin"` | Optional. The text to display on the sign-in button. |
| `shape?` | `"rectangular"` \| `"pill"` \| `"circle"` \| `"square"` | Optional. The shape of the sign-in button. |
| `width?` | `number` | Optional. The width of the sign-in button. |
| `locale?` | `string` | Optional. The locale for the sign-in button. |
| `logoAlignment?` | `"left"` \| `"center"` | Optional. The alignment of the logo on the button. |
| `onError?` | `(error: Error) => void` | Optional. Called when you try to render the button before the Client SDK is loaded. |
| Name | Type | Description |
| ---------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `type?` | `"standard"` \| `"icon"` | The type of the sign-in button. |
| `theme?` | `"outline"` \| `"filled_blue"` \| `"filled_black"` | The theme of the sign-in button. |
| `size?` | `"large"` \| `"medium"` \| `"small"` | The size of the sign-in button. |
| `text?` | `"signin_with"` \| `"signup_with"` \| `"continue_with"` \| `"signin"` | The text to display on the sign-in button. |
| `shape?` | `"rectangular"` \| `"pill"` \| `"circle"` \| `"square"` | The shape of the sign-in button. |
| `width?` | `number` | The width of the sign-in button. |
| `locale?` | `string` | The locale for the sign-in button. |
| `logoAlignment?` | `"left"` \| `"center"` | The alignment of the logo on the button. |
| `onError?` | `(error: Error) => void` | Called when you try to render the button before the Client SDK is loaded. |
16 changes: 8 additions & 8 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TypeScript helper to check if the passed parameter is an instance of `Error` whi
import {
isErrorWithCode,
GoogleSignin,
} from "@react-native-google-signin/google-signin";
} from '@react-native-google-signin/google-signin';

try {
const userInfo = await GoogleSignin.signIn();
Expand All @@ -31,7 +31,7 @@ try {
### Status Codes

```ts
import { statusCodes } from "@react-native-google-signin/google-signin";
import { statusCodes } from '@react-native-google-signin/google-signin';
```

Status codes are useful when determining which kind of error has occurred during the sign-in process. Under the hood, these constants are derived from native GoogleSignIn error codes and are platform-specific. Always compare `error.code` to `statusCodes.*` and do not rely on the raw value of `error.code`.
Expand All @@ -40,16 +40,16 @@ See [example usage](original#signin).

| Name | Description |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SIGN_IN_CANCELLED` | When user cancels the sign in flow |
| `IN_PROGRESS` | Trying to invoke another operation (e.g. `signInSilently`) when previous one has not yet finished. If you call e.g. `signInSilently` twice, 2 calls to `signInSilently` in the native module will be done. The promise from the first call to `signInSilently` will be rejected with this error, and the second will resolve / reject with the result of the native module. |
| `SIGN_IN_CANCELLED` | When user cancels the sign in flow. On the Web, this is also returned while [cooldown period](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown) is active. Detecting the cooldown period itself is not possible on the Web for user privacy reasons. On Android, it can be detected via `ONE_TAP_START_FAILED`. |
| `IN_PROGRESS` | Trying to invoke another operation (e.g. `signInSilently`) when previous one has not yet finished. If you call e.g. `signInSilently` twice, two calls to `signInSilently` in the native module will be done. The promise from the first call to `signInSilently` will be rejected with this error, and the second will resolve / reject with the result of the native call. |
| `SIGN_IN_REQUIRED` | Useful for use with `signInSilently()` - no user has signed in yet. This error does not happen with one-tap sign in (instead see `NO_SAVED_CREDENTIAL_FOUND`). |
| `PLAY_SERVICES_NOT_AVAILABLE` | Play services are not available or outdated. This happens on Android, or on the Web when you're calling the exposed APIs [before the Client library is loaded](setting-up/web). |

### Status codes specific to One-tap sign in

| Name | Description |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ONE_TAP_START_FAILED` | Thrown when the One-tap sign in UI cannot be presented. This would typically happen during the [cooldown period](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown). You can still call the original Google Sign In API in this case. |
| `NO_SAVED_CREDENTIAL_FOUND` | Android and Apple only (Web shows the one-tap UI instead). Thrown when no user signed in to your app yet. To recover from this error, proceed to calling [`createAccount`](one-tap#createaccount). |
| Name | Description |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ONE_TAP_START_FAILED` | Thrown only on Android or Web when the One-tap sign in UI cannot be presented. On Android, this happens during the [cooldown period](https://developers.google.com/identity/gsi/web/guides/features#exponential_cooldown). You can still call `presentExplicitSignIn` on Android or render `WebGoogleSigninButton` on Web as a fallback. |
| `NO_SAVED_CREDENTIAL_FOUND` | Android and Apple only (Web shows the one-tap UI instead). Thrown when no user signed in to your app yet. To recover from this error, proceed to calling [`createAccount`](one-tap#createaccount). |

See [example usage](one-tap#signin).
6 changes: 3 additions & 3 deletions docs/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Three steps are needed to access the sponsor package, which is hosted on [GitHub

3. Set up your package manager so that it fetches the package from the GH packages registry instead of the public registry. In this example, we're using an `NPM_TOKEN_GOOGLE_SIGN_IN` environment variable.

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="classic" label="npm / yarn v1">
Expand All @@ -54,7 +54,7 @@ import TabItem from "@theme/TabItem";
npmScopes:
react-native-google-signin:
npmRegistryServer: https://npm.pkg.github.com
npmAuthToken: "${NPM_TOKEN_GOOGLE_SIGN_IN}"
npmAuthToken: '${NPM_TOKEN_GOOGLE_SIGN_IN}'
```

</TabItem>
Expand Down
19 changes: 9 additions & 10 deletions docs/one-tap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 30
sidebar_class_name: sponsor-heart
---

import Image from "@theme/IdealImage";
import Image from '@theme/IdealImage';

# One-tap Google sign in

Expand All @@ -18,7 +18,7 @@ This is the easiest and recommended way to implement Google Sign In. It is a sig
:::tip
The functionality covered in this page is only available to sponsors️. [It takes just a few clicks to get access](install#accessing-the-private-package-for-sponsors) ❤️.

This module is being actively developed, and new features are added regularly. Since the first release in July 2023, there has been more than 1 release per month on average (last updated in June 2024).
This module is being actively developed, and new features are added regularly. Since the first release in July 2023, there has been more than 1 release per month on average (last updated in July 2024).
:::

Note that on Apple and Android, you can combine the one-tap methods with those one from the [Original Google Sign In](original). To do that, use the One-tap sign in to sign in the user. Then call `signInSilently()` and then (for example) `getCurrentUser()` to get the current user's information. However, this shouldn't be necessary because this module should cover all your needs. Please open an issue if that's not the case.
Expand All @@ -28,7 +28,7 @@ import {
GoogleOneTapSignIn,
statusCodes,
type OneTapUser,
} from "@react-native-google-signin/google-signin";
} from '@react-native-google-signin/google-signin';
```

### `signIn`
Expand Down Expand Up @@ -57,7 +57,7 @@ import {
statusCodes,
isErrorWithCode,
GoogleSignin,
} from "@react-native-google-signin/google-signin";
} from '@react-native-google-signin/google-signin';

// Somewhere in your code
const signIn = async () => {
Expand All @@ -78,9 +78,8 @@ const signIn = async () => {
// sign in was cancelled
break;
case statusCodes.ONE_TAP_START_FAILED:
// Android and Web only, you probably have hit rate limiting.
// Android-only, you probably have hit rate limiting.
// On Android, you can still call `presentExplicitSignIn` in this case.
// On the web, user needs to click the `WebGoogleSigninButton` to sign in.
break;
case statusCodes.PLAY_SERVICES_NOT_AVAILABLE:
// Android-only: play services not available or outdated
Expand All @@ -98,7 +97,7 @@ const signIn = async () => {

### `createAccount`

signature: (`params`: [`OneTapSignInParams`](api#onetapsigninparams)) => `Promise`\<[`OneTapUser`](api#onetapuser)\>
signature: (`params`: [`OneTapCreateAccountParams`](api#onetapcreateaccountparams)) => `Promise`\<[`OneTapUser`](api#onetapuser)\>

| Platform | Behavior |
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -124,7 +123,7 @@ Returns a `Promise` that resolves with an object containing the user data or rej
```ts
await GoogleOneTapSignIn.createAccount({
webClientId: `autoDetect`, // works only if you use Firebase
nonce: "your_nonce",
nonce: 'your_nonce',
});
```

Expand Down Expand Up @@ -154,7 +153,7 @@ Call this method only as a reaction to when user taps a "sign in with Google" bu
```ts
await GoogleOneTapSignIn.presentExplicitSignIn({
webClientId: `autoDetect`, // works only if you use Firebase
nonce: "your_nonce",
nonce: 'your_nonce',
});
```

Expand Down Expand Up @@ -244,7 +243,7 @@ You should display the One Tap UI on page load or other window events, instead o

```ts
useEffect(() => {
if (Platform.OS === "web") {
if (Platform.OS === 'web') {
// use callback-based api on the web!
GoogleOneTapSignIn.signIn(
{
Expand Down
Loading