Skip to content

[SDK] feat: support object auth option with default value #7292

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

coreyar
Copy link

@coreyar coreyar commented Jun 6, 2025

TOOL-4579 Pre-filled values for inAppWallet auth options

Notes for the reviewer

I opened this PR in response to finding issue 7126. I looked through the tests real quick and didn't see any calling inAppWallet(). I also didn't find tests for <ConnectEmbed/> after a quick pass.

If this PR is in the right direction, I can dig a little deeper to add the tests and documentation.


PR-Codex overview

This PR enhances the InAppWallet functionality by introducing AuthOptionWithOptions, improving authentication handling, and refining the UI components to utilize the new types for better management of default values and options.

Detailed summary

  • Added AuthOptionWithOptions type to manage options with default values.
  • Updated InAppWalletAuth to support both AuthOption and AuthOptionWithOptions.
  • Refactored ConnectModal.tsx to use authProviderName instead of authProvider.
  • Improved InAppWalletUI.tsx to check for authentication options using hasAuthOption.
  • Modified PreOtpLogin to accept a defaultValue prop for better state initialization.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Login forms for email and phone now support pre-filled default values, improving user convenience when entering credentials.
  • Bug Fixes

    • Enhanced handling of authentication provider types ensures consistent display and messaging regardless of input format.
  • Refactor

    • Improved internal logic for detecting available authentication options, enabling better support for both string and object formats.

@coreyar coreyar requested review from a team as code owners June 6, 2025 01:55
Copy link

changeset-bot bot commented Jun 6, 2025

⚠️ No Changeset found

Latest commit: f7591c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 6, 2025

@coreyar is attempting to deploy a commit to the thirdweb Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

Warning

Rate limit exceeded

@coreyar has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 25 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f4d16b and f7591c9.

📒 Files selected for processing (3)
  • packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx (4 hunks)
  • packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx (6 hunks)
  • packages/thirdweb/src/wallets/in-app/core/wallet/types.ts (1 hunks)

"""

Walkthrough

The changes introduce support for pre-filling authentication input fields (such as email or phone) in the in-app wallet UI by extending the types and logic handling authentication options. Utility functions are added to extract default values, and the UI components are updated to initialize input fields with these values if provided.

Changes

Files/Paths Change Summary
packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx Normalized authProvider prop to consistently extract provider name for display and logic.
packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx Added hasAuthOption and getAuthOptionDefaultValue utilities; updated UI to prefill auth fields with default values.
packages/thirdweb/src/wallets/in-app/core/wallet/types.ts Extended InAppWalletAuth type to allow default values; added AuthOptionWithOptions type.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConnectEmbed
    participant InAppWalletUI
    participant PreOtpLogin

    User->>ConnectEmbed: Opens connect modal
    ConnectEmbed->>InAppWalletUI: Renders auth options (with possible default values)
    InAppWalletUI->>PreOtpLogin: Passes defaultValue for email/phone if provided
    PreOtpLogin->>User: Displays input pre-filled with defaultValue
    User->>PreOtpLogin: Submits auth info
Loading

Assessment against linked issues

Objective Addressed Explanation
Support pre-filled/forced custom values for inAppWallet auth options in ConnectEmbed (TOOL-4579)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested labels

packages, SDK
"""

✨ 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

graphite-app bot commented Jun 6, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jun 6, 2025
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

🧹 Nitpick comments (1)
packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx (1)

478-478: Use optional chaining for cleaner code.

The normalization logic is correct, but you can simplify it using optional chaining as suggested by the static analysis tool.

Apply this diff to use optional chaining:

-  const authProviderName = typeof authProvider === 'string' ? authProvider : authProvider && authProvider.type;
+  const authProviderName = typeof authProvider === 'string' ? authProvider : authProvider?.type;
🧰 Tools
🪛 Biome (1.9.4)

[error] 478-478: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c95c0dc and ee56b4d.

📒 Files selected for processing (3)
  • packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx (4 hunks)
  • packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx (6 hunks)
  • packages/thirdweb/src/wallets/in-app/core/wallet/types.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx

[error] 478-478: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (5)
packages/thirdweb/src/wallets/in-app/core/wallet/types.ts (1)

42-44: LGTM! Well-designed type extension.

The new union type InAppWalletAuth elegantly supports both simple auth options and enhanced options with default values while maintaining backward compatibility.

packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx (1)

495-528: LGTM! Consistent normalization pattern.

The normalization of authProvider to authProviderName and its usage throughout the component correctly handles both string and object forms of auth providers.

packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx (3)

96-103: LGTM! Well-implemented utility functions.

The hasAuthOption and getAuthOptionDefaultValue functions correctly handle both string and object forms of auth options, providing a clean abstraction for the new union type.


219-223: LGTM! Clean default value handling.

The PreOtpLogin component properly accepts and uses the defaultValue prop to initialize the input state, enabling pre-filled authentication fields as intended.


112-146: LGTM! Consistent usage of utility functions.

The conditional rendering logic correctly uses the new utility functions to check for auth options and retrieve default values, maintaining consistency with the new type structure.

@coreyar coreyar force-pushed the feat/issue-7126-add-default-value-to-auth-options branch from ee56b4d to 6dd909f Compare June 6, 2025 01:59
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 ee56b4d and 6dd909f.

📒 Files selected for processing (3)
  • packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx (4 hunks)
  • packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx (6 hunks)
  • packages/thirdweb/src/wallets/in-app/core/wallet/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/thirdweb/src/wallets/in-app/core/wallet/types.ts
  • packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx

[error] 478-478: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (1)
packages/thirdweb/src/react/native/ui/connect/ConnectModal.tsx (1)

495-495: LGTM! Consistent normalization implementation.

The consistent replacement of authProvider with authProviderName throughout the conditional rendering and display logic properly implements the intended normalization pattern. This ensures uniform handling of authentication provider identification regardless of whether the provider is specified as a string or object.

Also applies to: 505-505, 520-521, 526-527

@coreyar coreyar force-pushed the feat/issue-7126-add-default-value-to-auth-options branch from 6dd909f to 7f4d16b Compare June 6, 2025 02:04
@coreyar coreyar force-pushed the feat/issue-7126-add-default-value-to-auth-options branch from 7f4d16b to ca0b8d3 Compare June 6, 2025 02:09
@coreyar coreyar marked this pull request as draft June 6, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant