@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.d.ts
CHANGED
|
@@ -461,6 +461,52 @@ declare const useMauticEvent: () => {
|
|
|
461
461
|
trackPageview: () => void;
|
|
462
462
|
};
|
|
463
463
|
|
|
464
|
+
/**
|
|
465
|
+
* @license GPL-3.0-or-later
|
|
466
|
+
*
|
|
467
|
+
* This file is part of the MarVAlt Open SDK.
|
|
468
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
469
|
+
*
|
|
470
|
+
* This program is free software: you can redistribute it and/or modify
|
|
471
|
+
* it under the terms of the GNU General Public License as published by
|
|
472
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
473
|
+
* (at your option) any later version.
|
|
474
|
+
*
|
|
475
|
+
* This program is distributed in the hope that it will be useful,
|
|
476
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
477
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
478
|
+
* See the GNU General Public License for more details.
|
|
479
|
+
*/
|
|
480
|
+
|
|
481
|
+
declare global {
|
|
482
|
+
interface Window {
|
|
483
|
+
turnstile?: {
|
|
484
|
+
render: (element: HTMLElement, options: TurnstileOptions) => string;
|
|
485
|
+
remove: (widgetId: string) => void;
|
|
486
|
+
reset: (widgetId: string) => void;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
interface TurnstileOptions {
|
|
491
|
+
sitekey: string;
|
|
492
|
+
callback?: (token: string) => void;
|
|
493
|
+
'error-callback'?: () => void;
|
|
494
|
+
'expired-callback'?: () => void;
|
|
495
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
496
|
+
size?: 'normal' | 'compact';
|
|
497
|
+
tabindex?: number;
|
|
498
|
+
}
|
|
499
|
+
interface TurnstileWidgetProps {
|
|
500
|
+
siteKey: string;
|
|
501
|
+
onSuccess: (token: string) => void;
|
|
502
|
+
onError?: () => void;
|
|
503
|
+
onExpire?: () => void;
|
|
504
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
505
|
+
size?: 'normal' | 'compact';
|
|
506
|
+
tabIndex?: number;
|
|
507
|
+
}
|
|
508
|
+
declare const TurnstileWidget: React.FC<TurnstileWidgetProps>;
|
|
509
|
+
|
|
464
510
|
/**
|
|
465
511
|
* Set the default Mautic client for hooks
|
|
466
512
|
*/
|
|
@@ -770,5 +816,5 @@ declare const sanitizeFormData: (formData: Record<string, any>) => Record<string
|
|
|
770
816
|
*/
|
|
771
817
|
declare const formatFormDataForSubmission: (formData: Record<string, any>) => Record<string, any>;
|
|
772
818
|
|
|
773
|
-
export { MauticClient, MauticForm, MauticGenerator, MauticProvider, MauticService, MauticTracking, createMauticConfig, formatFormDataForSubmission, generateMauticData, getAllFieldTypes, getDataMetadata, getDefaultMauticConfig, getFormByAlias, getFormById, getFormFieldByAlias, getFormsByFieldType, getFormsByType, getFormsCountByStatus, getMauticConfigSummary, getMauticData, getPublishedForms, isDataLoaded, isFormDataValid, isMauticEnabled, isRequiredFieldValid, isValidEmail, isValidPhone, isValidUrl, loadMauticData, mauticService, mergeMauticConfig, sanitizeFormData, searchForms, setMauticClient, useMauticAddTags, useMauticAddToSegment, useMauticClient, useMauticConfig, useMauticContactByEmail, useMauticContactTags, useMauticContext, useMauticCreateContact, useMauticEvent, useMauticEventTracking, useMauticForm, useMauticFormSubmission, useMauticForms, useMauticRemoveFromSegment, useMauticRemoveTags, useMauticSegments, useMauticTags, useMauticTracking, useMauticUpdateContact, validateField, validateFormData, validateMauticConfig };
|
|
819
|
+
export { MauticClient, MauticForm, MauticGenerator, MauticProvider, MauticService, MauticTracking, TurnstileWidget, createMauticConfig, formatFormDataForSubmission, generateMauticData, getAllFieldTypes, getDataMetadata, getDefaultMauticConfig, getFormByAlias, getFormById, getFormFieldByAlias, getFormsByFieldType, getFormsByType, getFormsCountByStatus, getMauticConfigSummary, getMauticData, getPublishedForms, isDataLoaded, isFormDataValid, isMauticEnabled, isRequiredFieldValid, isValidEmail, isValidPhone, isValidUrl, loadMauticData, mauticService, mergeMauticConfig, sanitizeFormData, searchForms, setMauticClient, useMauticAddTags, useMauticAddToSegment, useMauticClient, useMauticConfig, useMauticContactByEmail, useMauticContactTags, useMauticContext, useMauticCreateContact, useMauticEvent, useMauticEventTracking, useMauticForm, useMauticFormSubmission, useMauticForms, useMauticRemoveFromSegment, useMauticRemoveTags, useMauticSegments, useMauticTags, useMauticTracking, useMauticUpdateContact, validateField, validateFormData, validateMauticConfig };
|
|
774
820
|
export type { AuthMode, MauticApiResponse, MauticConfig, MauticContact, MauticEvent, MauticFormAction, MauticFormConfig, MauticFormData, MauticFormField, MauticFormSubmission, MauticForm$1 as MauticFormType, MauticGeneratorConfig, MauticStaticData, MauticTrackingConfig };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,wBA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AAe,GAChB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,UAAU,IAAI,cAAc,EAC5B,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import React, { useState, useEffect, createContext, useMemo, useContext } from 'react';
|
|
3
|
+
import React, { useState, useEffect, useRef, createContext, useMemo, useContext } from 'react';
|
|
4
4
|
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -2655,6 +2655,65 @@ const useMauticEvent = () => {
|
|
|
2655
2655
|
};
|
|
2656
2656
|
};
|
|
2657
2657
|
|
|
2658
|
+
const TurnstileWidget = ({ siteKey, onSuccess, onError, onExpire, theme = 'auto', size = 'normal', tabIndex, }) => {
|
|
2659
|
+
const widgetRef = useRef(null);
|
|
2660
|
+
const widgetId = useRef(null);
|
|
2661
|
+
const scriptLoaded = useRef(false);
|
|
2662
|
+
useEffect(() => {
|
|
2663
|
+
if (!widgetRef.current || !siteKey)
|
|
2664
|
+
return;
|
|
2665
|
+
const loadTurnstile = () => {
|
|
2666
|
+
if (window.turnstile && widgetRef.current && !widgetId.current) {
|
|
2667
|
+
try {
|
|
2668
|
+
widgetId.current = window.turnstile.render(widgetRef.current, {
|
|
2669
|
+
sitekey: siteKey,
|
|
2670
|
+
callback: onSuccess,
|
|
2671
|
+
'error-callback': onError,
|
|
2672
|
+
'expired-callback': onExpire,
|
|
2673
|
+
theme,
|
|
2674
|
+
size,
|
|
2675
|
+
tabindex: tabIndex,
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
catch (error) {
|
|
2679
|
+
console.error('Failed to render Turnstile widget:', error);
|
|
2680
|
+
onError?.();
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
};
|
|
2684
|
+
// Check if Turnstile is already loaded
|
|
2685
|
+
if (window.turnstile) {
|
|
2686
|
+
loadTurnstile();
|
|
2687
|
+
}
|
|
2688
|
+
else if (!scriptLoaded.current) {
|
|
2689
|
+
// Load Turnstile script
|
|
2690
|
+
scriptLoaded.current = true;
|
|
2691
|
+
const script = document.createElement('script');
|
|
2692
|
+
script.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js';
|
|
2693
|
+
script.async = true;
|
|
2694
|
+
script.defer = true;
|
|
2695
|
+
script.onload = loadTurnstile;
|
|
2696
|
+
script.onerror = () => {
|
|
2697
|
+
console.error('Failed to load Turnstile script');
|
|
2698
|
+
onError?.();
|
|
2699
|
+
};
|
|
2700
|
+
document.head.appendChild(script);
|
|
2701
|
+
}
|
|
2702
|
+
return () => {
|
|
2703
|
+
if (widgetId.current && window.turnstile) {
|
|
2704
|
+
try {
|
|
2705
|
+
window.turnstile.remove(widgetId.current);
|
|
2706
|
+
}
|
|
2707
|
+
catch (error) {
|
|
2708
|
+
console.error('Failed to remove Turnstile widget:', error);
|
|
2709
|
+
}
|
|
2710
|
+
widgetId.current = null;
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
}, [siteKey, onSuccess, onError, onExpire, theme, size, tabIndex]);
|
|
2714
|
+
return jsxRuntimeExports.jsx("div", { ref: widgetRef, className: "cf-turnstile" });
|
|
2715
|
+
};
|
|
2716
|
+
|
|
2658
2717
|
const MauticContext = createContext(null);
|
|
2659
2718
|
const MauticProvider = ({ config, children }) => {
|
|
2660
2719
|
const client = useMemo(() => {
|
|
@@ -3067,5 +3126,5 @@ const formatFormDataForSubmission = (formData) => {
|
|
|
3067
3126
|
return formatted;
|
|
3068
3127
|
};
|
|
3069
3128
|
|
|
3070
|
-
export { MauticClient, MauticForm, MauticGenerator, MauticProvider, MauticService, MauticTracking, createMauticConfig, formatFormDataForSubmission, generateMauticData, getAllFieldTypes, getDataMetadata, getDefaultMauticConfig, getFormByAlias, getFormById, getFormFieldByAlias, getFormsByFieldType, getFormsByType, getFormsCountByStatus, getMauticConfigSummary, getMauticData, getPublishedForms, isDataLoaded, isFormDataValid, isMauticEnabled, isRequiredFieldValid, isValidEmail, isValidPhone, isValidUrl, loadMauticData, mauticService, mergeMauticConfig, sanitizeFormData, searchForms, setMauticClient, useMauticAddTags, useMauticAddToSegment, useMauticClient, useMauticConfig, useMauticContactByEmail, useMauticContactTags, useMauticContext, useMauticCreateContact, useMauticEvent, useMauticEventTracking, useMauticForm, useMauticFormSubmission, useMauticForms, useMauticRemoveFromSegment, useMauticRemoveTags, useMauticSegments, useMauticTags, useMauticTracking, useMauticUpdateContact, validateField, validateFormData, validateMauticConfig };
|
|
3129
|
+
export { MauticClient, MauticForm, MauticGenerator, MauticProvider, MauticService, MauticTracking, TurnstileWidget, createMauticConfig, formatFormDataForSubmission, generateMauticData, getAllFieldTypes, getDataMetadata, getDefaultMauticConfig, getFormByAlias, getFormById, getFormFieldByAlias, getFormsByFieldType, getFormsByType, getFormsCountByStatus, getMauticConfigSummary, getMauticData, getPublishedForms, isDataLoaded, isFormDataValid, isMauticEnabled, isRequiredFieldValid, isValidEmail, isValidPhone, isValidUrl, loadMauticData, mauticService, mergeMauticConfig, sanitizeFormData, searchForms, setMauticClient, useMauticAddTags, useMauticAddToSegment, useMauticClient, useMauticConfig, useMauticContactByEmail, useMauticContactTags, useMauticContext, useMauticCreateContact, useMauticEvent, useMauticEventTracking, useMauticForm, useMauticFormSubmission, useMauticForms, useMauticRemoveFromSegment, useMauticRemoveTags, useMauticSegments, useMauticTags, useMauticTracking, useMauticUpdateContact, validateField, validateFormData, validateMauticConfig };
|
|
3071
3130
|
//# sourceMappingURL=index.esm.js.map
|