@@ -3,6 +3,7 @@ import { removeUrlQueryParams } from '../utils/url.js';
3
3
import { ErrorResponse , SuccessResponse } from '../types' ;
4
4
import { getCaptchaProvider , getCaptchaSolveProvider } from './get-captcha-provider' ;
5
5
import { captchaFactory } from './providers/registry.js' ;
6
+ import { getCaptchaInfo as getCaptchaInfoDeprecated , solveCaptcha as solveCaptchaDeprecated } from '../actions/captcha-deprecated' ;
6
7
7
8
/**
8
9
* Returns the supporting code to inject for the given captcha type
@@ -13,6 +14,7 @@ import { captchaFactory } from './providers/registry.js';
13
14
export function getSupportingCodeToInject ( action ) {
14
15
const { id : actionID , actionType, injectCaptchaHandler : captchaType } = action ;
15
16
if ( ! captchaType ) {
17
+ // ensures backward compatibility with old actions
16
18
return new SuccessResponse ( { actionID, actionType, response : { } } ) ;
17
19
}
18
20
@@ -37,6 +39,11 @@ export function getSupportingCodeToInject(action) {
37
39
export function getCaptchaInfo ( action , root = document ) {
38
40
const { id : actionID , selector, actionType, captchaType } = action ;
39
41
try {
42
+ if ( ! captchaType ) {
43
+ // ensures backward compatibility with old actions
44
+ return getCaptchaInfoDeprecated ( action , root ) ;
45
+ }
46
+
40
47
if ( ! selector ) {
41
48
throw new Error ( 'missing selector' ) ;
42
49
}
@@ -75,7 +82,8 @@ export function solveCaptcha(action, token, root = document) {
75
82
const { id : actionID , actionType, captchaType } = action ;
76
83
try {
77
84
if ( ! captchaType ) {
78
- throw new Error ( 'missing captchaType' ) ;
85
+ // ensures backward compatibility with old actions
86
+ return solveCaptchaDeprecated ( action , token , root ) ;
79
87
}
80
88
81
89
const captchaSolveProvider = getCaptchaSolveProvider ( root , captchaType ) ;
0 commit comments