@moontra/moonui-pro 2.37.5 → 2.37.7

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
@@ -2055,9 +2055,9 @@ function createAIProvider(provider, config) {
2055
2055
  // src/lib/auth-config.ts
2056
2056
  var IS_PRODUCTION = false;
2057
2057
  var AUTH_CONFIG = {
2058
- // Internal API endpoint (never external)
2059
- // Developers will implement this endpoint in their own project
2060
- internalEndpoint: "/api/moonui/validate-pro",
2058
+ // CLI Auth Server endpoint (REQUIRED - No fallback)
2059
+ // Run "moonui dev" to start the auth server
2060
+ authServerEndpoint: process.env.NEXT_PUBLIC_MOONUI_AUTH_SERVER || "http://localhost:7878",
2061
2061
  // Cache configuration
2062
2062
  cache: {
2063
2063
  // Server-side cache duration
@@ -2203,15 +2203,22 @@ function MoonUIAuthProvider({ children }) {
2203
2203
  throw new Error("Auth server not available");
2204
2204
  }
2205
2205
  } catch (error) {
2206
- console.log("[MoonUI Auth] Auth server not available, falling back to API route");
2207
- response = await fetch(AUTH_CONFIG.internalEndpoint, {
2208
- method: "GET",
2209
- credentials: "include",
2210
- headers: {
2211
- "Content-Type": "application/json",
2212
- "X-Request-ID": `auth-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
2213
- }
2214
- });
2206
+ console.log('[MoonUI Auth] Auth server not available. Run "moonui dev" to enable Pro features.');
2207
+ const freeState = {
2208
+ isLoading: false,
2209
+ hasProAccess: false,
2210
+ isAuthenticated: false,
2211
+ subscriptionPlan: "free",
2212
+ subscription: {
2213
+ status: "inactive",
2214
+ plan: "free"
2215
+ },
2216
+ isAdmin: false
2217
+ };
2218
+ if (isMounted.current) {
2219
+ setState(freeState);
2220
+ }
2221
+ return freeState;
2215
2222
  }
2216
2223
  if (!response.ok) {
2217
2224
  console.error("[MoonUI Auth] Validation failed:", response.status);
@@ -2394,12 +2401,13 @@ function useSubscription() {
2394
2401
  }
2395
2402
  try {
2396
2403
  console.log("[Client Auth] Validating with internal API...");
2397
- const response = await fetch(AUTH_CONFIG.internalEndpoint, {
2404
+ const response = await fetch(`${AUTH_CONFIG.authServerEndpoint}/validate`, {
2398
2405
  method: "GET",
2399
2406
  credentials: "include",
2400
2407
  // Include cookies
2401
2408
  headers: {
2402
- "Content-Type": "application/json"
2409
+ "Content-Type": "application/json",
2410
+ "X-Component": "useSubscription"
2403
2411
  }
2404
2412
  });
2405
2413
  if (!response.ok) {
@@ -2512,12 +2520,7 @@ function clearAuth() {
2512
2520
  } catch (error) {
2513
2521
  }
2514
2522
  if (typeof window !== "undefined") {
2515
- fetch(AUTH_CONFIG.internalEndpoint, {
2516
- method: "DELETE",
2517
- credentials: "include"
2518
- }).then(() => {
2519
- window.location.reload();
2520
- });
2523
+ window.location.reload();
2521
2524
  }
2522
2525
  }
2523
2526
  async function sha256(message) {
package/dist/server.d.ts CHANGED
@@ -60,7 +60,7 @@ declare function performServerValidation(): Promise<{
60
60
  * It ensures zero external API calls from the browser.
61
61
  */
62
62
  declare const AUTH_CONFIG: {
63
- readonly internalEndpoint: "/api/moonui/validate-pro";
63
+ readonly authServerEndpoint: string;
64
64
  readonly cache: {
65
65
  readonly serverCacheDuration: number;
66
66
  readonly cookieMaxAge: number;
package/dist/server.mjs CHANGED
@@ -2965,9 +2965,9 @@ var import_headers = __toESM(require_headers3(), 1);
2965
2965
  // src/lib/auth-config.ts
2966
2966
  var IS_PRODUCTION = false;
2967
2967
  var AUTH_CONFIG = {
2968
- // Internal API endpoint (never external)
2969
- // Developers will implement this endpoint in their own project
2970
- internalEndpoint: "/api/moonui/validate-pro",
2968
+ // CLI Auth Server endpoint (REQUIRED - No fallback)
2969
+ // Run "moonui dev" to start the auth server
2970
+ authServerEndpoint: process.env.NEXT_PUBLIC_MOONUI_AUTH_SERVER || "http://localhost:7878",
2971
2971
  // Cache configuration
2972
2972
  cache: {
2973
2973
  // Server-side cache duration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.37.5",
3
+ "version": "2.37.7",
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",
@@ -12,7 +12,6 @@
12
12
  "dist",
13
13
  "scripts",
14
14
  "plugin",
15
- "templates",
16
15
  "README.md",
17
16
  "LICENSE"
18
17
  ],
@@ -40,8 +39,7 @@
40
39
  "types": "./plugin/index.d.ts",
41
40
  "import": "./plugin/index.js",
42
41
  "require": "./plugin/index.js"
43
- },
44
- "./templates/validate-pro-route": "./templates/validate-pro-route.ts"
42
+ }
45
43
  },
46
44
  "scripts": {
47
45
  "build": "tsup && node scripts/postbuild.js",
@@ -1,157 +0,0 @@
1
- /**
2
- * MoonUI Pro - Server Validation API Route Template
3
- *
4
- * INSTALLATION:
5
- * 1. Copy this file to your project: app/api/moonui/validate-pro/route.ts
6
- * 2. Set environment variable: MOONUI_LICENSE_KEY=your-license-key
7
- * 3. (Optional) Set encryption key: MOONUI_ENCRYPTION_KEY=your-secret-key
8
- *
9
- * This route handles server-side validation to prevent browser API calls.
10
- */
11
-
12
- import { NextRequest, NextResponse } from "next/server";
13
- import {
14
- performServerValidation,
15
- clearValidationCookies,
16
- generateServerDeviceFingerprint,
17
- setValidationInCookies,
18
- } from "@moontra/moonui-pro/server";
19
-
20
- // In-memory cache for rate limiting (use Redis in production)
21
- const validationCache = new Map<
22
- string,
23
- {
24
- count: number;
25
- resetAt: number;
26
- }
27
- >();
28
-
29
- // Rate limiting helper
30
- function checkRateLimit(identifier: string): boolean {
31
- const now = Date.now();
32
- const limit = validationCache.get(identifier);
33
-
34
- if (!limit || limit.resetAt < now) {
35
- // Reset or create new limit
36
- validationCache.set(identifier, {
37
- count: 1,
38
- resetAt: now + 60 * 1000, // 1 minute window
39
- });
40
- return true;
41
- }
42
-
43
- if (limit.count >= 10) {
44
- // Max 10 requests per minute
45
- return false;
46
- }
47
-
48
- limit.count++;
49
- return true;
50
- }
51
-
52
- /**
53
- * GET /api/moonui/validate-pro
54
- * Validates the current session
55
- */
56
- export async function GET(request: NextRequest) {
57
- try {
58
- // Generate device fingerprint for rate limiting
59
- const deviceId = await generateServerDeviceFingerprint();
60
-
61
- // Check rate limit
62
- if (!checkRateLimit(deviceId)) {
63
- return NextResponse.json(
64
- { error: "Rate limit exceeded", valid: false },
65
- { status: 429 }
66
- );
67
- }
68
-
69
- // Perform server-side validation
70
- const validation = await performServerValidation();
71
-
72
- // Return validation result
73
- // Client will read from cookies, not from this response
74
- return NextResponse.json({
75
- valid: validation.valid,
76
- hasProAccess: validation.hasProAccess,
77
- cached: validation.cached,
78
- });
79
- } catch (error) {
80
- console.error("[API] Validation error:", error);
81
- return NextResponse.json(
82
- { error: "Internal server error", valid: false },
83
- { status: 500 }
84
- );
85
- }
86
- }
87
-
88
- /**
89
- * POST /api/moonui/validate-pro
90
- * Validates a provided token
91
- */
92
- export async function POST(request: NextRequest) {
93
- try {
94
- const body = await request.json();
95
- const { token } = body;
96
-
97
- if (!token) {
98
- return NextResponse.json(
99
- { error: "Token required", valid: false },
100
- { status: 400 }
101
- );
102
- }
103
-
104
- // Generate device fingerprint
105
- const deviceId = await generateServerDeviceFingerprint();
106
-
107
- // Check rate limit
108
- if (!checkRateLimit(deviceId)) {
109
- return NextResponse.json(
110
- { error: "Rate limit exceeded", valid: false },
111
- { status: 429 }
112
- );
113
- }
114
-
115
- // Import server validation utilities
116
- const { validateWithMoonUIServer } = await import(
117
- "@moontra/moonui-pro/server"
118
- );
119
-
120
- // Validate token with MoonUI server
121
- const result = await validateWithMoonUIServer(token, deviceId);
122
-
123
- // If valid, set cookies for future requests
124
- if (result.valid) {
125
- await setValidationInCookies(result);
126
- }
127
-
128
- return NextResponse.json(result);
129
- } catch (error) {
130
- console.error("[API] Validation error:", error);
131
- return NextResponse.json(
132
- { error: "Internal server error", valid: false },
133
- { status: 500 }
134
- );
135
- }
136
- }
137
-
138
- /**
139
- * DELETE /api/moonui/validate-pro
140
- * Clears validation session
141
- */
142
- export async function DELETE(request: NextRequest) {
143
- try {
144
- await clearValidationCookies();
145
-
146
- return NextResponse.json({
147
- success: true,
148
- message: "Validation cleared",
149
- });
150
- } catch (error) {
151
- console.error("[API] Clear validation error:", error);
152
- return NextResponse.json(
153
- { error: "Failed to clear validation" },
154
- { status: 500 }
155
- );
156
- }
157
- }