diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-03-20 23:29:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 23:29:24 +0000 |
commit | c649ee1afa80f71f108187df5671ae85eeaeed99 (patch) | |
tree | adb5227f58811d0fe4af023184f9ffd71f66f463 /src/view/com/auth/create/CaptchaWebView.web.tsx | |
parent | 8ad813cd86c74a987cb81f5278c2eabbe8193db8 (diff) | |
parent | d2d4d3a09206b52fe78018b89f82471c3dd91c8a (diff) | |
download | voidsky-c649ee1afa80f71f108187df5671ae85eeaeed99.tar.zst |
Merge pull request #3217 from bluesky-social/samuel/alf-login
Use ALF for login & signup flow
Diffstat (limited to 'src/view/com/auth/create/CaptchaWebView.web.tsx')
-rw-r--r-- | src/view/com/auth/create/CaptchaWebView.web.tsx | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/view/com/auth/create/CaptchaWebView.web.tsx b/src/view/com/auth/create/CaptchaWebView.web.tsx deleted file mode 100644 index 7791a58dd..000000000 --- a/src/view/com/auth/create/CaptchaWebView.web.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react' -import {StyleSheet} from 'react-native' - -// @ts-ignore web only, we will always redirect to the app on web (CORS) -const REDIRECT_HOST = new URL(window.location.href).host - -export function CaptchaWebView({ - url, - stateParam, - onSuccess, - onError, -}: { - url: string - stateParam: string - onSuccess: (code: string) => void - onError: () => void -}) { - const onLoad = React.useCallback(() => { - // @ts-ignore web - const frame: HTMLIFrameElement = document.getElementById( - 'captcha-iframe', - ) as HTMLIFrameElement - - try { - // @ts-ignore web - const href = frame?.contentWindow?.location.href - if (!href) return - const urlp = new URL(href) - - // This shouldn't happen with CORS protections, but for good measure - if (urlp.host !== REDIRECT_HOST) return - - const code = urlp.searchParams.get('code') - if (urlp.searchParams.get('state') !== stateParam || !code) { - onError() - return - } - onSuccess(code) - } catch (e) { - // We don't need to handle this - } - }, [stateParam, onSuccess, onError]) - - return ( - <iframe - src={url} - style={styles.iframe} - id="captcha-iframe" - onLoad={onLoad} - /> - ) -} - -const styles = StyleSheet.create({ - iframe: { - flex: 1, - borderWidth: 0, - borderRadius: 10, - backgroundColor: 'transparent', - }, -}) |