@marvalt/madapter 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +60 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +61 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/react/components/TurnstileWidget.d.ts +47 -0
- package/dist/react/components/TurnstileWidget.d.ts.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/mautic-proxy.d.ts.map +1 -1
- package/dist/server/turnstile.d.ts +24 -0
- package/dist/server/turnstile.d.ts.map +1 -0
- package/dist/server.cjs +137 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.esm.js +137 -1
- package/dist/server.esm.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.cjs +13 -0
- package/templates/MAUTIC_SECURITY.md +308 -0
package/dist/index.cjs
CHANGED
|
@@ -2658,6 +2658,65 @@ const useMauticEvent = () => {
|
|
|
2658
2658
|
};
|
|
2659
2659
|
};
|
|
2660
2660
|
|
|
2661
|
+
const TurnstileWidget = ({ siteKey, onSuccess, onError, onExpire, theme = 'auto', size = 'normal', tabIndex, }) => {
|
|
2662
|
+
const widgetRef = React.useRef(null);
|
|
2663
|
+
const widgetId = React.useRef(null);
|
|
2664
|
+
const scriptLoaded = React.useRef(false);
|
|
2665
|
+
React.useEffect(() => {
|
|
2666
|
+
if (!widgetRef.current || !siteKey)
|
|
2667
|
+
return;
|
|
2668
|
+
const loadTurnstile = () => {
|
|
2669
|
+
if (window.turnstile && widgetRef.current && !widgetId.current) {
|
|
2670
|
+
try {
|
|
2671
|
+
widgetId.current = window.turnstile.render(widgetRef.current, {
|
|
2672
|
+
sitekey: siteKey,
|
|
2673
|
+
callback: onSuccess,
|
|
2674
|
+
'error-callback': onError,
|
|
2675
|
+
'expired-callback': onExpire,
|
|
2676
|
+
theme,
|
|
2677
|
+
size,
|
|
2678
|
+
tabindex: tabIndex,
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
catch (error) {
|
|
2682
|
+
console.error('Failed to render Turnstile widget:', error);
|
|
2683
|
+
onError?.();
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
// Check if Turnstile is already loaded
|
|
2688
|
+
if (window.turnstile) {
|
|
2689
|
+
loadTurnstile();
|
|
2690
|
+
}
|
|
2691
|
+
else if (!scriptLoaded.current) {
|
|
2692
|
+
// Load Turnstile script
|
|
2693
|
+
scriptLoaded.current = true;
|
|
2694
|
+
const script = document.createElement('script');
|
|
2695
|
+
script.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js';
|
|
2696
|
+
script.async = true;
|
|
2697
|
+
script.defer = true;
|
|
2698
|
+
script.onload = loadTurnstile;
|
|
2699
|
+
script.onerror = () => {
|
|
2700
|
+
console.error('Failed to load Turnstile script');
|
|
2701
|
+
onError?.();
|
|
2702
|
+
};
|
|
2703
|
+
document.head.appendChild(script);
|
|
2704
|
+
}
|
|
2705
|
+
return () => {
|
|
2706
|
+
if (widgetId.current && window.turnstile) {
|
|
2707
|
+
try {
|
|
2708
|
+
window.turnstile.remove(widgetId.current);
|
|
2709
|
+
}
|
|
2710
|
+
catch (error) {
|
|
2711
|
+
console.error('Failed to remove Turnstile widget:', error);
|
|
2712
|
+
}
|
|
2713
|
+
widgetId.current = null;
|
|
2714
|
+
}
|
|
2715
|
+
};
|
|
2716
|
+
}, [siteKey, onSuccess, onError, onExpire, theme, size, tabIndex]);
|
|
2717
|
+
return jsxRuntimeExports.jsx("div", { ref: widgetRef, className: "cf-turnstile" });
|
|
2718
|
+
};
|
|
2719
|
+
|
|
2661
2720
|
const MauticContext = React.createContext(null);
|
|
2662
2721
|
const MauticProvider = ({ config, children }) => {
|
|
2663
2722
|
const client = React.useMemo(() => {
|
|
@@ -3076,6 +3135,7 @@ exports.MauticGenerator = MauticGenerator;
|
|
|
3076
3135
|
exports.MauticProvider = MauticProvider;
|
|
3077
3136
|
exports.MauticService = MauticService;
|
|
3078
3137
|
exports.MauticTracking = MauticTracking;
|
|
3138
|
+
exports.TurnstileWidget = TurnstileWidget;
|
|
3079
3139
|
exports.createMauticConfig = createMauticConfig;
|
|
3080
3140
|
exports.formatFormDataForSubmission = formatFormDataForSubmission;
|
|
3081
3141
|
exports.generateMauticData = generateMauticData;
|