Skip to content

feat: add expo plugin and trusted origins #597

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

Open
wants to merge 2 commits into
base: v3-main
Choose a base branch
from

Conversation

omar-bear
Copy link
Contributor

@omar-bear omar-bear commented Jul 2, 2025

Describe your changes

Add expo plugin and trusted origins to better-auth config, to make socials login works on start ui native using start ui web server

Summary by CodeRabbit

  • New Features

    • Added support for authentication on the Expo platform.
    • Defined trusted origins to enhance authentication security for native apps.
  • Chores

    • Updated dependencies to include Expo authentication support.

Copy link

vercel bot commented Jul 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
start-ui ❌ Failed (Inspect) Jul 3, 2025 3:26pm
start-ui-web-restart ❌ Failed (Inspect) Jul 3, 2025 3:26pm

Copy link
Contributor

coderabbitai bot commented Jul 2, 2025

Walkthrough

The changes add the @better-auth/expo plugin to the authentication configuration in app/server/auth.tsx, including a new trustedOrigins property for Expo-specific origins. Additionally, the @better-auth/expo dependency is added to package.json.

Changes

File(s) Change Summary
app/server/auth.tsx Added expo() plugin from @better-auth/expo to plugins; added trustedOrigins property for Expo origins.
package.json Added dependency "@better-auth/expo": "1.2.10".

Sequence Diagram(s)

sequenceDiagram
    participant Client (Expo App)
    participant Server (auth.tsx)
    participant BetterAuth
    participant ExpoPlugin

    Client (Expo App)->>Server (auth.tsx): Initiate authentication request
    Server (auth.tsx)->>BetterAuth: Process authentication with plugins
    BetterAuth->>ExpoPlugin: Use Expo plugin for authentication flow
    ExpoPlugin-->>BetterAuth: Return authentication result
    BetterAuth-->>Server (auth.tsx): Return auth result (with trusted origin check)
    Server (auth.tsx)-->>Client (Expo App): Respond with authentication outcome
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 123ca57 and 8776fa0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • app/server/auth.tsx (3 hunks)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • app/server/auth.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8b459c and 123ca57.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • app/server/auth.tsx (3 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
app/server/auth.tsx (1)
Learnt from: ivan-dalmet
PR: BearStudio/start-ui-web#532
File: src/server/config/oauth/providers/discord.ts:11-11
Timestamp: 2024-10-14T15:29:53.279Z
Learning: In `src/server/config/oauth/providers/discord.ts`, when defining the `zDiscordUser` schema, keep fields like `username` as nullable (e.g., `.nullish()`), as the Discord API might return null values despite the documentation stating otherwise.
🧬 Code Graph Analysis (1)
app/server/auth.tsx (1)
app/env/server.ts (1)
  • envServer (9-33)
🪛 ESLint
app/server/auth.tsx

[error] 21-21: 'inferAdditionalFields' is defined but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)


[error] 21-21: Remove this unused import of 'inferAdditionalFields'.

(sonarjs/unused-import)

🔇 Additional comments (4)
package.json (1)

47-47: LGTM - Dependency addition looks correct.

The @better-auth/expo dependency is properly added and the version aligns well with the existing better-auth ecosystem in the project.

app/server/auth.tsx (3)

5-5: LGTM - Expo plugin import correctly added.

The import is properly used in the plugins array configuration.


29-29: LGTM - Trusted origins configuration is appropriate.

The trusted origins configuration with start-ui-native:// and start-ui-native://* properly allows the native Expo app to authenticate with the web server. This follows the expected pattern for Expo deep linking authentication flows.


54-54: LGTM - Expo plugin correctly integrated.

The expo() plugin is properly added to the plugins array and will enable Expo-specific authentication functionality.

@@ -17,13 +18,15 @@ import { permissions } from '@/features/auth/permissions';
import { db } from '@/server/db';
import { sendEmail } from '@/server/email';
import { getUserLanguage } from '@/server/utils';
import { inferAdditionalFields } from 'better-auth/client/plugins';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unused import.

The inferAdditionalFields import is not used anywhere in the code and should be removed to keep the codebase clean.

-import { inferAdditionalFields } from 'better-auth/client/plugins';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { inferAdditionalFields } from 'better-auth/client/plugins';
🧰 Tools
🪛 ESLint

[error] 21-21: 'inferAdditionalFields' is defined but never used. Allowed unused vars must match /^_/u.

(@typescript-eslint/no-unused-vars)


[error] 21-21: Remove this unused import of 'inferAdditionalFields'.

(sonarjs/unused-import)

🤖 Prompt for AI Agents
In app/server/auth.tsx at line 21, the import statement for
inferAdditionalFields from better-auth/client/plugins is unused. Remove this
import line entirely to clean up the code and avoid unnecessary imports.

@@ -24,6 +25,7 @@ export const auth = betterAuth({
expiresIn: envServer.SESSION_EXPIRATION_IN_SECONDS,
updateAge: envServer.SESSION_UPDATE_AGE_IN_SECONDS,
},
trustedOrigins: ['start-ui-native://', 'start-ui-native://*'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to put that in environment variable or something like that?
Because client and side-project apps won't use those values.

Copy link

sonarqubecloud bot commented Jul 3, 2025

@ivan-dalmet ivan-dalmet added the v3 label Jul 11, 2025
@ivan-dalmet ivan-dalmet force-pushed the v3-main branch 2 times, most recently from cf02ee7 to cbaf95e Compare July 21, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants