-
Notifications
You must be signed in to change notification settings - Fork 28
Allow CAPTCHA actions to fail silently #1622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for content-scope-scripts ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Temporary Branch UpdateThe temporary branch has been updated with the latest changes. Below are the details:
Please use the above install command to update to the latest version. |
[Beta] Generated file diffTime updated: Wed, 09 Apr 2025 09:19:54 GMT Android
File has changed Integration
File has changed Windows
File has changed Apple
File has changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few comments that I think should be addressed, but I am also mindful we're on a tight schedule, so I'll be approving this (pending testing) since nothing is strictly blocking.
function emptySuccessResponse(actionID, actionType) { | ||
return SuccessResponse.create({ actionID, actionType, response: {} }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd say this makes more sense as part of the SuccessResponse
class:
/**
* @param {Pick<SuccessResponseInterface, "actionID" | "actionType">} params
* @return {SuccessResponse}
*/
static createEmptySuccessResponse(params) {
return SuccessResponse.create({ ...params, response: {} });
}
and usage becomes:
return SuccessResponse.createEmptySuccessResponse({ actionID, actionType })
@@ -12,6 +12,7 @@ | |||
* @property {string} [captchaType] | |||
* @property {string} [injectCaptchaHandler] | |||
* @property {string} [dataSource] | |||
* @property {boolean} [failSilently] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failSilently
suggests we are allowing something to fail silently when in reality we're just skipping the action in case of failure, can we consider something on the lines of: bypassOnFailure
| bypassOnError
| skipOnError
?
@@ -64,17 +64,19 @@ export function getCaptchaInfo(action, root = document) { | |||
|
|||
const captchaContainer = getCaptchaContainer(root, selector); | |||
if (PirError.isError(captchaContainer)) { | |||
return createError(captchaContainer.error.message); | |||
return failSilently ? emptySuccessResponse(actionID, actionType) : createError(captchaContainer.error.message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think failSilently
is a property of any
action and it should be moved a level up (as part of injected/src/features/broker-protection/execute.js
)
export async function execute(action, inputData, root = document) {
try {
const executeAction = async () => {
switch (action.actionType) {
case 'navigate':
return navigate(action, data(action, inputData, 'userProfile'));
case 'extract':
return await extract(action, data(action, inputData, 'userProfile'), root);
case 'click':
return click(action, data(action, inputData, 'userProfile'), root);
case 'expectation':
return expectation(action, root);
case 'fillForm':
return fillForm(action, data(action, inputData, 'extractedProfile'), root);
case 'getCaptchaInfo':
return getCaptchaInfo(action, root);
case 'solveCaptcha':
return solveCaptcha(action, data(action, inputData, 'token'), root);
default: {
return new ErrorResponse({
actionID: action.id,
message: `unimplemented actionType: ${action.actionType}`,
});
}
}
};
const actionResponse = await executeAction();
if (action.failSilently) {
return SuccessResponse.createEmptySuccessResponse({ actionID: action.id, actionType: action.actionType });
}
return actionResponse;
} catch (e) {
// ...
}
}
Asana Task/Github Issue: https://app.asana.com/0/1199230911884351/1209924515943923/f
Description
Allows captcha actions to fail silently without stopping the opt out flow for more flexbility
Testing Steps
See Asana
Checklist
Please tick all that apply: