@@ -9,8 +9,10 @@ import type {
9
9
PreAuthArgsType ,
10
10
} from "../../../../wallets/in-app/core/authentication/types.js" ;
11
11
import type {
12
+ AuthOption ,
12
13
InAppWalletAuth ,
13
14
InAppWalletSocialAuth ,
15
+ AuthOptionWithOptions ,
14
16
} from "../../../../wallets/in-app/core/wallet/types.js" ;
15
17
import { preAuthenticate } from "../../../../wallets/in-app/native/auth/index.js" ;
16
18
import { hasStoredPasskey } from "../../../../wallets/in-app/native/auth/passkeys.js" ;
@@ -91,16 +93,25 @@ export function InAppWalletUI(props: InAppWalletFormUIProps) {
91
93
92
94
const [ inputMode , setInputMode ] = useState < "email" | "phone" > ( "email" ) ;
93
95
96
+ const hasAuthOption = useCallback ( ( key : AuthOption ) => {
97
+ return authOptions . find ( ( opt ) => typeof opt === 'string' ? opt === key : opt . type === key ) ;
98
+ } , [ authOptions ] ) ;
99
+
100
+ const getAuthOptionDefaultValue = useCallback ( ( key : AuthOption ) => {
101
+ const option = authOptions . find ( ( opt ) => typeof opt === 'object' && opt . type === key ) as AuthOptionWithOptions | undefined ;
102
+ return option ?. defaultValue ;
103
+ } , [ authOptions ] ) ;
104
+
94
105
return (
95
106
< View style = { styles . container } >
96
107
< View style = { styles . row } >
97
108
{ socialLogins . map ( ( auth ) => (
98
109
< SocialLogin key = { auth } auth = { auth } { ...props } />
99
110
) ) }
100
111
</ View >
101
- { authOptions . includes ( "email" ) ? (
112
+ { hasAuthOption ( "email" ) ? (
102
113
inputMode === "email" ? (
103
- < PreOtpLogin auth = "email" { ...props } />
114
+ < PreOtpLogin auth = "email" defaultValue = { getAuthOptionDefaultValue ( 'email' ) } { ...props } />
104
115
) : (
105
116
< ThemedButtonWithIcon
106
117
theme = { theme }
@@ -110,9 +121,9 @@ export function InAppWalletUI(props: InAppWalletFormUIProps) {
110
121
/>
111
122
)
112
123
) : null }
113
- { authOptions . includes ( "phone" ) ? (
124
+ { hasAuthOption ( "phone" ) ? (
114
125
inputMode === "phone" ? (
115
- < PreOtpLogin auth = "phone" { ...props } />
126
+ < PreOtpLogin auth = "phone" defaultValue = { getAuthOptionDefaultValue ( 'phone' ) } { ...props } />
116
127
) : (
117
128
< ThemedButtonWithIcon
118
129
theme = { theme }
@@ -122,7 +133,7 @@ export function InAppWalletUI(props: InAppWalletFormUIProps) {
122
133
/>
123
134
)
124
135
) : null }
125
- { authOptions . includes ( "passkey" ) ? (
136
+ { hasAuthOption ( "passkey" ) ? (
126
137
< ThemedButtonWithIcon
127
138
theme = { theme }
128
139
title = "Passkey"
@@ -132,7 +143,7 @@ export function InAppWalletUI(props: InAppWalletFormUIProps) {
132
143
} }
133
144
/>
134
145
) : null }
135
- { authOptions . includes ( "guest" ) ? < GuestLogin { ...props } /> : null }
146
+ { hasAuthOption ( "guest" ) ? < GuestLogin { ...props } /> : null }
136
147
</ View >
137
148
) ;
138
149
}
@@ -205,10 +216,11 @@ function SocialLogin(
205
216
function PreOtpLogin (
206
217
props : InAppWalletFormUIProps & {
207
218
auth : PreAuthArgsType [ "strategy" ] ;
219
+ defaultValue ?: string ;
208
220
} ,
209
221
) {
210
- const { theme, auth, client, setScreen, wallet } = props ;
211
- const [ phoneOrEmail , setPhoneNumberOrEmail ] = useState ( "" ) ;
222
+ const { theme, auth, client, setScreen, wallet, defaultValue = '' } = props ;
223
+ const [ phoneOrEmail , setPhoneNumberOrEmail ] = useState ( defaultValue ) ;
212
224
213
225
const sendCode = useMutation ( {
214
226
mutationFn : async ( options : {
0 commit comments