@@ -70,6 +70,7 @@ export default function Turnstile({
70
70
execution,
71
71
userRef,
72
72
onVerify,
73
+ onSuccess,
73
74
onLoad,
74
75
onError,
75
76
onExpire,
@@ -81,6 +82,7 @@ export default function Turnstile({
81
82
const ownRef = useRef < HTMLDivElement | null > ( null ) ;
82
83
const inplaceState = useState < TurnstileCallbacks > ( {
83
84
onVerify,
85
+ onSuccess,
84
86
onLoad,
85
87
onError,
86
88
onExpire,
@@ -123,8 +125,10 @@ export default function Turnstile({
123
125
"refresh-expired" : refreshExpired ,
124
126
appearance,
125
127
execution,
126
- callback : ( token : string ) =>
127
- inplaceState . onVerify ?.( token , boundTurnstileObject ) ,
128
+ callback : ( token : string , preClearanceObtained : boolean ) => {
129
+ inplaceState . onVerify ?.( token , boundTurnstileObject ) ;
130
+ inplaceState . onSuccess ?.( token , preClearanceObtained , boundTurnstileObject ) ;
131
+ } ,
128
132
"error-callback" : ( error ?: any ) =>
129
133
inplaceState . onError ?.( error , boundTurnstileObject ) ,
130
134
"expired-callback" : ( token : string ) =>
@@ -165,6 +169,7 @@ export default function Turnstile({
165
169
] ) ;
166
170
useEffect ( ( ) => {
167
171
inplaceState . onVerify = onVerify ;
172
+ inplaceState . onSuccess = onSuccess ;
168
173
inplaceState . onLoad = onLoad ;
169
174
inplaceState . onError = onError ;
170
175
inplaceState . onExpire = onExpire ;
@@ -174,6 +179,7 @@ export default function Turnstile({
174
179
inplaceState . onUnsupported = onUnsupported ;
175
180
} , [
176
181
onVerify ,
182
+ onSuccess ,
177
183
onLoad ,
178
184
onError ,
179
185
onExpire ,
@@ -225,6 +231,7 @@ export interface TurnstileProps extends TurnstileCallbacks {
225
231
226
232
export interface TurnstileCallbacks {
227
233
onVerify ?: ( token : string , boundTurnstile : BoundTurnstileObject ) => void ;
234
+ onSuccess ?: ( token : string , preClearanceObtained : boolean , boundTurnstile : BoundTurnstileObject ) => void ;
228
235
onLoad ?: ( widgetId : string , boundTurnstile : BoundTurnstileObject ) => void ;
229
236
onError ?: (
230
237
error ?: Error | any ,
0 commit comments