Skip to content

Commit

Permalink
fix: put back removed error-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Jun 26, 2024
1 parent 315e7c9 commit 857257a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
}

defaultConfig {
minSdkVersion 16
minSdkVersion 16 // Android 4.1
targetSdkVersion 34

// See https://developer.android.com/studio/publish/versioning
Expand Down
26 changes: 22 additions & 4 deletions sdk/src/main/html/hcaptcha.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@
},
'open-callback': function openCallback() {
return BridgeObject.onOpen();
},
'error-callback': function errorCallback(error) {
switch(error) {
case "rate-limited":
return BridgeObject.onError(31);
case "network-error":
return BridgeObject.onError(7);
case "invalid-data":
return BridgeObject.onError(8);
case "challenge-error":
return BridgeObject.onError(9);
case "internal-error":
return BridgeObject.onError(10);
default:
// Error not handled? Log it for debugging purposes
console.error(error);
return BridgeObject.onError(29);
}
}
};
}
Expand All @@ -128,13 +146,13 @@
loadAsync: true,
async: true,
};
};
}
function getLoaderParams(config) {
var result = getScriptParams(config);

result.render = 'explicit';
result.sentry = config.sentry;
result.custom = !!config.customTheme
result.custom = !!config.customTheme;
result.assethost = config.assethost;
result.imghost = config.imghost;
result.reportapi = config.reportapi;
Expand All @@ -145,7 +163,7 @@
result.cleanup = true;

return result;
};
}
var container = document.getElementById("hcaptcha-container");
container.addEventListener("click", function () {
if (hcaptcha) {
Expand All @@ -157,7 +175,7 @@
});
async function execute() {
try {
const { response } = await hcaptcha.execute(getScriptParams(bridgeConfig)); // { async: true }
var { response } = await hcaptcha.execute(getScriptParams(bridgeConfig));
BridgeObject.onPass(response);
} catch (error) {
switch(error) {
Expand Down

0 comments on commit 857257a

Please sign in to comment.