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
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ Now, create a helper file to initialize the Supabase client for both web and Rea
queryGroup="auth-store"
>
<TabPanel id="async-storage" label="AsyncStorage">

<$CodeSample
path="/auth/expo-social-auth/lib/supabase.web.ts"
lines={[[1, -1]]}
meta="name=lib/supabase.web.ts"
/>
/>

</TabPanel>
<TabPanel id="secure-store" label="SecureStore">

If you want to encrypt the user's session information, use `aes-js` and store the encryption key in [Expo SecureStore](https://docs.expo.dev/versions/latest/sdk/securestore). The [`aes-js` library](https://github.com/ricmoo/aes-js) is a reputable JavaScript-only implementation of the AES encryption algorithm in CTR mode. A new 256-bit encryption key is generated using the `react-native-get-random-values` library. This key is stored inside Expo's SecureStore, while the value is encrypted and placed inside AsyncStorage.

Make sure that:

- You keep the `expo-secure-storage`, `aes-js` and `react-native-get-random-values` libraries up-to-date.
- Choose the correct [`SecureStoreOptions`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestoreoptions) for your app's needs. E.g. [`SecureStore.WHEN_UNLOCKED`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestorewhen_unlocked) regulates when the data can be accessed.
- Carefully consider optimizations or other modifications to the above example, as those can lead to introducing subtle security vulnerabilities.
Expand All @@ -75,8 +77,7 @@ Now, create a helper file to initialize the Supabase client for both web and Rea
path="/auth/expo-social-auth/lib/supabase.ts"
lines={[[1, -1]]}
meta="name=lib/supabase.ts"

/>
/>

</TabPanel>
</Tabs>
Expand All @@ -89,7 +90,7 @@ These variables are safe to expose in your Expo app since Supabase has [Row Leve
Create a `.env` file containing these variables:

<$CodeSample
path="/auth/expo-social-auth/.env"
path="/auth/expo-social-auth/.env.template"
lines={[[1, -1]]}
meta="name=.env"
/>
Expand Down Expand Up @@ -162,8 +163,9 @@ Wrap the navigation with the `AuthProvider` and `SplashScreenController`.

Using [Expo Router's protected routes](https://docs.expo.dev/router/advanced/authentication/#using-protected-routes), you can secure navigation:

{/* prettier-ignore */}
<$CodeSample
path="/auth/expo-social-auth/app/\_layout.tsx"
path="/auth/expo-social-auth/app/_layout.tsx"
lines={[[1, -1]]}
meta="name=app/\_layout.tsx"
/>
Expand Down Expand Up @@ -197,22 +199,22 @@ Start by adding the button inside the login screen:
<$CodeTabs>

```tsx name=app/login.tsx
...
import AppleSignInButton from '@/components/social-auth-buttons/apple/apple-sign-in-button';
...
export default function LoginScreen() {
return (
<>
<Stack.Screen options={{ title: 'Login' }} />
<ThemedView style={styles.container}>
...
<AppleSignInButton />
...
</ThemedView>
</>
);
}
...
```

</$CodeTabs>
Expand Down Expand Up @@ -269,9 +271,11 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s

Then create the iOS specific button component `AppleSignInButton`:

<$CodeSample path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.ios.tsx" lines={[[1, -1]]} meta="name=components/social-auth-buttons/apple/apple-sign-in-button.ios.tsx"

/>
<$CodeSample
path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.ios.tsx"
lines={[[1, -1]]}
meta="name=components/social-auth-buttons/apple/apple-sign-in-button.ios.tsx"
/>

<Admonition type="note">

Expand All @@ -280,9 +284,9 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s
<$CodeTabs>

```tsx name=components/social-auth-buttons/apple/apple-sign-in-button.ios.tsx
...
const credentialState = await appleAuth.getCredentialStateForUser(appleAuthRequestResponse.user);
...
```

</$CodeTabs>
Expand All @@ -297,13 +301,13 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s
```json name=app.json
{
"expo": {
...
"ios": {
...
"usesAppleSignIn": true
...
},
...
}
}
```
Expand Down Expand Up @@ -357,9 +361,11 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s

Next, create the Android-specific `AppleSignInButton` component:

<$CodeSample path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.android.tsx" lines={[[1, -1]]} meta="name=components/social-auth-buttons/apple/apple-sign-in-button.android.tsx"

/>
<$CodeSample
path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.android.tsx"
lines={[[1, -1]]}
meta="name=components/social-auth-buttons/apple/apple-sign-in-button.android.tsx"
/>

You should now be able to test the authentication by running it on a physical device or simulator:

Expand Down Expand Up @@ -392,9 +398,11 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s

Next, create the Web-specific `AppleSignInButton` component:

<$CodeSample path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.web.tsx" lines={[[1, -1]]} meta="name=components/social-auth-buttons/apple/apple-sign-in-button.web.tsx"

/>
<$CodeSample
path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.web.tsx"
lines={[[1, -1]]}
meta="name=components/social-auth-buttons/apple/apple-sign-in-button.web.tsx"
/>

Test the authentication in your browser using the tunneled HTTPS URL:

Expand Down Expand Up @@ -425,14 +433,14 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s
```json name=app.json
{
"expo": {
...
"ios": {
...
"usesAppleSignIn": true
...
},
"plugins": ["expo-apple-authentication"]
...
}
}
```
Expand All @@ -441,9 +449,11 @@ For more information, follow the [Supabase Login with Apple](/docs/guides/auth/s

Then create the iOS specific button component `AppleSignInButton`:

<$CodeSample path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.tsx" lines={[[1, -1]]} meta="name=components/social-auth-buttons/apple/apple-sign-in-button.tsx"

/>
<$CodeSample
path="/auth/expo-social-auth/components/social-auth-buttons/apple/apple-sign-in-button.tsx"
lines={[[1, -1]]}
meta="name=components/social-auth-buttons/apple/apple-sign-in-button.tsx"
/>

<Admonition type="note">

Expand All @@ -461,22 +471,22 @@ Start by adding the button to the login screen:
<$CodeTabs>

```tsx name=app/login.tsx
...
import GoogleSignInButton from '@/components/social-auth-buttons/google/google-sign-in-button';
...
export default function LoginScreen() {
return (
<>
<Stack.Screen options={{ title: 'Login' }} />
<ThemedView style={styles.container}>
...
<GoogleSignInButton />
...
</ThemedView>
</>
);
}
...
```

</$CodeTabs>
Expand All @@ -485,7 +495,7 @@ For Google authentication, you can choose between the following options:

- [GN Google Sign In Premium](https://react-native-google-signin.github.io/docs/install#sponsor-only-version) - that supports iOS, Android, and Web by using the latest Google's One Tap sign-in (but [it requires a subscription](https://universal-sign-in.com/))
- [@react-oauth/google](https://github.com/MomenSherif/react-oauth#googlelogin) - that supports Web (so it's not a good option for mobile, but it works)
- Relying on the [``signInWithOAuth](/docs/reference/javascript/auth-signinwithoauth) function of the Supabase Auth - that also supports iOS, Android and Web (useful also to manage any other OAuth provider)
- Relying on the [`signInWithOAuth`](/docs/reference/javascript/auth-signinwithoauth) function of the Supabase Auth - that also supports iOS, Android and Web (useful also to manage any other OAuth provider)

<Admonition type="note">

Expand All @@ -510,13 +520,16 @@ EXPO_PUBLIC_GOOGLE_AUTH_WEB_CLIENT_ID="YOUR_GOOGLE_AUTH_WEB_CLIENT_ID"
defaultActiveId="web"
queryGroup="google-authentication"
>
<TabPanel id="mobile" label="Mobile">

Create the mobile generic button component `GoogleSignInButton`:
<TabPanel id="mobile" label="Mobile">

<$CodeSample path="/auth/expo-social-auth/components/social-auth-buttons/google/google-sign-in-button.tsx" lines={[[1, -1]]} meta="name=components/social-auth-buttons/google/google-sign-in-button.tsx"
Create the mobile generic button component `GoogleSignInButton`:

/>
<$CodeSample
path="/auth/expo-social-auth/components/social-auth-buttons/google/google-sign-in-button.tsx"
lines={[[1, -1]]}
meta="name=components/social-auth-buttons/google/google-sign-in-button.tsx"
/>

Finally, update the iOS and Android projects by running the Expo prebuild command:

Expand Down Expand Up @@ -550,18 +563,18 @@ EXPO_PUBLIC_GOOGLE_AUTH_WEB_CLIENT_ID="YOUR_GOOGLE_AUTH_WEB_CLIENT_ID"
```json name=app.json
{
"expo": {
...
"plugins": {
...
"plugins": [
[
"expo-web-browser",
{
"experimentalLauncherActivity": false
}
]
...
},
...
],
}
}
```
Expand All @@ -570,9 +583,11 @@ EXPO_PUBLIC_GOOGLE_AUTH_WEB_CLIENT_ID="YOUR_GOOGLE_AUTH_WEB_CLIENT_ID"

Then create the iOS specific button component `GoogleSignInButton`:

<$CodeSample path="/auth/expo-social-auth/components/social-auth-buttons/google/google-sign-in-button.web.tsx" lines={[[1, -1]]} meta="name=components/social-auth-buttons/google/google-sign-in-button.web.tsx"

/>
<$CodeSample
path="/auth/expo-social-auth/components/social-auth-buttons/google/google-sign-in-button.web.tsx"
lines={[[1, -1]]}
meta="name=components/social-auth-buttons/google/google-sign-in-button.web.tsx"
/>

Test the authentication in your browser using the tunnelled HTTPS URL:

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/resources/globalSearch/globalSearchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function createModelFromMatch({
} else {
return null
}
case 'github-discussions':
case 'troubleshooting':
return new TroubleshootingModel({
title: page_title,
href,
Expand Down
3 changes: 0 additions & 3 deletions apps/docs/scripts/search/generate-embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ async function generateEmbeddings() {
}

requireEnvOrThrow([
'DOCS_GITHUB_APP_ID',
'DOCS_GITHUB_APP_INSTALLATION_ID',
'DOCS_GITHUB_APP_PRIVATE_KEY',
'NEXT_PUBLIC_MISC_ANON_KEY',
'NEXT_PUBLIC_MISC_URL',
'NEXT_PUBLIC_SUPABASE_URL',
Expand Down
32 changes: 11 additions & 21 deletions apps/docs/scripts/search/sources/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { type GuideModel } from '../../../resources/guide/guideModel.js'
import { GuideModelLoader } from '../../../resources/guide/guideModelLoader.js'
import {
GitHubDiscussionLoader,
type GitHubDiscussionSource,
fetchDiscussions,
} from './github-discussion.js'
import { LintWarningsGuideLoader, type LintWarningsGuideSource } from './lint-warnings-guide.js'
import { MarkdownLoader, type MarkdownSource } from './markdown.js'
import { IntegrationLoader, type IntegrationSource, fetchPartners } from './partner-integrations.js'
Expand All @@ -16,13 +11,14 @@ import {
OpenApiReferenceLoader,
type OpenApiReferenceSource,
} from './reference-doc.js'
import { fetchTroubleshootingSources, type TroubleshootingSource } from './troubleshooting.js'

export type SearchSource =
| MarkdownSource
| OpenApiReferenceSource
| ClientLibReferenceSource
| CliReferenceSource
| GitHubDiscussionSource
| TroubleshootingSource
| IntegrationSource
| LintWarningsGuideSource

Expand Down Expand Up @@ -150,21 +146,15 @@ export async function fetchAllSources(fullIndex: boolean) {
.then((data) => data.flat())
: []

const githubDiscussionSources = fetchDiscussions(
'supabase',
'supabase',
'DIC_kwDODMpXOc4CUvEr' // 'Troubleshooting' category
)
.then((discussions) =>
Promise.all(
discussions.map((discussion) =>
new GitHubDiscussionLoader('supabase/supabase', discussion).load()
)
)
)
// Load troubleshooting articles from local MDX files
const troubleshootingSources = fetchTroubleshootingSources()
.then((loaders) => Promise.all(loaders.map((loader) => loader.load())))
.then((data) => data.flat())

const sources: SearchSource[] = (
// Type assertion required because ReferenceLoader.load() returns Promise<BaseSource[]>
// which widens the inferred union type. All concrete sources in this array are valid
// SearchSource types (MarkdownSource, OpenApiReferenceSource, etc.).
const sources = (
await Promise.all([
guideSources,
lintWarningsGuideSources,
Expand All @@ -177,9 +167,9 @@ export async function fetchAllSources(fullIndex: boolean) {
ktLibReferenceSource,
cliReferenceSource,
partnerIntegrationSources,
githubDiscussionSources,
troubleshootingSources,
])
).flat()
).flat() as SearchSource[]

return sources
}
Loading
Loading