Skip to content
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
2 changes: 1 addition & 1 deletion docs/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ The latest version of the Universal Sign In package supports:
| | supported range |
| ------------ | --------------- |
| expo | 52.0.40 - 54 |
| react-native | 0.76.0 - 0.81 |
| react-native | 0.76.0 - 0.82 |

Use older versions of the package if you run older React Native / Expo.
36 changes: 32 additions & 4 deletions docs/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ There are 2 security-related features available:

## Custom nonce

_Currently available only in version 21.x of the package_.

[Nonce](https://en.wikipedia.org/wiki/Cryptographic_nonce) (number used once) is a security measure used to mitigate replay attacks and to associate a Client session with an ID Token.

The authorization APIs in [Universal Sign-In](/docs/one-tap) for Apple, Android and web allow you to specify a nonce.
The authorization APIs in [Universal Sign-In](/docs/one-tap) for Apple, Android and web allow you to specify nonce.

Example usage:

Expand All @@ -36,8 +38,8 @@ import TabItem from '@theme/TabItem';

[//]: # 'or use uuid v4 with react-native-get-random-values or expo-crypto'

<Tabs>
<TabItem value="expo-crypto" label="expo-crypto">
<Tabs queryString="expo-or-community">
<TabItem value="expo" label="expo-crypto">

```ts
import * as Crypto from 'expo-crypto';
Expand All @@ -57,7 +59,7 @@ export function getUrlSafeNonce(byteLength = 32) {

</TabItem>

<TabItem value="react-native-get-random-values" label="react-native-get-random-values">
<TabItem value="community" label="react-native-get-random-values">

```ts
import 'react-native-get-random-values';
Expand All @@ -82,6 +84,9 @@ export function getUrlSafeNonce(byteLength = 32) {

Auth providers such as [Supabase](https://supabase.com/docs/reference/javascript/auth-signinwithidtoken) require passing SHA-256 hash (digest) of the nonce ([source](https://github.com/supabase/auth-js/blob/dfb40d24188f7e8b0d34e51ded15582086250c51/src/lib/types.ts#L612)). This can be done as follows:

<Tabs queryString="expo-or-community">
<TabItem value="expo" label="expo-crypto">

```ts
import { digestStringAsync, CryptoDigestAlgorithm } from 'expo-crypto';

Expand All @@ -99,6 +104,29 @@ export const getNonce = async () => {
};
```

</TabItem>

<TabItem value="community" label="react-native-quick-crypto">

```ts
import QuickCrypto from 'react-native-quick-crypto';

const getNonce = () => {
// `rawNonce` goes to Supabase's signInWithIdToken().
// Supabase makes a hash of `rawNonce` and compares it with the `nonceDigest`
// which is included in the ID token from RN-google-signin.
const rawNonce = getUrlSafeNonce();
// `nonceDigest` (SHA-256 hash, hex-encoded) goes to the `nonce` parameter in RN-google-signin APIs
const nonceDigest = QuickCrypto.createHash('sha256')
.update(rawNonce)
.digest('hex');
return { rawNonce, nonceDigest };
};
```

</TabItem>
</Tabs>

## App Check for iOS (advanced) {#appcheck}

App Check helps protect your apps from abuse by preventing unauthorized clients from authenticating using Google Sign-in: only the apps you've authorized can acquire access tokens and ID tokens from Google's OAuth 2.0 and OpenID Connect endpoint.
Expand Down
6 changes: 5 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const config: Config = {

onBrokenLinks: 'throw',
onBrokenAnchors: 'throw',
onBrokenMarkdownLinks: 'throw',
markdown: {
hooks: {
onBrokenMarkdownLinks: 'throw',
},
},

// Even if you don't use internationalization, you can use this field to set
// useful metadata like html lang. For example, if your site is Chinese, you
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
"prettier:check": "prettier --list-different 'docs/**/*.{md,mdx}'"
},
"dependencies": {
"@docusaurus/core": "^3.8.1",
"@docusaurus/plugin-ideal-image": "^3.8.1",
"@docusaurus/preset-classic": "^3.8.1",
"@docusaurus/core": "^3.9.1",
"@docusaurus/plugin-ideal-image": "^3.9.1",
"@docusaurus/preset-classic": "^3.9.1",
"@mdx-js/react": "^3.1.1",
"clsx": "^2.1.1",
"docusaurus-lunr-search": "^3.6.1",
"prism-react-renderer": "^2.4.1",
"react": "^19.1.1",
"react-dom": "^19.1.1"
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@docusaurus/faster": "^3.8.1",
"@docusaurus/module-type-aliases": "^3.8.1",
"@docusaurus/tsconfig": "^3.8.1",
"@docusaurus/types": "^3.8.1",
"@types/react": "^19.1.12",
"@docusaurus/faster": "^3.9.1",
"@docusaurus/module-type-aliases": "^3.9.1",
"@docusaurus/tsconfig": "^3.9.1",
"@docusaurus/types": "^3.9.1",
"@types/react": "^19.2.2",
"docusaurus-plugin-typedoc": "^1.4.2",
"prettier": "^3.6.2",
"typedoc": "^0.28.11",
"typedoc-plugin-markdown": "^4.8.1",
"typedoc": "^0.28.14",
"typedoc-plugin-markdown": "^4.9.0",
"typescript": "~5.9.2"
},
"browserslist": {
Expand Down
Loading