@moontra/moonui-pro 2.33.7 → 2.33.9
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.global.js +51 -51
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +52 -32
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2771,17 +2771,16 @@ function createAIProvider(provider, config) {
|
|
|
2771
2771
|
// src/index.ts
|
|
2772
2772
|
init_use_subscription();
|
|
2773
2773
|
var CACHE_KEY2 = "moonui_license_cache";
|
|
2774
|
+
var CLI_AUTH_CACHE_KEY = "moonui_cli_auth_cache";
|
|
2774
2775
|
var CACHE_DURATION = !process.env.VERCEL ? 1 * 60 * 1e3 : 24 * 60 * 60 * 1e3;
|
|
2776
|
+
var CLI_AUTH_CACHE_DURATION = 60 * 60 * 1e3;
|
|
2775
2777
|
var OFFLINE_GRACE_PERIOD = !process.env.VERCEL ? 5 * 60 * 1e3 : 7 * 24 * 60 * 60 * 1e3;
|
|
2776
|
-
var CHECK_INTERVAL = !process.env.VERCEL ? 10 * 1e3 : 60 * 60 * 1e3;
|
|
2777
2778
|
var SubscriptionContext = createContext(void 0);
|
|
2778
2779
|
function SubscriptionProvider({ children }) {
|
|
2779
2780
|
const [isLoading, setIsLoading] = useState(true);
|
|
2780
2781
|
const [hasProAccess, setHasProAccess] = useState(false);
|
|
2781
2782
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
2782
2783
|
const [lastCheckTime, setLastCheckTime] = useState(0);
|
|
2783
|
-
const [authCheckInterval, setAuthCheckInterval] = useState(null);
|
|
2784
|
-
const [hasAuthError, setHasAuthError] = useState(false);
|
|
2785
2784
|
const getAuthToken2 = async () => {
|
|
2786
2785
|
if (process.env.VERCEL) {
|
|
2787
2786
|
return process.env.NEXT_PUBLIC_MOONUI_AUTH_TOKEN || process.env.MOONUI_LICENSE_KEY || null;
|
|
@@ -2795,6 +2794,23 @@ function SubscriptionProvider({ children }) {
|
|
|
2795
2794
|
const devToken = process.env.NEXT_PUBLIC_MOONUI_DEV_TOKEN;
|
|
2796
2795
|
const deviceId = process.env.NEXT_PUBLIC_MOONUI_DEVICE_ID;
|
|
2797
2796
|
if (devToken && deviceId) {
|
|
2797
|
+
const cachedAuth = localStorage.getItem(CLI_AUTH_CACHE_KEY);
|
|
2798
|
+
if (cachedAuth) {
|
|
2799
|
+
try {
|
|
2800
|
+
const cache2 = JSON.parse(cachedAuth);
|
|
2801
|
+
const now = Date.now();
|
|
2802
|
+
if (now - cache2.timestamp < CLI_AUTH_CACHE_DURATION) {
|
|
2803
|
+
console.log("[MoonUI Pro] Using cached CLI auth response");
|
|
2804
|
+
if (cache2.valid && (cache2.plan === "lifetime" || cache2.plan === "pro_lifetime")) {
|
|
2805
|
+
return "cli-authenticated-pro";
|
|
2806
|
+
}
|
|
2807
|
+
return null;
|
|
2808
|
+
}
|
|
2809
|
+
} catch (e) {
|
|
2810
|
+
console.error("[MoonUI Pro] Error parsing CLI auth cache:", e);
|
|
2811
|
+
localStorage.removeItem(CLI_AUTH_CACHE_KEY);
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2798
2814
|
try {
|
|
2799
2815
|
const decoded = JSON.parse(atob(devToken));
|
|
2800
2816
|
const jwtToken = decoded.token;
|
|
@@ -2822,7 +2838,14 @@ function SubscriptionProvider({ children }) {
|
|
|
2822
2838
|
if (response.ok) {
|
|
2823
2839
|
const data = await response.json();
|
|
2824
2840
|
console.log("[MoonUI Pro] Response data:", data);
|
|
2825
|
-
|
|
2841
|
+
const cacheData = {
|
|
2842
|
+
valid: data.valid,
|
|
2843
|
+
plan: data.plan,
|
|
2844
|
+
timestamp: Date.now()
|
|
2845
|
+
};
|
|
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")) {
|
|
2826
2849
|
return "cli-authenticated-pro";
|
|
2827
2850
|
} else if (data.valid) {
|
|
2828
2851
|
return null;
|
|
@@ -2833,12 +2856,8 @@ function SubscriptionProvider({ children }) {
|
|
|
2833
2856
|
try {
|
|
2834
2857
|
const errorObj = JSON.parse(errorData);
|
|
2835
2858
|
if (errorObj.reason === "browser-fingerprint-invalid" || errorObj.reason === "cli-session-missing" || response.status === 401) {
|
|
2836
|
-
console.error("[MoonUI Pro] Critical auth error
|
|
2837
|
-
|
|
2838
|
-
if (authCheckInterval) {
|
|
2839
|
-
clearInterval(authCheckInterval);
|
|
2840
|
-
setAuthCheckInterval(null);
|
|
2841
|
-
}
|
|
2859
|
+
console.error("[MoonUI Pro] Critical auth error");
|
|
2860
|
+
localStorage.removeItem(CLI_AUTH_CACHE_KEY);
|
|
2842
2861
|
}
|
|
2843
2862
|
} catch (e) {
|
|
2844
2863
|
}
|
|
@@ -2921,17 +2940,36 @@ function SubscriptionProvider({ children }) {
|
|
|
2921
2940
|
}
|
|
2922
2941
|
setLastCheckTime(now);
|
|
2923
2942
|
try {
|
|
2943
|
+
if (true) {
|
|
2944
|
+
const cliCached = localStorage.getItem(CLI_AUTH_CACHE_KEY);
|
|
2945
|
+
if (cliCached) {
|
|
2946
|
+
try {
|
|
2947
|
+
const cliCache = JSON.parse(cliCached);
|
|
2948
|
+
if (now - cliCache.timestamp < CLI_AUTH_CACHE_DURATION) {
|
|
2949
|
+
console.log("[MoonUI Pro] Using cached CLI auth from checkAccess");
|
|
2950
|
+
if (cliCache.valid && (cliCache.plan === "lifetime" || cliCache.plan === "pro_lifetime")) {
|
|
2951
|
+
setHasProAccess(true);
|
|
2952
|
+
setIsAuthenticated(true);
|
|
2953
|
+
setIsLoading(false);
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
} catch (e) {
|
|
2958
|
+
console.error("[MoonUI Pro] Error parsing CLI auth cache:", e);
|
|
2959
|
+
localStorage.removeItem(CLI_AUTH_CACHE_KEY);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2924
2963
|
const cached = localStorage.getItem(CACHE_KEY2);
|
|
2925
2964
|
if (cached) {
|
|
2926
2965
|
const cacheData = JSON.parse(cached);
|
|
2927
|
-
|
|
2928
|
-
if (now2 - cacheData.timestamp < CACHE_DURATION) {
|
|
2966
|
+
if (now - cacheData.timestamp < CACHE_DURATION) {
|
|
2929
2967
|
setHasProAccess(cacheData.valid && cacheData.hasLifetimeAccess);
|
|
2930
2968
|
setIsAuthenticated(cacheData.valid);
|
|
2931
2969
|
setIsLoading(false);
|
|
2932
2970
|
return;
|
|
2933
2971
|
}
|
|
2934
|
-
if (
|
|
2972
|
+
if (now - cacheData.timestamp < OFFLINE_GRACE_PERIOD) {
|
|
2935
2973
|
validateLicense2().catch(() => {
|
|
2936
2974
|
setHasProAccess(cacheData.valid && cacheData.hasLifetimeAccess);
|
|
2937
2975
|
setIsAuthenticated(cacheData.valid);
|
|
@@ -2951,25 +2989,7 @@ function SubscriptionProvider({ children }) {
|
|
|
2951
2989
|
};
|
|
2952
2990
|
useEffect(() => {
|
|
2953
2991
|
checkAccess();
|
|
2954
|
-
|
|
2955
|
-
const interval = setInterval(() => {
|
|
2956
|
-
if (!hasAuthError) {
|
|
2957
|
-
console.log("[MoonUI Pro] Running periodic auth check...");
|
|
2958
|
-
validateLicense2().catch((error) => {
|
|
2959
|
-
console.error("[MoonUI Pro] Periodic auth check failed:", error);
|
|
2960
|
-
});
|
|
2961
|
-
} else {
|
|
2962
|
-
console.log("[MoonUI Pro] Auth check disabled due to critical error");
|
|
2963
|
-
clearInterval(interval);
|
|
2964
|
-
}
|
|
2965
|
-
}, CHECK_INTERVAL);
|
|
2966
|
-
setAuthCheckInterval(interval);
|
|
2967
|
-
return () => {
|
|
2968
|
-
if (interval)
|
|
2969
|
-
clearInterval(interval);
|
|
2970
|
-
};
|
|
2971
|
-
}
|
|
2972
|
-
}, [hasAuthError]);
|
|
2992
|
+
}, []);
|
|
2973
2993
|
const value = {
|
|
2974
2994
|
isLoading,
|
|
2975
2995
|
hasProAccess,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.33.
|
|
3
|
+
"version": "2.33.9",
|
|
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",
|