🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@captchafox/react

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@captchafox/react - npm Package Compare versions

Comparing version

to
1.6.0

2

dist/index.d.ts

@@ -14,2 +14,2 @@ import { WidgetApi, WidgetOptions } from '@captchafox/types';

export { CAPTCHA_RESPONSE_KEY, CaptchaFox, CaptchaFoxInstance };
export { CAPTCHA_RESPONSE_KEY, CaptchaFox, type CaptchaFoxInstance };

@@ -24,27 +24,47 @@ "use client";

// ../internal/dist/index.mjs
var resolveFn;
var rejectFn;
var mountInstance = new Promise((resolve, reject) => {
resolveFn = resolve;
rejectFn = reject;
var backoff = (retryCount) => Math.exp(retryCount) * 150;
var withRetry = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (callback, { attempts = 4 } = {}) {
let error;
for (let i = 0; i < attempts; i++) {
try {
return yield callback();
} catch (err) {
error = err;
yield new Promise((r) => setTimeout(r, backoff(i)));
}
}
throw error != null ? error : new Error("Exhausted all retries");
});
var mountInstance;
var LOAD_FUNC_KEY = "captchaFoxOnLoad";
var SCRIPT_SRC = `https://cdn.captchafox.com/api.js?render=explicit&onload=${LOAD_FUNC_KEY}`;
function loadCaptchaScript() {
function loadScript() {
return __async(this, arguments, function* ({ nonce } = {}) {
if (document.querySelector(`script[src="${SCRIPT_SRC}"]`))
if (mountInstance && document.querySelector(`script[src="${SCRIPT_SRC}"]`)) {
return mountInstance;
window[LOAD_FUNC_KEY] = resolveFn;
const script = document.createElement("script");
script.src = SCRIPT_SRC;
script.async = true;
script.defer = true;
script.onerror = rejectFn;
if (nonce) {
script.nonce = nonce;
}
document.body.appendChild(script);
mountInstance = new Promise((resolve, reject) => {
window[LOAD_FUNC_KEY] = resolve;
const script = document.createElement("script");
script.src = SCRIPT_SRC;
script.async = true;
script.defer = true;
script.onerror = (e) => {
script.remove();
mountInstance = void 0;
reject(e);
};
if (nonce) {
script.nonce = nonce;
}
document.body.appendChild(script);
});
return mountInstance;
});
}
function loadCaptchaScript() {
return __async(this, arguments, function* (props = {}) {
return withRetry(() => loadScript(props));
});
}
var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !== "undefined";

@@ -116,4 +136,3 @@

(_a = window.captchafox) == null ? void 0 : _a.remove(widgetId);
if (!containerRef || ((_b = containerRef == null ? void 0 : containerRef.children) == null ? void 0 : _b.length) === 1)
return;
if (!containerRef || ((_b = containerRef == null ? void 0 : containerRef.children) == null ? void 0 : _b.length) === 1) return;
const newWidgetId = yield (_c = window.captchafox) == null ? void 0 : _c.render(containerRef, {

@@ -133,4 +152,3 @@ lang,

useEffect(() => {
if (!containerRef)
return;
if (!containerRef) return;
if (firstRendered.current) {

@@ -137,0 +155,0 @@ if (isApiReady()) {

{
"name": "@captchafox/react",
"version": "1.5.1",
"version": "1.6.0",
"main": "./dist/index.cjs",

@@ -53,3 +53,3 @@ "module": "./dist/index.js",

"react": "^18.2.0",
"tsup": "^7.2.0",
"tsup": "^8.3.5",
"ts-jest": "^29.1.1",

@@ -56,0 +56,0 @@ "typescript": "^5.0.2"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet