@moontra/moonui-pro 2.33.10 → 2.33.12

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
@@ -509,6 +509,26 @@ async function getAuthToken() {
509
509
  });
510
510
  if (isDevelopment) {
511
511
  console.log("[MoonUI Pro Auth] Development mode - checking CLI authentication...");
512
+ if (typeof window !== "undefined") {
513
+ const cliCached = localStorage.getItem(CLI_AUTH_CACHE_KEY);
514
+ if (cliCached) {
515
+ try {
516
+ const cliCache = JSON.parse(cliCached);
517
+ const now = Date.now();
518
+ if (now - cliCache.timestamp < CLI_AUTH_CACHE_DURATION) {
519
+ console.log("[MoonUI Pro Auth] Using cached CLI auth, plan:", cliCache.plan);
520
+ if (cliCache.valid && (cliCache.plan === "lifetime" || cliCache.plan === "pro_lifetime")) {
521
+ return "cli-authenticated-pro";
522
+ }
523
+ } else {
524
+ console.log("[MoonUI Pro Auth] CLI cache expired, will revalidate");
525
+ }
526
+ } catch (e) {
527
+ console.error("[MoonUI Pro Auth] Error parsing CLI auth cache:", e);
528
+ localStorage.removeItem(CLI_AUTH_CACHE_KEY);
529
+ }
530
+ }
531
+ }
512
532
  const cliToken = await cliTokenReader.getCLIToken();
513
533
  if (cliToken) {
514
534
  console.log("[MoonUI Pro Auth] Using validated CLI token");
@@ -559,6 +579,20 @@ async function validateLicense() {
559
579
  });
560
580
  return;
561
581
  }
