-
Notifications
You must be signed in to change notification settings - Fork 661
[SDK] Add name and picture fields to Profile type for Apple Sign In compliance #8681
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "thirdweb": minor | ||
| --- | ||
|
|
||
| Add optional `name` and `picture` fields to `Profile` type to support additional OAuth provider data (Google, Apple, etc.). The UI now displays the user's name when available from OAuth providers, improving Apple Sign In compliance. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,33 +9,39 @@ import { useSocialProfiles } from "../../../../core/social/useSocialProfiles.js" | |
| import { getSocialIcon } from "../../../../core/utils/walletIcon.js"; | ||
| import { useProfiles } from "../../../hooks/wallets/useProfiles.js"; | ||
| import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js"; | ||
| import { Container, Line, ModalHeader } from "../../components/basic.js"; | ||
| import { IconButton } from "../../components/buttons.js"; | ||
| import { Img } from "../../components/Img.js"; | ||
| import { Spacer } from "../../components/Spacer.js"; | ||
| import { Container, Line, ModalHeader } from "../../components/basic.js"; | ||
| import { IconButton } from "../../components/buttons.js"; | ||
| import { Text } from "../../components/text.js"; | ||
| import { Blobbie } from "../Blobbie.js"; | ||
| import { MenuButton } from "../MenuButton.js"; | ||
| import { AddUserIcon } from "../icons/AddUserIcon.js"; | ||
| import { EmailIcon } from "../icons/EmailIcon.js"; | ||
| import { FingerPrintIcon } from "../icons/FingerPrintIcon.js"; | ||
| import { PhoneIcon } from "../icons/PhoneIcon.js"; | ||
| import type { ConnectLocale } from "../locale/types.js"; | ||
| import { MenuButton } from "../MenuButton.js"; | ||
| import type { WalletDetailsModalScreen } from "./types.js"; | ||
|
|
||
| function getProfileDisplayName(profile: Profile) { | ||
| function getProfileDisplayName(profile: Profile): string { | ||
| // Prefer name if available (from OAuth providers like Google/Apple). | ||
| // Use .trim() to reject whitespace-only strings that some backends may return. | ||
| if (profile.details.name?.trim()) { | ||
| return profile.details.name.trim(); | ||
| } | ||
|
|
||
| switch (true) { | ||
| case profile.type === "email" && profile.details.email !== undefined: | ||
| return profile.details.email; | ||
| return profile.details.email as string; | ||
| case profile.type === "google" && profile.details.email !== undefined: | ||
| return profile.details.email; | ||
| return profile.details.email as string; | ||
| case profile.type === "phone" && profile.details.phone !== undefined: | ||
| return profile.details.phone; | ||
| return profile.details.phone as string; | ||
| case profile.details.address !== undefined: | ||
| return shortenAddress(profile.details.address, 6); | ||
| case (profile.type as string) === "cognito" && | ||
| profile.details.email !== undefined: | ||
| return profile.details.email; | ||
| return profile.details.email as string; | ||
|
Comment on lines
33
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Apple email fallback when provider name is missing. If Suggested fix switch (true) {
case profile.type === "email" && profile.details.email !== undefined:
return profile.details.email as string;
case profile.type === "google" && profile.details.email !== undefined:
return profile.details.email as string;
+ case profile.type === "apple" && profile.details.email !== undefined:
+ return profile.details.email as string;
case profile.type === "phone" && profile.details.phone !== undefined:
return profile.details.phone as string;🤖 Prompt for AI Agents |
||
| case (profile.type as string).toLowerCase() === "custom_auth_endpoint": | ||
| return "Custom Profile"; | ||
| default: | ||
|
|
@@ -154,6 +160,18 @@ function LinkedProfile({ | |
| }} | ||
| width={iconSize.lg} | ||
| /> | ||
| ) : profile.details.picture ? ( | ||
| // Fallback to OAuth provider picture (e.g. Google/Apple) when no social profile avatar is available | ||
| <Img | ||
| client={client} | ||
| height={iconSize.lg} | ||
| loading="eager" | ||
| src={profile.details.picture} | ||
| style={{ | ||
| borderRadius: "100%", | ||
| }} | ||
| width={iconSize.lg} | ||
| /> | ||
| ) : profile.details.address !== undefined ? ( | ||
| <Container | ||
| style={{ | ||
|
|
@@ -190,6 +208,12 @@ function LinkedProfile({ | |
| }} | ||
| > | ||
| <Text color="primaryText"> | ||
| {/* | ||
| * Name display priority: | ||
| * 1. socialProfiles name (real-time on-chain/social lookup) | ||
| * 2. profile.details.name (OAuth provider name, e.g. Google/Apple) | ||
| * 3. email / phone / shortened address / profile type (via getProfileDisplayName) | ||
| */} | ||
| {socialProfiles?.find((p) => p.avatar)?.name || | ||
| getProfileDisplayName(profile)} | ||
| </Text> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an Apple-specific fallback test case.
The fallback scenarios here only validate
google. Add one forapplewith missing/blankdetails.nameto lock the compliance-critical branch and catch"Apple"default regressions.Suggested test addition
📝 Committable suggestion
🤖 Prompt for AI Agents