@moontra/moonui-pro 3.2.2 → 3.3.1

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/server.mjs CHANGED
@@ -3170,6 +3170,20 @@ function readLicenseTokenServer() {
3170
3170
  if (typeof window !== "undefined") {
3171
3171
  return null;
3172
3172
  }
3173
+ if (process.env.MOONUI_PRO_TOKEN) {
3174
+ try {
3175
+ const tokenString = Buffer.from(process.env.MOONUI_PRO_TOKEN, "base64").toString("utf8");
3176
+ const token2 = JSON.parse(tokenString);
3177
+ if (token2.expiresAt < Date.now()) {
3178
+ console.log("[MoonUI] License token expired, re-validation required");
3179
+ return null;
3180
+ }
3181
+ console.log("[MoonUI] License token loaded successfully from environment variable");
3182
+ return token2;
3183
+ } catch (envError) {
3184
+ console.error("[MoonUI] Failed to parse MOONUI_PRO_TOKEN:", envError);
3185
+ }
3186
+ }
3173
3187
  const fs = __require("fs");
3174
3188
  const path = __require("path");
3175
3189
  const possiblePaths = [
@@ -3178,6 +3192,13 @@ function readLicenseTokenServer() {
3178
3192
  path.join(process.cwd(), "..", "..", ".moonui-license"),
3179
3193
  path.join(__dirname, "..", "..", "..", "..", ".moonui-license")
3180
3194
  ];
3195
+ if (process.env.VERCEL_ARTIFACTS_PATH) {
3196
+ possiblePaths.push(path.join(process.env.VERCEL_ARTIFACTS_PATH, ".moonui-license"));
3197
+ }
3198
+ if (process.env.NETLIFY_BUILD_BASE) {
3199
+ possiblePaths.push(path.join(process.env.NETLIFY_BUILD_BASE, ".moonui-license"));
3200
+ }
3201
+ possiblePaths.push("/tmp/.moonui-license");
3181
3202
  let encryptedData = null;
3182
3203
  let foundPath = null;
3183
3204
  for (const filePath of possiblePaths) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "3.2.2",
3
+ "version": "3.3.1",
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",
@@ -50,33 +50,16 @@ function encryptToken(token, key) {
50
50
  // Validate license with MoonUI API
51
51
  async function validateLicense(licenseKey) {
52
52
  return new Promise((resolve, reject) => {
53
- // Determine the domain
54
- let domain = 'unknown';
55
-
56
- // Check for Vercel deployment
57
- if (process.env.VERCEL_URL) {
58
- domain = process.env.VERCEL_URL.replace(/^https?:\/\//, '');
59
- } else if (process.env.VERCEL_PROJECT_PRODUCTION_URL) {
60
- domain = process.env.VERCEL_PROJECT_PRODUCTION_URL.replace(/^https?:\/\//, '');
61
- } else if (process.env.NEXT_PUBLIC_VERCEL_URL) {
62
- domain = process.env.NEXT_PUBLIC_VERCEL_URL.replace(/^https?:\/\//, '');
63
- } else if (process.env.DEPLOY_URL) {
64
- domain = process.env.DEPLOY_URL.replace(/^https?:\/\//, '');
65
- }
66
-
67
- // For moonui.dev site, use special validation
68
- const isMoonUISite = domain.includes('moonui.dev') ||
69
- domain.includes('moonui-git') ||
70
- domain.includes('moonui-') ||
71
- process.env.MOONUI_SITE === 'true';
72
-
53
+ // Don't send domain information to prevent bypass attacks
54
+ // Only validate the license key itself
73
55
  const postData = JSON.stringify({
74
56
  licenseKey,
75
- domain: isMoonUISite ? 'moonui.dev' : domain,
76
57
  environment: 'production',
77
- isMoonUISite
58
+ source: 'postinstall'
78
59
  });
79
60
 
61
+ console.log('[MoonUI Pro] Sending validation request with data:', postData);
62
+
80
63
  const options = {
81
64
  hostname: 'moonui.dev',
82
65
  port: 443,
@@ -93,25 +76,33 @@ async function validateLicense(licenseKey) {
93
76
  const req = https.request(options, (res) => {
94
77
  let data = '';
95
78
 
79
+ console.log('[MoonUI Pro] Response status code:', res.statusCode);
80
+
96
81
  res.on('data', (chunk) => {
97
82
  data += chunk;
98
83
  });
99
84
 
100
85
  res.on('end', () => {
101
86
  try {
87
+ console.log('[MoonUI Pro] Raw response data:', data);
102
88
  const result = JSON.parse(data);
103
- if (res.statusCode === 200 && result.valid) {
89
+ console.log('[MoonUI Pro] Parsed response:', JSON.stringify(result, null, 2));
90
+
91
+ if (res.statusCode === 200) {
92
+ // Return the full result, don't check result.valid here
104
93
  resolve(result);
105
94
  } else {
106
95
  reject(new Error(result.error || 'License validation failed'));
107
96
  }
108
97
  } catch (error) {
98
+ console.error('[MoonUI Pro] Error parsing response:', error);
109
99
  reject(error);
110
100
  }
111
101
  });
112
102
  });
113
103
 
114
104
  req.on('error', (error) => {
105
+ console.error('[MoonUI Pro] Request error:', error);
115
106
  reject(error);
116
107
  });
117
108
 
@@ -120,15 +111,58 @@ async function validateLicense(licenseKey) {
120
111
  });
121
112
  }
122
113
 
123
- // Save license token to file
114
+ // Save license token to file or environment
124
115
  function saveLicenseToken(token) {
125
116
  try {
117
+ console.log('[MoonUI Pro] Starting to save license token...');
118
+
119
+ // Check if we're in Vercel build environment
120
+ const isVercelBuild = process.env.VERCEL === '1';
121
+ const isNetlifyBuild = process.env.NETLIFY === 'true';
122
+
123
+ if (isVercelBuild || isNetlifyBuild) {
124
+ console.log('[MoonUI Pro] Detected build environment:', isVercelBuild ? 'Vercel' : 'Netlify');
125
+
126
+ // In Vercel/Netlify, we can't write files persistently
127
+ // Instead, we'll set an environment variable that the build can use
128
+ const tokenString = JSON.stringify(token);
129
+ const base64Token = Buffer.from(tokenString).toString('base64');
130
+
131
+ console.log('[MoonUI Pro] Setting MOONUI_PRO_TOKEN environment variable for build...');
132
+ process.env.MOONUI_PRO_TOKEN = base64Token;
133
+
134
+ // Also try to write to a temp location that might be available during build
135
+ try {
136
+ const tempPath = process.env.VERCEL_ARTIFACTS_PATH || process.env.NETLIFY_BUILD_BASE || '/tmp';
137
+ const tempLicenseFile = path.join(tempPath, LICENSE_FILE);
138
+
139
+ // Encrypt token with a deterministic key based on environment
140
+ const encryptionKey = process.env.MOONUI_LICENSE_KEY || 'default-key';
141
+ const encryptedData = encryptToken(token, encryptionKey);
142
+
143
+ fs.writeFileSync(tempLicenseFile, JSON.stringify(encryptedData, null, 2));
144
+ console.log('[MoonUI Pro] Token saved to temporary location:', tempLicenseFile);
145
+ } catch (tempError) {
146
+ console.log('[MoonUI Pro] Could not write to temp location (expected in some environments)');
147
+ }
148
+
149
+ console.log('[MoonUI Pro] ✓ License token stored for build environment');
150
+ return true;
151
+ }
152
+
153
+ // Standard file system approach for local development
126
154
  // Find the project root (where package.json is)
127
155
  let projectRoot = process.cwd();
156
+ console.log('[MoonUI Pro] Initial working directory:', projectRoot);
157
+
128
158
  let attempts = 0;
129
159
 
130
160
  while (attempts < 10) {
131
- if (fs.existsSync(path.join(projectRoot, 'package.json'))) {
161
+ const packageJsonPath = path.join(projectRoot, 'package.json');
162
+ console.log(`[MoonUI Pro] Checking for package.json at: ${packageJsonPath}`);
163
+
164
+ if (fs.existsSync(packageJsonPath)) {
165
+ console.log('[MoonUI Pro] Found package.json at:', projectRoot);
132
166
  break;
133
167
  }
134
168
  projectRoot = path.dirname(projectRoot);
@@ -136,19 +170,44 @@ function saveLicenseToken(token) {
136
170
  }
137
171
 
138
172
  const licenseFilePath = path.join(projectRoot, LICENSE_FILE);
173
+ console.log('[MoonUI Pro] License file path:', licenseFilePath);
139
174
 
140
175
  // Encrypt token with a deterministic key based on environment
141
176
  const encryptionKey = process.env.MOONUI_LICENSE_KEY || 'default-key';
177
+ console.log('[MoonUI Pro] Using encryption key:', encryptionKey.substring(0, 10) + '...');
178
+
142
179
  const encryptedData = encryptToken(token, encryptionKey);
180
+ console.log('[MoonUI Pro] Token encrypted successfully');
143
181
 
144
182
  // Save to file
183
+ console.log('[MoonUI Pro] Writing to file:', licenseFilePath);
145
184
  fs.writeFileSync(licenseFilePath, JSON.stringify(encryptedData, null, 2));
146
185
 
147
- console.log('[MoonUI Pro] License token saved successfully');
148
- return true;
186
+ // Verify file was created
187
+ if (fs.existsSync(licenseFilePath)) {
188
+ const stats = fs.statSync(licenseFilePath);
189
+ console.log('[MoonUI Pro] ✓ License token saved successfully');
190
+ console.log('[MoonUI Pro] File size:', stats.size, 'bytes');
191
+ return true;
192
+ } else {
193
+ console.error('[MoonUI Pro] File was not created despite no errors');
194
+ return false;
195
+ }
149
196
  } catch (error) {
150
197
  console.error('[MoonUI Pro] Failed to save license token:', error.message);
151
- return false;
198
+ console.error('[MoonUI Pro] Full error:', error);
199
+
200
+ // As a fallback, try to set environment variable
201
+ try {
202
+ const tokenString = JSON.stringify(token);
203
+ const base64Token = Buffer.from(tokenString).toString('base64');
204
+ process.env.MOONUI_PRO_TOKEN = base64Token;
205
+ console.log('[MoonUI Pro] Fallback: Set MOONUI_PRO_TOKEN environment variable');
206
+ return true;
207
+ } catch (fallbackError) {
208
+ console.error('[MoonUI Pro] Fallback also failed:', fallbackError);
209
+ return false;
210
+ }
152
211
  }
153
212
  }
154
213
 
@@ -183,24 +242,39 @@ async function main() {
183
242
  // Validate license with API
184
243
  const validationResult = await validateLicense(licenseKey);
185
244
 
186
- if (validationResult.valid && validationResult.hasProAccess) {
245
+ // Debug: Log the full validation result
246
+ console.log('[MoonUI Pro] Validation result:', JSON.stringify(validationResult, null, 2));
247
+
248
+ if (validationResult && validationResult.valid && validationResult.hasProAccess) {
249
+ console.log('[MoonUI Pro] ✓ License is valid and has Pro access');
250
+
187
251
  // Create token with validation result and expiry
188
252
  const token = {
189
253
  valid: true,
190
254
  hasProAccess: validationResult.hasProAccess,
191
- plan: validationResult.plan,
255
+ plan: validationResult.plan || 'pro',
192
256
  expiresAt: Date.now() + CACHE_DURATION,
193
- domain: validationResult.domain,
194
257
  timestamp: Date.now()
195
258
  };
196
259
 
260
+ console.log('[MoonUI Pro] Creating token:', JSON.stringify(token, null, 2));
261
+
197
262
  // Save encrypted token
198
- saveLicenseToken(token);
263
+ const saveResult = saveLicenseToken(token);
199
264
 
200
- console.log('[MoonUI Pro] ✓ License validated successfully');
201
- console.log('[MoonUI Pro] ✓ Pro features enabled');
265
+ if (saveResult) {
266
+ console.log('[MoonUI Pro] ✓ License validated successfully');
267
+ console.log('[MoonUI Pro] ✓ Pro features enabled');
268
+ } else {
269
+ console.log('[MoonUI Pro] ⚠ License valid but failed to save token');
270
+ }
202
271
  } else {
203
- console.log('[MoonUI Pro] License validation failed');
272
+ console.log('[MoonUI Pro] License validation failed or no Pro access');
273
+ console.log('[MoonUI Pro] Validation result:', {
274
+ valid: validationResult?.valid || false,
275
+ hasProAccess: validationResult?.hasProAccess || false,
276
+ plan: validationResult?.plan || 'none'
277
+ });
204
278
  console.log('[MoonUI Pro] Pro features will be disabled');
205
279
  }
206
280
  } catch (error) {