@infuro/cms-core 1.0.34 → 1.0.36
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/README.md +13 -0
- package/dist/OrderTrackPage-W3J6WIG2.js +426 -0
- package/dist/OrderTrackPage-Z6FCJQYY.cjs +428 -0
- package/dist/admin.cjs +35254 -21613
- package/dist/admin.d.cts +192 -9
- package/dist/admin.d.ts +192 -9
- package/dist/admin.js +34301 -20755
- package/dist/api.cjs +137 -17531
- package/dist/api.d.cts +633 -3
- package/dist/api.d.ts +633 -3
- package/dist/api.js +15 -17528
- package/dist/auth.cjs +192 -1034
- package/dist/auth.d.cts +197 -54
- package/dist/auth.d.ts +197 -54
- package/dist/auth.js +4 -966
- package/dist/chunk-2AEVFOQP.cjs +30436 -0
- package/dist/chunk-3DZRIZOD.cjs +52 -0
- package/dist/chunk-5ELSW2UP.js +150 -0
- package/dist/chunk-7NMT3GBR.cjs +29 -0
- package/dist/chunk-COBORIJH.cjs +2373 -0
- package/dist/chunk-CRFV5WJK.js +16 -0
- package/dist/chunk-D5FBNKQM.cjs +104 -0
- package/dist/chunk-FG6I64HP.js +604 -0
- package/dist/chunk-GO7PPYNU.js +76 -0
- package/dist/chunk-HCIRL37O.js +21 -0
- package/dist/chunk-HF3L2GIT.cjs +194 -0
- package/dist/chunk-HT5DI3XW.cjs +82 -0
- package/dist/chunk-JC6DLWTE.js +21 -0
- package/dist/chunk-JS2W7XZ4.js +30312 -0
- package/dist/chunk-JXF23MPG.js +25 -0
- package/dist/chunk-KFFB6EMZ.js +123 -0
- package/dist/chunk-KPKFNLQQ.cjs +648 -0
- package/dist/chunk-LI2IXVAY.js +171 -0
- package/dist/chunk-MQBT33IV.js +48 -0
- package/dist/chunk-OOTLNH63.cjs +18 -0
- package/dist/chunk-PNOKNSG2.cjs +222 -0
- package/dist/chunk-SHUYVCID.js +4 -0
- package/dist/chunk-SPQFNIYJ.cjs +132 -0
- package/dist/chunk-SYBOCAWB.js +97 -0
- package/dist/chunk-TDV6EJHV.js +192 -0
- package/dist/chunk-UCKN4BBY.cjs +24 -0
- package/dist/chunk-UF3BYUXY.js +616 -0
- package/dist/chunk-UPLVMVRX.cjs +23 -0
- package/dist/chunk-USNT2KNT.cjs +6 -0
- package/dist/chunk-VMY2S32H.js +2342 -0
- package/dist/chunk-WEMDMVHQ.js +216 -0
- package/dist/chunk-WO2DW4AU.cjs +182 -0
- package/dist/chunk-X47PBV4I.js +79 -0
- package/dist/chunk-X6H5VBQ2.cjs +620 -0
- package/dist/chunk-XQ3QUHWR.cjs +83 -0
- package/dist/chunk-XW5ATPRW.cjs +155 -0
- package/dist/cli.cjs +107 -86
- package/dist/cli.js +66 -29
- package/dist/email-queue-CGZBVVAS.js +2 -0
- package/dist/email-queue-TPZWLTIV.cjs +23 -0
- package/dist/emit-order-notification-trigger-D2N3KFHL.cjs +16 -0
- package/dist/emit-order-notification-trigger-IVLWKKJL.js +3 -0
- package/dist/erp-config-enabled-CUMQ6N2V.cjs +11 -0
- package/dist/erp-config-enabled-T37X7T34.js +2 -0
- package/dist/erp-order-invoice-3YISSOWW.js +3 -0
- package/dist/erp-order-invoice-ZR5F2KTA.cjs +12 -0
- package/dist/event-order-defaults-EMWBIGL3.cjs +39 -0
- package/dist/event-order-defaults-SDRNAZHC.js +2 -0
- package/dist/hooks.cjs +259 -132
- package/dist/hooks.d.cts +42 -1
- package/dist/hooks.d.ts +42 -1
- package/dist/hooks.js +234 -91
- package/dist/index.cjs +3679 -22356
- package/dist/index.d.cts +2173 -643
- package/dist/index.d.ts +2173 -643
- package/dist/index.js +2587 -22119
- package/dist/interpolate-WAKPN56R.cjs +11 -0
- package/dist/interpolate-WDUWDF3I.js +2 -0
- package/dist/migrations/1779400000000-ConvertStatusToEnum.ts +142 -0
- package/dist/migrations/1779400000000-SeedDefaultCurrencies.ts +33 -0
- package/dist/migrations/1779500000000-VendorRolesAndPermissions.ts +102 -0
- package/dist/migrations/1779600000000-VendorRegistrationProfile.ts +52 -0
- package/dist/migrations/1779700000000-CollectionIsCatalog.ts +22 -0
- package/dist/migrations/1779710000000-CollectionPlatformCatalog.ts +60 -0
- package/dist/migrations/1779720000000-ProductCategoryPlatformCatalog.ts +157 -0
- package/dist/migrations/1779800000000-EventsAndEventProducts.ts +173 -0
- package/dist/migrations/1779810000000-BackfillVendorRoleEventsPermissions.ts +38 -0
- package/dist/migrations/1779820000000-FixProductsCategoryForeignKey.ts +70 -0
- package/dist/migrations/1779830000000-ProductTitleColumn.ts +32 -0
- package/dist/migrations/1779840000000-EventAboutAndVisibilityFields.ts +34 -0
- package/dist/migrations/1779850000000-EventCityCountrySplit.ts +43 -0
- package/dist/migrations/1779860000000-CreateCombos.ts +140 -0
- package/dist/migrations/1780100000000-OrderAttendeesEventId.ts +55 -0
- package/dist/migrations/1780110000000-EventContactFormId.ts +49 -0
- package/dist/migrations/1780130000000-ProductVariants.ts +54 -0
- package/dist/migrations/1780140000000-EventManagementEnhancements.ts +44 -0
- package/dist/migrations/1780160000000-EventRegistrationGstProductContactForm.ts +79 -0
- package/dist/migrations/1780170000000-ComboCurrencyPrices.ts +20 -0
- package/dist/migrations/1781110000000-VendorOwnerCombosPermission.ts +38 -0
- package/dist/migrations/1781120000000-RefundPoliciesAndRequests.ts +225 -0
- package/dist/migrations/1781130000000-CreateAttendees.ts +44 -0
- package/dist/migrations/1781140000000-EventOrderNotifications.ts +29 -0
- package/dist/migrations/1781150000000-EventNamedLists.ts +28 -0
- package/dist/migrations/1781160000000-RefundPolicyEventTiers.ts +27 -0
- package/dist/migrations/1781170000000-EventRefundPolicy.ts +42 -0
- package/dist/migrations/1781180000000-RemoveCartItemsUniqueConstraint.ts +15 -0
- package/dist/migrations/1781190000000-RenameProductTaxesToProductConfig.ts +84 -0
- package/dist/migrations/1781200000000-VendorOwnerProductConfigPermissions.ts +51 -0
- package/dist/migrations/1781210000000-VendorRoleProductConfigPermissions.ts +46 -0
- package/dist/migrations/1781220000000-AddWhatsappTriggerBindings.ts +23 -0
- package/dist/migrations/1781230000000-AddOrderNotificationTriggers.ts +46 -0
- package/dist/migrations/1781240000000-DropEventOrderNotificationColumns.ts +29 -0
- package/dist/migrations/1781250000000-RemoveOrderRefundedTrigger.ts +36 -0
- package/dist/migrations/helpers/vendor-role-seed.ts +243 -0
- package/dist/paid-order-erp-3USEG6WL.js +3 -0
- package/dist/paid-order-erp-FSQ3GSXE.cjs +12 -0
- package/dist/pg-boss-service-4XF2TQ2E.js +2 -0
- package/dist/pg-boss-service-L6MTF4EQ.cjs +15 -0
- package/dist/razorpay-KLO2KNCB.js +49 -0
- package/dist/razorpay-U23LGY72.cjs +56 -0
- package/dist/rbac-debug-db-HWP65A4O.cjs +35 -0
- package/dist/rbac-debug-db-QJH3AD34.js +33 -0
- package/dist/sms-defaults-2NL24H57.js +2 -0
- package/dist/sms-defaults-KCOPKQBA.cjs +19 -0
- package/dist/stripe-4FD27QVJ.js +51 -0
- package/dist/stripe-VU6OEG2D.cjs +57 -0
- package/dist/theme.cjs +31 -59
- package/dist/theme.d.cts +78 -3
- package/dist/theme.d.ts +78 -3
- package/dist/theme.js +23 -20
- package/dist/vendor-invite-status-77O7ZQ3U.cjs +19 -0
- package/dist/vendor-invite-status-PWJ3DE76.js +2 -0
- package/dist/whatsapp-trigger-dispatcher-ONHXI7UY.cjs +19 -0
- package/dist/whatsapp-trigger-dispatcher-PWFI4FKP.js +6 -0
- package/package.json +147 -142
- package/dist/admin.cjs.map +0 -1
- package/dist/admin.js.map +0 -1
- package/dist/api.cjs.map +0 -1
- package/dist/api.js.map +0 -1
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config-DJ5CmQvS.d.cts +0 -8
- package/dist/config-DJ5CmQvS.d.ts +0 -8
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/index-Bf5GO8fu.d.cts +0 -583
- package/dist/index-DOiJuMQA.d.ts +0 -583
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme.cjs.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/types-DCVaXlPV.d.cts +0 -78
- package/dist/types-DCVaXlPV.d.ts +0 -78
- package/dist/vendor-scope-DTYhJk_I.d.cts +0 -129
- package/dist/vendor-scope-DTYhJk_I.d.ts +0 -129
package/dist/hooks.js
CHANGED
|
@@ -1,23 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
import { useState, useEffect } from
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
import React2, { createContext, useState, useEffect, useContext, useRef, useCallback, useMemo } from 'react';
|
|
3
|
+
|
|
3
4
|
var MOBILE_BREAKPOINT = 768;
|
|
4
5
|
function useIsMobile() {
|
|
5
6
|
const [isMobile, setIsMobile] = useState(void 0);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
8
|
-
const onChange = () => setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9
|
+
const onChange = /* @__PURE__ */ __name(() => setIsMobile(window.innerWidth < MOBILE_BREAKPOINT), "onChange");
|
|
9
10
|
mql.addEventListener("change", onChange);
|
|
10
11
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
11
12
|
return () => mql.removeEventListener("change", onChange);
|
|
12
13
|
}, []);
|
|
13
14
|
return !!isMobile;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
__name(useIsMobile, "useIsMobile");
|
|
17
|
+
function useCatalogCategories(enabled = true) {
|
|
18
|
+
const [categories, setCategories] = useState([]);
|
|
19
|
+
const [loading, setLoading] = useState(enabled);
|
|
20
|
+
const [error, setError] = useState(null);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!enabled) {
|
|
23
|
+
setLoading(false);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let cancelled = false;
|
|
27
|
+
setLoading(true);
|
|
28
|
+
(async () => {
|
|
29
|
+
try {
|
|
30
|
+
const res = await fetch("/api/product_categories?limit=500&sortField=sortOrder&sortOrder=asc&active=true&isCatalog=true");
|
|
31
|
+
const data = await res.json().catch(() => ({}));
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const msg = typeof data.error === "string" ? data.error : "Failed to load categories";
|
|
34
|
+
throw new Error(msg);
|
|
35
|
+
}
|
|
36
|
+
if (cancelled) return;
|
|
37
|
+
const rows = Array.isArray(data.data) ? data.data : [];
|
|
38
|
+
setCategories(rows.filter((c) => c.active !== false));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (!cancelled) {
|
|
41
|
+
setError(e instanceof Error ? e.message : "Could not load categories");
|
|
42
|
+
}
|
|
43
|
+
} finally {
|
|
44
|
+
if (!cancelled) setLoading(false);
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
return () => {
|
|
48
|
+
cancelled = true;
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
enabled
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
categories,
|
|
55
|
+
loading,
|
|
56
|
+
error
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
__name(useCatalogCategories, "useCatalogCategories");
|
|
60
|
+
function vendorCategoryWorkspaceUrl(categoryId, collectionId) {
|
|
61
|
+
const params = new URLSearchParams({
|
|
62
|
+
categoryId: String(categoryId)
|
|
63
|
+
});
|
|
64
|
+
if (collectionId != null && String(collectionId).trim() !== "") {
|
|
65
|
+
params.set("collectionId", String(collectionId));
|
|
66
|
+
}
|
|
67
|
+
return `/admin/products?${params.toString()}`;
|
|
68
|
+
}
|
|
69
|
+
__name(vendorCategoryWorkspaceUrl, "vendorCategoryWorkspaceUrl");
|
|
70
|
+
function vendorCollectionCreateUrl(categoryId, from, options) {
|
|
71
|
+
const params = new URLSearchParams({
|
|
72
|
+
categoryId: String(categoryId)
|
|
73
|
+
});
|
|
74
|
+
if (options?.isCatalog) params.set("isCatalog", "true");
|
|
75
|
+
const base = `/admin/collections/create?${params.toString()}`;
|
|
76
|
+
return from ? `${base}&from=${encodeURIComponent(from)}` : base;
|
|
77
|
+
}
|
|
78
|
+
__name(vendorCollectionCreateUrl, "vendorCollectionCreateUrl");
|
|
79
|
+
function vendorProductCreateUrl(categoryId, options) {
|
|
80
|
+
const params = new URLSearchParams({
|
|
81
|
+
categoryId: String(categoryId)
|
|
82
|
+
});
|
|
83
|
+
if (options?.collectionId != null && String(options.collectionId).trim() !== "") {
|
|
84
|
+
params.set("collectionId", String(options.collectionId));
|
|
85
|
+
}
|
|
86
|
+
if (options?.eventId != null && String(options.eventId).trim() !== "") {
|
|
87
|
+
params.set("eventId", String(options.eventId));
|
|
88
|
+
}
|
|
89
|
+
const base = `/admin/products/create?${params.toString()}`;
|
|
90
|
+
return options?.from ? `${base}&from=${encodeURIComponent(options.from)}` : base;
|
|
91
|
+
}
|
|
92
|
+
__name(vendorProductCreateUrl, "vendorProductCreateUrl");
|
|
93
|
+
function vendorEventProductCreateUrl(eventId, options) {
|
|
94
|
+
const params = new URLSearchParams({
|
|
95
|
+
eventId: String(eventId)
|
|
96
|
+
});
|
|
97
|
+
if (options?.categoryId != null && String(options.categoryId).trim() !== "") {
|
|
98
|
+
params.set("categoryId", String(options.categoryId));
|
|
99
|
+
}
|
|
100
|
+
const base = `/admin/products/create?${params.toString()}`;
|
|
101
|
+
return options?.from ? `${base}&from=${encodeURIComponent(options.from)}` : base;
|
|
102
|
+
}
|
|
103
|
+
__name(vendorEventProductCreateUrl, "vendorEventProductCreateUrl");
|
|
104
|
+
function useCatalogCollections(enabled = true) {
|
|
105
|
+
const [collections, setCollections] = useState([]);
|
|
106
|
+
const [loading, setLoading] = useState(enabled);
|
|
107
|
+
const [error, setError] = useState(null);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (!enabled) {
|
|
110
|
+
setLoading(false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
let cancelled = false;
|
|
114
|
+
setLoading(true);
|
|
115
|
+
(async () => {
|
|
116
|
+
try {
|
|
117
|
+
const res = await fetch("/api/collections?limit=500&sortField=sortOrder&sortOrder=asc&active=true&isCatalog=true");
|
|
118
|
+
const data = await res.json().catch(() => ({}));
|
|
119
|
+
if (!res.ok) {
|
|
120
|
+
const msg = typeof data.error === "string" ? data.error : "Failed to load collections";
|
|
121
|
+
throw new Error(msg);
|
|
122
|
+
}
|
|
123
|
+
if (cancelled) return;
|
|
124
|
+
const rows = Array.isArray(data.data) ? data.data : [];
|
|
125
|
+
setCollections(rows.filter((c) => c.active !== false));
|
|
126
|
+
} catch (e) {
|
|
127
|
+
if (!cancelled) {
|
|
128
|
+
setError(e instanceof Error ? e.message : "Could not load collections");
|
|
129
|
+
}
|
|
130
|
+
} finally {
|
|
131
|
+
if (!cancelled) setLoading(false);
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
return () => {
|
|
135
|
+
cancelled = true;
|
|
136
|
+
};
|
|
137
|
+
}, [
|
|
138
|
+
enabled
|
|
139
|
+
]);
|
|
140
|
+
return {
|
|
141
|
+
collections,
|
|
142
|
+
loading,
|
|
143
|
+
error
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
__name(useCatalogCollections, "useCatalogCollections");
|
|
147
|
+
function vendorCollectionProductsUrl(collectionId) {
|
|
148
|
+
return `/admin/products?collectionId=${collectionId}`;
|
|
149
|
+
}
|
|
150
|
+
__name(vendorCollectionProductsUrl, "vendorCollectionProductsUrl");
|
|
18
151
|
function useAnalytics(pathname) {
|
|
19
152
|
const isAdminRoute = pathname != null && pathname.startsWith("/admin");
|
|
20
|
-
|
|
153
|
+
useEffect(() => {
|
|
21
154
|
if (isAdminRoute && typeof window !== "undefined") {
|
|
22
155
|
if (typeof window.gtag === "function") {
|
|
23
156
|
window.gtag = () => {
|
|
@@ -27,43 +160,35 @@ function useAnalytics(pathname) {
|
|
|
27
160
|
window.dataLayer = [];
|
|
28
161
|
}
|
|
29
162
|
}
|
|
30
|
-
}, [
|
|
31
|
-
|
|
163
|
+
}, [
|
|
164
|
+
isAdminRoute
|
|
165
|
+
]);
|
|
166
|
+
return {
|
|
167
|
+
isAdminRoute,
|
|
168
|
+
shouldTrack: !isAdminRoute
|
|
169
|
+
};
|
|
32
170
|
}
|
|
33
|
-
|
|
34
|
-
// src/hooks/use-plugin.ts
|
|
35
|
-
import React, { createContext, useContext } from "react";
|
|
171
|
+
__name(useAnalytics, "useAnalytics");
|
|
36
172
|
var PluginContext = createContext(null);
|
|
37
|
-
function PluginProvider({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
173
|
+
function PluginProvider({ getPlugin, children }) {
|
|
174
|
+
return React2.createElement(PluginContext.Provider, {
|
|
175
|
+
value: {
|
|
176
|
+
getPlugin
|
|
177
|
+
}
|
|
178
|
+
}, children);
|
|
42
179
|
}
|
|
180
|
+
__name(PluginProvider, "PluginProvider");
|
|
43
181
|
function usePlugin(name) {
|
|
44
182
|
const ctx = useContext(PluginContext);
|
|
45
183
|
if (!ctx) return void 0;
|
|
46
184
|
return ctx.getPlugin(name);
|
|
47
185
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
import {
|
|
51
|
-
createContext as createContext2,
|
|
52
|
-
useCallback,
|
|
53
|
-
useContext as useContext2,
|
|
54
|
-
useEffect as useEffect3,
|
|
55
|
-
useMemo,
|
|
56
|
-
useRef,
|
|
57
|
-
useState as useState2
|
|
58
|
-
} from "react";
|
|
59
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
60
|
-
var CaptchaReactContext = createContext2(null);
|
|
186
|
+
__name(usePlugin, "usePlugin");
|
|
187
|
+
var CaptchaReactContext = /* @__PURE__ */ createContext(null);
|
|
61
188
|
function loadScript(src) {
|
|
62
189
|
return new Promise((resolve, reject) => {
|
|
63
190
|
const base = src.split("?")[0] ?? src;
|
|
64
|
-
const existing = Array.from(document.querySelectorAll("script[src]")).some(
|
|
65
|
-
(el) => el.src.startsWith(base)
|
|
66
|
-
);
|
|
191
|
+
const existing = Array.from(document.querySelectorAll("script[src]")).some((el) => el.src.startsWith(base));
|
|
67
192
|
if (existing) {
|
|
68
193
|
resolve();
|
|
69
194
|
return;
|
|
@@ -76,14 +201,15 @@ function loadScript(src) {
|
|
|
76
201
|
document.head.appendChild(s);
|
|
77
202
|
});
|
|
78
203
|
}
|
|
204
|
+
__name(loadScript, "loadScript");
|
|
79
205
|
function CaptchaProvider({ children }) {
|
|
80
|
-
const [config, setConfig] =
|
|
81
|
-
const [selectedProvider, setSelectedProvider] =
|
|
82
|
-
const [ready, setReady] =
|
|
206
|
+
const [config, setConfig] = useState(null);
|
|
207
|
+
const [selectedProvider, setSelectedProvider] = useState(null);
|
|
208
|
+
const [ready, setReady] = useState(false);
|
|
83
209
|
const turnstileWidgetIdRef = useRef(null);
|
|
84
210
|
const turnstileContainerRef = useRef(null);
|
|
85
211
|
const turnstileTokenRef = useRef(null);
|
|
86
|
-
|
|
212
|
+
useEffect(() => {
|
|
87
213
|
let cancelled = false;
|
|
88
214
|
fetch("/api/public/captcha-config").then((r) => r.ok ? r.json() : null).then((c) => {
|
|
89
215
|
if (cancelled || !c) return;
|
|
@@ -97,7 +223,7 @@ function CaptchaProvider({ children }) {
|
|
|
97
223
|
cancelled = true;
|
|
98
224
|
};
|
|
99
225
|
}, []);
|
|
100
|
-
|
|
226
|
+
useEffect(() => {
|
|
101
227
|
if (!config?.enabled || !selectedProvider) return;
|
|
102
228
|
const siteKeyFor = config.availableProviders.find((p) => p.id === selectedProvider)?.siteKey;
|
|
103
229
|
if (!siteKeyFor) return;
|
|
@@ -105,9 +231,7 @@ function CaptchaProvider({ children }) {
|
|
|
105
231
|
(async () => {
|
|
106
232
|
try {
|
|
107
233
|
if (selectedProvider === "recaptcha_v3") {
|
|
108
|
-
await loadScript(
|
|
109
|
-
`https://www.google.com/recaptcha/api.js?render=${encodeURIComponent(siteKeyFor)}`
|
|
110
|
-
);
|
|
234
|
+
await loadScript(`https://www.google.com/recaptcha/api.js?render=${encodeURIComponent(siteKeyFor)}`);
|
|
111
235
|
} else {
|
|
112
236
|
await loadScript("https://challenges.cloudflare.com/turnstile/v0/api.js");
|
|
113
237
|
if (cancelled || !turnstileContainerRef.current || !window.turnstile) return;
|
|
@@ -121,21 +245,21 @@ function CaptchaProvider({ children }) {
|
|
|
121
245
|
const wid = window.turnstile.render(turnstileContainerRef.current, {
|
|
122
246
|
sitekey: siteKeyFor,
|
|
123
247
|
execution: "execute",
|
|
124
|
-
callback: (token) => {
|
|
248
|
+
callback: /* @__PURE__ */ __name((token) => {
|
|
125
249
|
const p = turnstileTokenRef.current;
|
|
126
250
|
turnstileTokenRef.current = null;
|
|
127
251
|
p?.resolve(token);
|
|
128
|
-
},
|
|
129
|
-
"error-callback": () => {
|
|
252
|
+
}, "callback"),
|
|
253
|
+
"error-callback": /* @__PURE__ */ __name(() => {
|
|
130
254
|
const p = turnstileTokenRef.current;
|
|
131
255
|
turnstileTokenRef.current = null;
|
|
132
256
|
p?.reject(new Error("Turnstile error"));
|
|
133
|
-
},
|
|
134
|
-
"expired-callback": () => {
|
|
257
|
+
}, "error-callback"),
|
|
258
|
+
"expired-callback": /* @__PURE__ */ __name(() => {
|
|
135
259
|
const p = turnstileTokenRef.current;
|
|
136
260
|
turnstileTokenRef.current = null;
|
|
137
261
|
p?.reject(new Error("Turnstile expired"));
|
|
138
|
-
}
|
|
262
|
+
}, "expired-callback")
|
|
139
263
|
});
|
|
140
264
|
turnstileWidgetIdRef.current = wid;
|
|
141
265
|
}
|
|
@@ -145,7 +269,10 @@ function CaptchaProvider({ children }) {
|
|
|
145
269
|
return () => {
|
|
146
270
|
cancelled = true;
|
|
147
271
|
};
|
|
148
|
-
}, [
|
|
272
|
+
}, [
|
|
273
|
+
config,
|
|
274
|
+
selectedProvider
|
|
275
|
+
]);
|
|
149
276
|
const getCaptchaPayload = useCallback(async () => {
|
|
150
277
|
if (!config?.enabled || !selectedProvider) return {};
|
|
151
278
|
const siteKeyFor = config.availableProviders.find((p) => p.id === selectedProvider)?.siteKey;
|
|
@@ -154,15 +281,23 @@ function CaptchaProvider({ children }) {
|
|
|
154
281
|
if (!window.grecaptcha) return {};
|
|
155
282
|
const token2 = await new Promise((resolve, reject) => {
|
|
156
283
|
window.grecaptcha.ready(() => {
|
|
157
|
-
window.grecaptcha.execute(siteKeyFor, {
|
|
284
|
+
window.grecaptcha.execute(siteKeyFor, {
|
|
285
|
+
action: "submit"
|
|
286
|
+
}).then(resolve).catch(reject);
|
|
158
287
|
});
|
|
159
288
|
});
|
|
160
|
-
return {
|
|
289
|
+
return {
|
|
290
|
+
captchaToken: token2,
|
|
291
|
+
captchaProvider: "recaptcha_v3"
|
|
292
|
+
};
|
|
161
293
|
}
|
|
162
294
|
const wid = turnstileWidgetIdRef.current;
|
|
163
295
|
if (!wid || !window.turnstile) return {};
|
|
164
296
|
const token = await new Promise((resolve, reject) => {
|
|
165
|
-
turnstileTokenRef.current = {
|
|
297
|
+
turnstileTokenRef.current = {
|
|
298
|
+
resolve,
|
|
299
|
+
reject
|
|
300
|
+
};
|
|
166
301
|
try {
|
|
167
302
|
window.turnstile.reset(wid);
|
|
168
303
|
window.turnstile.execute(wid);
|
|
@@ -171,49 +306,57 @@ function CaptchaProvider({ children }) {
|
|
|
171
306
|
reject(e instanceof Error ? e : new Error("Turnstile execute failed"));
|
|
172
307
|
}
|
|
173
308
|
});
|
|
174
|
-
return {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
309
|
+
return {
|
|
310
|
+
captchaToken: token,
|
|
311
|
+
captchaProvider: "turnstile"
|
|
312
|
+
};
|
|
313
|
+
}, [
|
|
314
|
+
config,
|
|
315
|
+
selectedProvider
|
|
316
|
+
]);
|
|
317
|
+
const ctx = useMemo(() => ({
|
|
318
|
+
config,
|
|
319
|
+
ready,
|
|
320
|
+
selectedProvider,
|
|
321
|
+
setSelectedProvider,
|
|
322
|
+
getCaptchaPayload
|
|
323
|
+
}), [
|
|
324
|
+
config,
|
|
325
|
+
ready,
|
|
326
|
+
selectedProvider,
|
|
327
|
+
getCaptchaPayload
|
|
328
|
+
]);
|
|
329
|
+
return /* @__PURE__ */ React2.createElement(CaptchaReactContext.Provider, {
|
|
330
|
+
value: ctx
|
|
331
|
+
}, config?.enabled && config.multipleProviders ? /* @__PURE__ */ React2.createElement("div", {
|
|
332
|
+
className: "mb-2 text-sm text-muted-foreground max-w-md"
|
|
333
|
+
}, /* @__PURE__ */ React2.createElement("label", {
|
|
334
|
+
className: "mr-2",
|
|
335
|
+
htmlFor: "captcha-provider-select"
|
|
336
|
+
}, "Verification"), /* @__PURE__ */ React2.createElement("select", {
|
|
337
|
+
id: "captcha-provider-select",
|
|
338
|
+
className: "border rounded px-2 py-1 bg-background",
|
|
339
|
+
value: selectedProvider ?? "",
|
|
340
|
+
onChange: /* @__PURE__ */ __name((e) => setSelectedProvider(e.target.value), "onChange")
|
|
341
|
+
}, config.availableProviders.map((p) => /* @__PURE__ */ React2.createElement("option", {
|
|
342
|
+
key: p.id,
|
|
343
|
+
value: p.id
|
|
344
|
+
}, p.id === "turnstile" ? "Cloudflare Turnstile" : "Google reCAPTCHA v3")))) : null, /* @__PURE__ */ React2.createElement("div", {
|
|
345
|
+
ref: turnstileContainerRef,
|
|
346
|
+
className: "hidden",
|
|
347
|
+
"aria-hidden": true
|
|
348
|
+
}), children);
|
|
203
349
|
}
|
|
350
|
+
__name(CaptchaProvider, "CaptchaProvider");
|
|
204
351
|
function useCaptchaPayload() {
|
|
205
|
-
const ctx =
|
|
352
|
+
const ctx = useContext(CaptchaReactContext);
|
|
206
353
|
return useCallback(async () => {
|
|
207
354
|
if (!ctx?.config?.enabled || !ctx.ready) return {};
|
|
208
355
|
return ctx.getCaptchaPayload();
|
|
209
|
-
}, [
|
|
356
|
+
}, [
|
|
357
|
+
ctx
|
|
358
|
+
]);
|
|
210
359
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
useAnalytics,
|
|
215
|
-
useCaptchaPayload,
|
|
216
|
-
useIsMobile,
|
|
217
|
-
usePlugin
|
|
218
|
-
};
|
|
219
|
-
//# sourceMappingURL=hooks.js.map
|
|
360
|
+
__name(useCaptchaPayload, "useCaptchaPayload");
|
|
361
|
+
|
|
362
|
+
export { CaptchaProvider, PluginProvider, useAnalytics, useCaptchaPayload, useCatalogCategories, useCatalogCollections, useIsMobile, usePlugin, vendorCategoryWorkspaceUrl, vendorCollectionCreateUrl, vendorCollectionProductsUrl, vendorEventProductCreateUrl, vendorProductCreateUrl };
|