@@ -42,25 +42,28 @@ export default function TurnstileBridge() {
4242 ( window as any ) . turnstile . render ( containerRef . current , {
4343 sitekey : siteKey ,
4444 callback : ( token : string ) => {
45- try {
46- window . location . replace ( `ethoraappreactnative://turnstile?token=${ encodeURIComponent ( token ) } ` ) ;
47- } catch ( e ) {
48- try {
49- window . open ( `ethoraappreactnative://turnstile?token=${ encodeURIComponent ( token ) } ` , '_self' ) ;
50- } catch ( e2 ) {
51- try {
52- const link = document . createElement ( 'a' ) ;
53- link . href = `ethoraappreactnative://turnstile?token=${ encodeURIComponent ( token ) } ` ;
54- link . click ( ) ;
55- } catch ( e3 ) {
56- console . error ( 'All redirect methods failed:' , e3 ) ;
57- }
58- }
45+ console . log ( 'Turnstile success, token:' , token ) ;
46+ // Используем redirect URI для возврата в мобильное приложение
47+ const redirectUri = new URLSearchParams ( window . location . search ) . get ( 'redirect_uri' ) ;
48+ if ( redirectUri ) {
49+ const url = new URL ( redirectUri ) ;
50+ url . searchParams . set ( 'token' , token ) ;
51+ window . location . href = url . toString ( ) ;
52+ } else {
53+ // Fallback для тестирования в браузере
54+ alert ( `Turnstile Token: ${ token } ` ) ;
5955 }
6056 } ,
6157 'error-callback' : ( error : string ) => {
6258 console . error ( 'Turnstile error:' , error ) ;
63- window . location . replace ( `ethoraappreactnative://turnstile?error=${ encodeURIComponent ( error ) } ` ) ;
59+ const redirectUri = new URLSearchParams ( window . location . search ) . get ( 'redirect_uri' ) ;
60+ if ( redirectUri ) {
61+ const url = new URL ( redirectUri ) ;
62+ url . searchParams . set ( 'error' , error ) ;
63+ window . location . href = url . toString ( ) ;
64+ } else {
65+ alert ( `Turnstile Error: ${ error } ` ) ;
66+ }
6467 } ,
6568 theme : 'light' ,
6669 } ) ;
0 commit comments