Skip to content

Commit 8a3c25d

Browse files
committed
feat: ensure backwards compatibility
1 parent e123925 commit 8a3c25d

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

injected/src/features/broker-protection/captcha-services/captcha.service.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { removeUrlQueryParams } from '../utils/url.js';
33
import { ErrorResponse, SuccessResponse } from '../types';
44
import { getCaptchaProvider, getCaptchaSolveProvider } from './get-captcha-provider';
55
import { captchaFactory } from './providers/registry.js';
6+
import { getCaptchaInfo as getCaptchaInfoDeprecated, solveCaptcha as solveCaptchaDeprecated } from '../actions/captcha-deprecated';
67

78
/**
89
* Returns the supporting code to inject for the given captcha type
@@ -13,6 +14,7 @@ import { captchaFactory } from './providers/registry.js';
1314
export function getSupportingCodeToInject(action) {
1415
const { id: actionID, actionType, injectCaptchaHandler: captchaType } = action;
1516
if (!captchaType) {
17+
// ensures backward compatibility with old actions
1618
return new SuccessResponse({ actionID, actionType, response: {} });
1719
}
1820

@@ -37,6 +39,11 @@ export function getSupportingCodeToInject(action) {
3739
export function getCaptchaInfo(action, root = document) {
3840
const { id: actionID, selector, actionType, captchaType } = action;
3941
try {
42+
if (!captchaType) {
43+
// ensures backward compatibility with old actions
44+
return getCaptchaInfoDeprecated(action, root);
45+
}
46+
4047
if (!selector) {
4148
throw new Error('missing selector');
4249
}
@@ -75,7 +82,8 @@ export function solveCaptcha(action, token, root = document) {
7582
const { id: actionID, actionType, captchaType } = action;
7683
try {
7784
if (!captchaType) {
78-
throw new Error('missing captchaType');
85+
// ensures backward compatibility with old actions
86+
return solveCaptchaDeprecated(action, token, root);
7987
}
8088

8189
const captchaSolveProvider = getCaptchaSolveProvider(root, captchaType);

injected/src/features/broker-protection/execute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resolveActionHandlers } from './actions';
1+
import { resolveActionHandlers } from './actions/actions';
22
import { ErrorResponse } from './types';
33

44
/**

injected/src/features/broker-protection/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* id: string;
88
* actionType: "extract" | "fillForm" | "click" | "expectation" | "getCaptchaInfo" | "solveCaptcha" | "navigate";
99
* selector: string;
10-
* captchaType: string;
10+
* captchaType?: string;
1111
* injectCaptchaHandler?: string
1212
* dataSource?: string;
1313
* }} PirAction

0 commit comments

Comments
 (0)