@captchafox/react
Advanced tools
Comparing version
@@ -125,8 +125,14 @@ "use client"; | ||
}, | ||
execute: () => { | ||
execute: () => __async(void 0, null, function* () { | ||
if (!isApiReady() || !widgetId) { | ||
return waitAndExecute(); | ||
} | ||
return window.captchafox.execute(widgetId); | ||
} | ||
try { | ||
const token = yield window.captchafox.execute(widgetId); | ||
return token; | ||
} catch (error) { | ||
const errorType = getErrorType(error); | ||
return Promise.reject(errorType); | ||
} | ||
}) | ||
}; | ||
@@ -169,6 +175,15 @@ }, | ||
clearTimeout(executeTimeout.current); | ||
window.captchafox.execute(id).then(resolve).catch(reject); | ||
window.captchafox.execute(id).then(resolve).catch((error) => { | ||
const errorType = getErrorType(error); | ||
reject(errorType); | ||
}); | ||
}; | ||
}); | ||
}; | ||
const getErrorType = (error) => { | ||
if (error !== "challenge-aborted" && error !== "rate-limited") { | ||
return new RetryError(); | ||
} | ||
return error; | ||
}; | ||
const renderCaptcha = () => __async(void 0, null, function* () { | ||
@@ -175,0 +190,0 @@ var _a, _b, _c; |
{ | ||
"name": "@captchafox/react", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"main": "./dist/index.cjs", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
22866
4.76%494
6.47%