(provider: string)
| 146 | }; |
| 147 | |
| 148 | const onSocialRegistration = async (provider: string) => { |
| 149 | const additionalData = { timezone }; |
| 150 | |
| 151 | if (isNativeAuthSupported(provider)) { |
| 152 | const res = await iosNativeAuth(provider); |
| 153 | if (!res) { |
| 154 | return; |
| 155 | } |
| 156 | const result = await betterAuthSignInWithIdToken({ |
| 157 | provider: provider.toLowerCase(), |
| 158 | token: res.token, |
| 159 | nonce: res.nonce, |
| 160 | additionalData, |
| 161 | }); |
| 162 | if (result.error) { |
| 163 | logEvent({ |
| 164 | event_name: AuthEventNames.RegistrationError, |
| 165 | extra: JSON.stringify({ |
| 166 | provider, |
| 167 | error: result.error, |
| 168 | origin: 'betterauth native id token registration', |
| 169 | }), |
| 170 | }); |
| 171 | return; |
| 172 | } |
| 173 | try { |
| 174 | const { data: boot } = await refetchBoot(); |
| 175 | if (!boot.user) { |
| 176 | logEvent({ |
| 177 | event_name: AuthEventNames.RegistrationError, |
| 178 | extra: JSON.stringify({ |
| 179 | provider, |
| 180 | error: 'Missing user after Better Auth social registration', |
| 181 | origin: 'betterauth native id token registration boot', |
| 182 | }), |
| 183 | }); |
| 184 | displayToast('An error occurred, please refresh the page.'); |
| 185 | return; |
| 186 | } |
| 187 | } catch (error) { |
| 188 | logEvent({ |
| 189 | event_name: AuthEventNames.RegistrationError, |
| 190 | extra: JSON.stringify({ |
| 191 | provider, |
| 192 | error: getBetterAuthErrorMessage( |
| 193 | error, |
| 194 | 'Failed to refresh Better Auth registration state', |
| 195 | ), |
| 196 | origin: 'betterauth native id token registration boot', |
| 197 | }), |
| 198 | }); |
| 199 | displayToast('An error occurred, please refresh the page.'); |
| 200 | return; |
| 201 | } |
| 202 | return; |
| 203 | } |
| 204 | const callbackURL = `${webappUrl}callback?login=true`; |
| 205 | const { url, error } = await getBetterAuthSocialRedirectData( |
no test coverage detected