582
+ if (token === "cli-authenticated-pro") {
583
+ console.log("[MoonUI Pro Auth] Using cached CLI authentication");
584
+ updateGlobalState({
585
+ hasProAccess: true,
586
+ isAuthenticated: true,
587
+ subscriptionPlan: "lifetime",
588
+ subscription: {
589
+ status: "active",
590
+ plan: "lifetime"
591
+ },
592
+ isLoading: false
593
+ });
594
+ return;
595
+ }
562
596
  try {
563
597
  console.log("[MoonUI Pro Auth] Calling validate API...");
564
598
  const response = await fetch("https://moonui.dev/api/auth/validate", {
@@ -646,6 +680,35 @@ async function initializeAuth() {
646
680
  return;
647
681
  isInitialized = true;
648
682
  if (typeof window !== "undefined") {
683
+ const isDev2 = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local");
684
+ if (isDev2) {
685
+ const cliCached = localStorage.getItem(CLI_AUTH_CACHE_KEY);
686
+ if (cliCached) {
687
+ try {
688
+ const cliCache = JSON.parse(cliCached);
689
+ const now = Date.now();
690
+ if (now - cliCache.timestamp < CLI_AUTH_CACHE_DURATION) {
691
+ console.log("[MoonUI Pro Auth] Using cached CLI auth from init, plan:", cliCache.plan);
692
+ if (cliCache.valid && (cliCache.plan === "lifetime" || cliCache.plan === "pro_lifetime")) {
693
+ updateGlobalState({
694
+ hasProAccess: true,
695
+ isAuthenticated: true,
696
+ subscriptionPlan: "lifetime",
697
+ subscription: {
698
+ status: "active",
699
+ plan: "lifetime"
700
+ },
701
+ isLoading: false
702
+ });
703
+ return;
704
+ }
705
+ }
706
+ } catch (e) {
707
+ console.error("[MoonUI Pro Auth] Error parsing CLI auth cache:", e);
708
+ localStorage.removeItem(CLI_AUTH_CACHE_KEY);
709
+ }
710
+ }
711
+ }
649
712
  const cached = localStorage.getItem(CACHE_KEY);
650
713
  if (cached) {
651
714
  const cacheData = JSON.parse(cached);
@@ -765,7 +828,7 @@ function useSubscription() {
765
828
  clearCache
766
829
  };
767
830
  }
768
- var globalAuthState, isInitialized, subscribers, CACHE_KEY;
831
+ var globalAuthState, isInitialized, subscribers, CACHE_KEY, CLI_AUTH_CACHE_KEY, CLI_AUTH_CACHE_DURATION;
769
832
  var init_use_subscription = __esm({
770
833
  "src/hooks/use-subscription.ts"() {
771
834
  init_cli_token_reader();
@@ -783,6 +846,8 @@ var init_use_subscription = __esm({
783
846
  isInitialized = false;
784
847
  subscribers = [];
785
848
  CACHE_KEY = "moonui_license_cache";
849
+ CLI_AUTH_CACHE_KEY = "moonui_cli_auth_cache";
850
+ CLI_AUTH_CACHE_DURATION = 60 * 60 * 1e3;
786
851
  }
787
852
  });
788
853
 
@@ -2771,9 +2836,9 @@ function createAIProvider(provider, config) {
2771
2836
  // src/index.ts
2772
2837
  init_use_subscription();
2773
2838
  var CACHE_KEY2 = "moonui_license_cache";
2774
- var CLI_AUTH_CACHE_KEY = "moonui_cli_auth_cache";
2839
+ var CLI_AUTH_CACHE_KEY2 = "moonui_cli_auth_cache";
2775
2840
  var CACHE_DURATION = !process.env.VERCEL ? 1 * 60 * 1e3 : 24 * 60 * 60 * 1e3;
2776
- var CLI_AUTH_CACHE_DURATION = 60 * 60 * 1e3;
2841
+ var CLI_AUTH_CACHE_DURATION2 = 60 * 60 * 1e3;
2777
2842
  var OFFLINE_GRACE_PERIOD = !process.env.VERCEL ? 5 * 60 * 1e3 : 7 * 24 * 60 * 60 * 1e3;
2778
2843
  var SubscriptionContext = createContext(void 0);
2779
2844
  function SubscriptionProvider({ children }) {
@@ -2794,12 +2859,12 @@ function SubscriptionProvider({ children }) {
2794
2859
  const devToken = process.env.NEXT_PUBLIC_MOONUI_DEV_TOKEN;
2795
2860
  const deviceId = process.env.NEXT_PUBLIC_MOONUI_DEVICE_ID;
2796
2861
  if (devToken && deviceId) {
2797
- const cachedAuth = localStorage.getItem(CLI_AUTH_CACHE_KEY);
2862
+ const cachedAuth = localStorage.getItem(CLI_AUTH_CACHE_KEY2);
2798
2863
  if (cachedAuth) {
2799
2864
  try {
2800
2865
  const cache2 = JSON.parse(cachedAuth);
2801
2866
  const now = Date.now();
2802
- if (now - cache2.timestamp < CLI_AUTH_CACHE_DURATION) {
2867
+ if (now - cache2.timestamp < CLI_AUTH_CACHE_DURATION2) {
2803
2868
  console.log("[MoonUI Pro] Using cached CLI auth response");
2804
2869
  if (cache2.valid && (cache2.plan === "lifetime" || cache2.plan === "pro_lifetime")) {
2805
2870
  return "cli-authenticated-pro";
@@ -2808,7 +2873,7 @@ function SubscriptionProvider({ children }) {
2808
2873
  }
2809
2874
  } catch (e) {
2810
2875
  console.error("[MoonUI Pro] Error parsing CLI auth cache:", e);
2811
- localStorage.removeItem(CLI_AUTH_CACHE_KEY);
2876
+ localStorage.removeItem(CLI_AUTH_CACHE_KEY2);
2812
2877
  }
2813
2878
  }
2814
2879
  try {
@@ -2838,14 +2903,15 @@ function SubscriptionProvider({ children }) {
2838
2903
  if (response.ok) {
2839
2904
  const data = await response.json();
2840
2905
  console.log("[MoonUI Pro] Response data:", data);
2906
+ const planValue = typeof data.plan === "object" ? data.plan?.plan : data.plan;
2841
2907
  const cacheData = {
2842
2908
  valid: data.valid,
2843
- plan: data.plan,
2909
+ plan: planValue || "free",
2844
2910
  timestamp: Date.now()
2845
2911
  };
2846
- localStorage.setItem(CLI_AUTH_CACHE_KEY, JSON.stringify(cacheData));
2847
- console.log("[MoonUI Pro] Cached CLI auth response for 1 hour");
2848
- if (data.valid && (data.plan === "lifetime" || data.plan === "pro_lifetime")) {
2912
+ localStorage.setItem(CLI_AUTH_CACHE_KEY2, JSON.stringify(cacheData));
2913
+ console.log("[MoonUI Pro] Cached CLI auth response for 1 hour, plan:", planValue);
2914
+ if (data.valid && (planValue === "lifetime" || planValue === "pro_lifetime")) {
2849
2915
  return "cli-authenticated-pro";
2850
2916
  } else if (data.valid) {
2851
2917
  return null;
@@ -2857,7 +2923,7 @@ function SubscriptionProvider({ children }) {
2857
2923
  const errorObj = JSON.parse(errorData);
2858
2924
  if (errorObj.reason === "browser-fingerprint-invalid" || errorObj.reason === "cli-session-missing" || response.status === 401) {
2859
2925
  console.error("[MoonUI Pro] Critical auth error");
2860
- localStorage.removeItem(CLI_AUTH_CACHE_KEY);
2926
+ localStorage.removeItem(CLI_AUTH_CACHE_KEY2);
2861
2927
  }
2862
2928
  } catch (e) {
2863
2929
  }
@@ -2942,11 +3008,11 @@ function SubscriptionProvider({ children }) {
2942
3008
  setLastCheckTime(now);
2943
3009
  try {
2944
3010
  if (true) {
2945
- const cliCached = localStorage.getItem(CLI_AUTH_CACHE_KEY);
3011
+ const cliCached = localStorage.getItem(CLI_AUTH_CACHE_KEY2);
2946
3012
  if (cliCached) {
2947
3013
  try {
2948
3014
  const cliCache = JSON.parse(cliCached);
2949
- if (now - cliCache.timestamp < CLI_AUTH_CACHE_DURATION) {
3015
+ if (now - cliCache.timestamp < CLI_AUTH_CACHE_DURATION2) {
2950
3016
  console.log("[MoonUI Pro] Using cached CLI auth from checkAccess");
2951
3017
  if (cliCache.valid && (cliCache.plan === "lifetime" || cliCache.plan === "pro_lifetime")) {
2952
3018
  setHasProAccess(true);
@@ -2957,7 +3023,7 @@ function SubscriptionProvider({ children }) {
2957
3023
  }
2958
3024
  } catch (e) {
2959
3025
  console.error("[MoonUI Pro] Error parsing CLI auth cache:", e);
2960
- localStorage.removeItem(CLI_AUTH_CACHE_KEY);
3026
+ localStorage.removeItem(CLI_AUTH_CACHE_KEY2);
2961
3027
  }
2962
3028
  }
2963
3029
  console.log("[MoonUI Pro] No valid CLI cache, checking CLI auth...");
@@ -3016,21 +3082,6 @@ function SubscriptionProvider({ children }) {
3016
3082
  }
3017
3083
  function useSubscriptionContext() {
3018
3084
  const context = useContext(SubscriptionContext);
3019
- if (context === void 0) {
3020
- return {
3021
- isLoading: false,
3022
- hasProAccess: false,
3023
- isAuthenticated: false,
3024
- subscriptionPlan: "free",
3025
- subscription: {
3026
- status: "inactive",
3027
- plan: "free"
3028
- },
3029
- isAdmin: false,
3030
- checkAccess: async () => {
3031
- }
3032
- };
3033
- }
3034
3085
  return context;
3035
3086
  }
3036
3087
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.33.10",
3
+ "version": "2.33.12",
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",