( path: string, provider: string, callbackURL: string, additionalData?: SocialAdditionalData, scopes?: string[], )
| 168 | type SocialAdditionalData = Record<string, unknown>; |
| 169 | |
| 170 | const getBetterAuthSocialRedirect = async ( |
| 171 | path: string, |
| 172 | provider: string, |
| 173 | callbackURL: string, |
| 174 | additionalData?: SocialAdditionalData, |
| 175 | scopes?: string[], |
| 176 | ): Promise<BetterAuthSocialRedirectResponse> => { |
| 177 | const absoluteCallbackURL = callbackURL.startsWith('http') |
| 178 | ? callbackURL |
| 179 | : `${window.location.origin}${ |
| 180 | callbackURL.startsWith('/') ? '' : '/' |
| 181 | }${callbackURL}`; |
| 182 | |
| 183 | const response = await betterAuthPost<{ |
| 184 | url?: string; |
| 185 | redirect?: boolean; |
| 186 | }>( |
| 187 | path, |
| 188 | { |
| 189 | provider, |
| 190 | callbackURL: absoluteCallbackURL, |
| 191 | errorCallbackURL: absoluteCallbackURL, |
| 192 | disableRedirect: true, |
| 193 | ...(additionalData && { additionalData }), |
| 194 | ...(scopes?.length && { scopes }), |
| 195 | }, |
| 196 | 'Failed to get social auth URL', |
| 197 | ); |
| 198 | |
| 199 | return { |
| 200 | url: response.url, |
| 201 | redirect: response.redirect, |
| 202 | ...response, |
| 203 | }; |
| 204 | }; |
| 205 | |
| 206 | export const getBetterAuthSocialRedirectData = ( |
| 207 | provider: string, |
no outgoing calls
no test coverage detected