@moontra/moonui-pro 2.37.13 → 2.37.15

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.mjs CHANGED
@@ -2185,15 +2185,30 @@ function MoonUIAuthProvider({ children }) {
2185
2185
  authPromise = (async () => {
2186
2186
  try {
2187
2187
  lastFetchTime = now;
2188
- const isProduction = false;
2189
- const isDevelopment = true;
2190
- console.log("[MoonUI Auth] Environment Detection:", {
2191
- NODE_ENV: "development",
2192
- isProduction,
2193
- isDevelopment,
2194
- window: typeof window !== "undefined" ? "available" : "SSR"
2195
- });
2196
- const isLocalhost = typeof window !== "undefined" ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.startsWith("192.168.") || window.location.hostname.startsWith("10.") : false;
2188
+ let isProduction = false;
2189
+ let isDevelopment = true;
2190
+ let environmentInfo = {};
2191
+ try {
2192
+ const envResponse = await fetch("/api/environment", {
2193
+ method: "GET",
2194
+ cache: "no-store"
2195
+ });
2196
+ if (envResponse.ok) {
2197
+ environmentInfo = await envResponse.json();
2198
+ isProduction = environmentInfo.isProduction;
2199
+ isDevelopment = environmentInfo.isDevelopment;
2200
+ console.log("[MoonUI Auth] Runtime Environment Detection:", {
2201
+ ...environmentInfo.debug,
2202
+ environment: environmentInfo.environment,
2203
+ isProduction,
2204
+ isDevelopment
2205
+ });
2206
+ } else {
2207
+ console.warn("[MoonUI Auth] Failed to fetch environment info, falling back to development mode");
2208
+ }
2209
+ } catch (error) {
2210
+ console.warn("[MoonUI Auth] Error fetching environment info:", error);
2211
+ }
2197
2212
  if (isDevelopment) {
2198
2213
  let response;
2199
2214
  const authServerUrl = typeof window !== "undefined" ? process.env.NEXT_PUBLIC_MOONUI_AUTH_SERVER || "http://localhost:7878" : "http://localhost:7878";
@@ -2233,7 +2248,64 @@ function MoonUIAuthProvider({ children }) {
2233
2248
  console.log('[MoonUI Auth] Auth server not available in development. Run "moonui dev" to enable Pro features.');
2234
2249
  }
2235
2250
  }
2236
- if (isProduction) ;
2251
+ if (isProduction) {
2252
+ const licenseKey = environmentInfo.hasLicenseKey ? process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY || process.env.MOONUI_LICENSE_KEY || process.env.VITE_MOONUI_LICENSE_KEY || process.env.REACT_APP_MOONUI_LICENSE_KEY || "check-server" : null;
2253
+ if (licenseKey) {
2254
+ console.log("[MoonUI Auth] Production mode - validating license key...");
2255
+ try {
2256
+ const currentDomain = typeof window !== "undefined" ? window.location.hostname : process.env.VERCEL_URL || process.env.NEXT_PUBLIC_VERCEL_URL || "";
2257
+ const apiUrl = "https://moonui.dev/api/v1/license/validate";
2258
+ const validationResponse = await fetch(apiUrl, {
2259
+ method: "POST",
2260
+ headers: {
2261
+ "Content-Type": "application/json"
2262
+ },
2263
+ body: JSON.stringify({
2264
+ licenseKey,
2265
+ domain: currentDomain
2266
+ })
2267
+ });
2268
+ if (validationResponse.ok) {
2269
+ const validationData = await validationResponse.json();
2270
+ if (validationData.valid && validationData.hasProAccess) {
2271
+ console.log("[MoonUI Auth] License key validated successfully");
2272
+ const newState = {
2273
+ isLoading: false,
2274
+ hasProAccess: validationData.hasProAccess,
2275
+ isAuthenticated: true,
2276
+ subscriptionPlan: validationData.plan === "lifetime" ? "lifetime" : "free",
2277
+ subscription: {
2278
+ status: validationData.hasProAccess ? "active" : "inactive",
2279
+ plan: validationData.plan === "lifetime" ? "lifetime" : "free"
2280
+ },
2281
+ isAdmin: false
2282
+ };
2283
+ if (typeof document !== "undefined" && validationData.cacheDuration) {
2284
+ const cacheData = {
2285
+ valid: true,
2286
+ hasProAccess: validationData.hasProAccess,
2287
+ timestamp: Date.now()
2288
+ };
2289
+ document.cookie = `moonui_pro_status=${encodeURIComponent(
2290
+ JSON.stringify(cacheData)
2291
+ )}; max-age=${Math.floor(validationData.cacheDuration / 1e3)}; path=/; SameSite=Strict`;
2292
+ }
2293
+ if (isMounted.current) {
2294
+ setState(newState);
2295
+ }
2296
+ authPromise = null;
2297
+ return newState;
2298
+ } else {
2299
+ console.warn("[MoonUI Auth] License key validation failed:", validationData.error || "Invalid license");
2300
+ }
2301
+ } else {
2302
+ console.error("[MoonUI Auth] License validation request failed:", validationResponse.status);
2303
+ }
2304
+ } catch (error) {
2305
+ console.error("[MoonUI Auth] License validation error:", error);
2306
+ }
2307
+ }
2308
+ }
2237
2309
  const freeState = {
2238
2310
  isLoading: false,
2239
2311
  hasProAccess: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.37.13",
3
+ "version": "2.37.15",
4
4
  "description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",