@moontra/moonui-pro 3.3.0 → 3.3.2
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 +21 -0
- package/package.json +1 -1
- package/scripts/postinstall.cjs +121 -12
- package/scripts/validate-license.cjs +53 -0
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.3.
|
|
3
|
+
"version": "3.3.2",
|
|
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",
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -58,6 +58,8 @@ async function validateLicense(licenseKey) {
|
|
|
58
58
|
source: 'postinstall'
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
console.log('[MoonUI Pro] Sending validation request with data:', postData);
|
|
62
|
+
|
|
61
63
|
const options = {
|
|
62
64
|
hostname: 'moonui.dev',
|
|
63
65
|
port: 443,
|
|
@@ -74,25 +76,33 @@ async function validateLicense(licenseKey) {
|
|
|
74
76
|
const req = https.request(options, (res) => {
|
|
75
77
|
let data = '';
|
|
76
78
|
|
|
79
|
+
console.log('[MoonUI Pro] Response status code:', res.statusCode);
|
|
80
|
+
|
|
77
81
|
res.on('data', (chunk) => {
|
|
78
82
|
data += chunk;
|
|
79
83
|
});
|
|
80
84
|
|
|
81
85
|
res.on('end', () => {
|
|
82
86
|
try {
|
|
87
|
+
console.log('[MoonUI Pro] Raw response data:', data);
|
|
83
88
|
const result = JSON.parse(data);
|
|
84
|
-
|
|
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
|
|
85
93
|
resolve(result);
|
|
86
94
|
} else {
|
|
87
95
|
reject(new Error(result.error || 'License validation failed'));
|
|
88
96
|
}
|
|
89
97
|
} catch (error) {
|
|
98
|
+
console.error('[MoonUI Pro] Error parsing response:', error);
|
|
90
99
|
reject(error);
|
|
91
100
|
}
|
|
92
101
|
});
|
|
93
102
|
});
|
|
94
103
|
|
|
95
104
|
req.on('error', (error) => {
|
|
105
|
+
console.error('[MoonUI Pro] Request error:', error);
|
|
96
106
|
reject(error);
|
|
97
107
|
});
|
|
98
108
|
|
|
@@ -101,15 +111,58 @@ async function validateLicense(licenseKey) {
|
|
|
101
111
|
});
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
// Save license token to file
|
|
114
|
+
// Save license token to file or environment
|
|
105
115
|
function saveLicenseToken(token) {
|
|
106
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
|
|
107
154
|
// Find the project root (where package.json is)
|
|
108
155
|
let projectRoot = process.cwd();
|
|
156
|
+
console.log('[MoonUI Pro] Initial working directory:', projectRoot);
|
|
157
|
+
|
|
109
158
|
let attempts = 0;
|
|
110
159
|
|
|
111
160
|
while (attempts < 10) {
|
|
112
|
-
|
|
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);
|
|
113
166
|
break;
|
|
114
167
|
}
|
|
115
168
|
projectRoot = path.dirname(projectRoot);
|
|
@@ -117,24 +170,58 @@ function saveLicenseToken(token) {
|
|
|
117
170
|
}
|
|
118
171
|
|
|
119
172
|
const licenseFilePath = path.join(projectRoot, LICENSE_FILE);
|
|
173
|
+
console.log('[MoonUI Pro] License file path:', licenseFilePath);
|
|
120
174
|
|
|
121
175
|
// Encrypt token with a deterministic key based on environment
|
|
122
176
|
const encryptionKey = process.env.MOONUI_LICENSE_KEY || 'default-key';
|
|
177
|
+
console.log('[MoonUI Pro] Using encryption key:', encryptionKey.substring(0, 10) + '...');
|
|
178
|
+
|
|
123
179
|
const encryptedData = encryptToken(token, encryptionKey);
|
|
180
|
+
console.log('[MoonUI Pro] Token encrypted successfully');
|
|
124
181
|
|
|
125
182
|
// Save to file
|
|
183
|
+
console.log('[MoonUI Pro] Writing to file:', licenseFilePath);
|
|
126
184
|
fs.writeFileSync(licenseFilePath, JSON.stringify(encryptedData, null, 2));
|
|
127
185
|
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
}
|
|
130
196
|
} catch (error) {
|
|
131
197
|
console.error('[MoonUI Pro] Failed to save license token:', error.message);
|
|
132
|
-
|
|
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
|
+
}
|
|
133
211
|
}
|
|
134
212
|
}
|
|
135
213
|
|
|
136
214
|
// Main postinstall logic
|
|
137
215
|
async function main() {
|
|
216
|
+
console.log('[MoonUI Pro] === POSTINSTALL SCRIPT STARTED ===');
|
|
217
|
+
console.log('[MoonUI Pro] Environment:', {
|
|
218
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
219
|
+
VERCEL: process.env.VERCEL,
|
|
220
|
+
NETLIFY: process.env.NETLIFY,
|
|
221
|
+
CI: process.env.CI,
|
|
222
|
+
MOONUI_AUTH_TOKEN: !!process.env.MOONUI_AUTH_TOKEN
|
|
223
|
+
});
|
|
224
|
+
|
|
138
225
|
try {
|
|
139
226
|
// Only run in production environments
|
|
140
227
|
if (!isProduction()) {
|
|
@@ -164,23 +251,39 @@ async function main() {
|
|
|
164
251
|
// Validate license with API
|
|
165
252
|
const validationResult = await validateLicense(licenseKey);
|
|
166
253
|
|
|
167
|
-
|
|
254
|
+
// Debug: Log the full validation result
|
|
255
|
+
console.log('[MoonUI Pro] Validation result:', JSON.stringify(validationResult, null, 2));
|
|
256
|
+
|
|
257
|
+
if (validationResult && validationResult.valid && validationResult.hasProAccess) {
|
|
258
|
+
console.log('[MoonUI Pro] ✓ License is valid and has Pro access');
|
|
259
|
+
|
|
168
260
|
// Create token with validation result and expiry
|
|
169
261
|
const token = {
|
|
170
262
|
valid: true,
|
|
171
263
|
hasProAccess: validationResult.hasProAccess,
|
|
172
|
-
plan: validationResult.plan,
|
|
264
|
+
plan: validationResult.plan || 'pro',
|
|
173
265
|
expiresAt: Date.now() + CACHE_DURATION,
|
|
174
266
|
timestamp: Date.now()
|
|
175
267
|
};
|
|
176
268
|
|
|
269
|
+
console.log('[MoonUI Pro] Creating token:', JSON.stringify(token, null, 2));
|
|
270
|
+
|
|
177
271
|
// Save encrypted token
|
|
178
|
-
saveLicenseToken(token);
|
|
272
|
+
const saveResult = saveLicenseToken(token);
|
|
179
273
|
|
|
180
|
-
|
|
181
|
-
|
|
274
|
+
if (saveResult) {
|
|
275
|
+
console.log('[MoonUI Pro] ✓ License validated successfully');
|
|
276
|
+
console.log('[MoonUI Pro] ✓ Pro features enabled');
|
|
277
|
+
} else {
|
|
278
|
+
console.log('[MoonUI Pro] ⚠ License valid but failed to save token');
|
|
279
|
+
}
|
|
182
280
|
} else {
|
|
183
|
-
console.log('[MoonUI Pro] License validation failed');
|
|
281
|
+
console.log('[MoonUI Pro] License validation failed or no Pro access');
|
|
282
|
+
console.log('[MoonUI Pro] Validation result:', {
|
|
283
|
+
valid: validationResult?.valid || false,
|
|
284
|
+
hasProAccess: validationResult?.hasProAccess || false,
|
|
285
|
+
plan: validationResult?.plan || 'none'
|
|
286
|
+
});
|
|
184
287
|
console.log('[MoonUI Pro] Pro features will be disabled');
|
|
185
288
|
}
|
|
186
289
|
} catch (error) {
|
|
@@ -194,10 +297,16 @@ async function main() {
|
|
|
194
297
|
|
|
195
298
|
// Run if called directly (not imported)
|
|
196
299
|
if (require.main === module) {
|
|
300
|
+
console.log('[MoonUI Pro] PostInstall script invoked');
|
|
197
301
|
main().catch(error => {
|
|
198
302
|
console.error('[MoonUI Pro] Unexpected error:', error);
|
|
303
|
+
console.error('[MoonUI Pro] Stack trace:', error.stack);
|
|
199
304
|
process.exit(0); // Don't fail npm install
|
|
305
|
+
}).finally(() => {
|
|
306
|
+
console.log('[MoonUI Pro] === POSTINSTALL SCRIPT FINISHED ===');
|
|
200
307
|
});
|
|
308
|
+
} else {
|
|
309
|
+
console.log('[MoonUI Pro] PostInstall script loaded as module');
|
|
201
310
|
}
|
|
202
311
|
|
|
203
312
|
module.exports = { validateLicense, saveLicenseToken, isProduction };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MoonUI Pro License Validation Script
|
|
5
|
+
* Can be called from build scripts or directly
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const postinstall = require('./postinstall.cjs');
|
|
9
|
+
|
|
10
|
+
// Force production mode for validation
|
|
11
|
+
process.env.NODE_ENV = 'production';
|
|
12
|
+
|
|
13
|
+
console.log('[MoonUI Pro] Running license validation from build script...');
|
|
14
|
+
|
|
15
|
+
async function validate() {
|
|
16
|
+
try {
|
|
17
|
+
const licenseKey = process.env.MOONUI_LICENSE_KEY ||
|
|
18
|
+
process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY ||
|
|
19
|
+
process.env.VITE_MOONUI_LICENSE_KEY ||
|
|
20
|
+
process.env.REACT_APP_MOONUI_LICENSE_KEY;
|
|
21
|
+
|
|
22
|
+
if (!licenseKey) {
|
|
23
|
+
console.log('[MoonUI Pro] No license key found in environment variables');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.log('[MoonUI Pro] Found license key, validating...');
|
|
28
|
+
|
|
29
|
+
// Use the validation function from postinstall
|
|
30
|
+
const result = await postinstall.validateLicense(licenseKey);
|
|
31
|
+
|
|
32
|
+
if (result && result.valid && result.hasProAccess) {
|
|
33
|
+
console.log('[MoonUI Pro] License validated successfully via build script');
|
|
34
|
+
|
|
35
|
+
const token = {
|
|
36
|
+
valid: true,
|
|
37
|
+
hasProAccess: result.hasProAccess,
|
|
38
|
+
plan: result.plan || 'pro',
|
|
39
|
+
expiresAt: Date.now() + (30 * 24 * 60 * 60 * 1000),
|
|
40
|
+
timestamp: Date.now()
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
postinstall.saveLicenseToken(token);
|
|
44
|
+
} else {
|
|
45
|
+
console.log('[MoonUI Pro] License validation failed via build script');
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('[MoonUI Pro] Error during build validation:', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Run validation
|
|
53
|
+
validate();
|