@moontra/moonui-pro 2.20.4 → 2.21.0
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.d.ts +12 -11
- package/dist/index.mjs +1208 -663
- package/package.json +3 -2
- package/scripts/postinstall.js +0 -504
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
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",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"postinstall": "node scripts/postinstall.js",
|
|
38
37
|
"build": "tsup && node scripts/postbuild.js",
|
|
39
38
|
"build:dts": "tsup --dts",
|
|
40
39
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -96,10 +95,12 @@
|
|
|
96
95
|
"@radix-ui/react-toast": "^1.2.14",
|
|
97
96
|
"@radix-ui/react-tooltip": "^1.2.7",
|
|
98
97
|
"@tanstack/react-table": "^8.20.5",
|
|
98
|
+
"@types/crypto-js": "^4.2.2",
|
|
99
99
|
"canvas-confetti": "^1.9.3",
|
|
100
100
|
"class-variance-authority": "^0.7.0",
|
|
101
101
|
"clsx": "^2.1.1",
|
|
102
102
|
"cmdk": "^1.0.4",
|
|
103
|
+
"crypto-js": "^4.2.0",
|
|
103
104
|
"date-fns": "^3.6.0",
|
|
104
105
|
"framer-motion": "^11.11.17",
|
|
105
106
|
"fuse.js": "^7.0.0",
|
package/scripts/postinstall.js
DELETED
|
@@ -1,504 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import https from 'https';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import os from 'os';
|
|
7
|
-
import crypto from 'crypto';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = path.dirname(__filename);
|
|
12
|
-
|
|
13
|
-
// ANSI color codes for console output
|
|
14
|
-
const colors = {
|
|
15
|
-
reset: '\x1b[0m',
|
|
16
|
-
bright: '\x1b[1m',
|
|
17
|
-
red: '\x1b[31m',
|
|
18
|
-
green: '\x1b[32m',
|
|
19
|
-
yellow: '\x1b[33m',
|
|
20
|
-
blue: '\x1b[34m',
|
|
21
|
-
cyan: '\x1b[36m',
|
|
22
|
-
gray: '\x1b[90m'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const log = (message, color = '') => {
|
|
26
|
-
console.log(`${color}${message}${colors.reset}`);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const getDeviceFingerprint = () => {
|
|
30
|
-
// Create a unique device fingerprint using multiple system attributes
|
|
31
|
-
const hostname = os.hostname();
|
|
32
|
-
const username = os.userInfo().username;
|
|
33
|
-
const platform = os.platform();
|
|
34
|
-
const arch = os.arch();
|
|
35
|
-
const cpus = os.cpus();
|
|
36
|
-
const cpuModel = cpus[0]?.model || 'unknown';
|
|
37
|
-
const cpuCount = cpus.length;
|
|
38
|
-
const homeDir = os.homedir();
|
|
39
|
-
|
|
40
|
-
// Combine all attributes for a unique device ID
|
|
41
|
-
const deviceString = `${hostname}|${username}|${platform}|${arch}|${cpuModel}|${cpuCount}|${homeDir}`;
|
|
42
|
-
return crypto.createHash('sha256').update(deviceString).digest('hex');
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const getAuthConfig = () => {
|
|
46
|
-
try {
|
|
47
|
-
const authPath = path.join(os.homedir(), '.moonui', 'auth.encrypted');
|
|
48
|
-
|
|
49
|
-
if (!fs.existsSync(authPath)) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Read encrypted auth
|
|
54
|
-
const encryptedData = fs.readFileSync(authPath, 'utf-8');
|
|
55
|
-
const parts = encryptedData.split('.');
|
|
56
|
-
|
|
57
|
-
if (parts.length !== 3) {
|
|
58
|
-
// Encrypted format: iv.encrypted.signature
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const [ivHex, encrypted, signature] = parts;
|
|
63
|
-
const iv = Buffer.from(ivHex, 'hex');
|
|
64
|
-
|
|
65
|
-
// Get device-specific key using same fingerprint method
|
|
66
|
-
const deviceFingerprint = getDeviceFingerprint();
|
|
67
|
-
const key = crypto.createHash('sha256').update(deviceFingerprint).digest();
|
|
68
|
-
|
|
69
|
-
// Verify signature
|
|
70
|
-
const hmac = crypto.createHmac('sha256', key);
|
|
71
|
-
hmac.update(encrypted);
|
|
72
|
-
const computedSignature = hmac.digest('hex');
|
|
73
|
-
|
|
74
|
-
if (computedSignature !== signature) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Decrypt
|
|
79
|
-
const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
|
|
80
|
-
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
|
81
|
-
decrypted += decipher.final('utf8');
|
|
82
|
-
|
|
83
|
-
const cache = JSON.parse(decrypted);
|
|
84
|
-
|
|
85
|
-
// Verify device matches
|
|
86
|
-
if (cache.deviceId && cache.deviceId !== deviceFingerprint) {
|
|
87
|
-
log('❌ Device mismatch detected!', colors.red + colors.bright);
|
|
88
|
-
log(' This license is registered to a different device', colors.red);
|
|
89
|
-
log(' MoonUI Pro licenses are single-device only', colors.yellow);
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Extract token from cache
|
|
94
|
-
const auth = cache.token || cache;
|
|
95
|
-
|
|
96
|
-
// Check if expired
|
|
97
|
-
if (new Date(auth.expiresAt) < new Date()) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return auth;
|
|
102
|
-
} catch (error) {
|
|
103
|
-
// Silent fail - will show auth required message
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const validateAuth = async (token) => {
|
|
109
|
-
return new Promise((resolve) => {
|
|
110
|
-
const API_BASE = process.env.MOONUI_API_BASE || 'moonui.dev';
|
|
111
|
-
|
|
112
|
-
const options = {
|
|
113
|
-
hostname: API_BASE.replace('https://', '').replace('http://', ''),
|
|
114
|
-
port: 443,
|
|
115
|
-
path: '/api/auth/validate',
|
|
116
|
-
method: 'GET',
|
|
117
|
-
headers: {
|
|
118
|
-
'Authorization': `Bearer ${token}`,
|
|
119
|
-
'User-Agent': 'moonui-pro-postinstall/2.0.0'
|
|
120
|
-
},
|
|
121
|
-
timeout: 10000
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const req = https.request(options, (res) => {
|
|
125
|
-
let data = '';
|
|
126
|
-
|
|
127
|
-
res.on('data', (chunk) => {
|
|
128
|
-
data += chunk;
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
res.on('end', () => {
|
|
132
|
-
try {
|
|
133
|
-
if (res.statusCode === 200) {
|
|
134
|
-
const result = JSON.parse(data);
|
|
135
|
-
resolve({ valid: true, ...result });
|
|
136
|
-
} else {
|
|
137
|
-
resolve({ valid: false, error: 'INVALID_TOKEN', message: 'Authentication token is invalid' });
|
|
138
|
-
}
|
|
139
|
-
} catch (error) {
|
|
140
|
-
resolve({ valid: false, error: 'PARSE_ERROR', message: 'Invalid response from server' });
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
req.on('error', (error) => {
|
|
146
|
-
resolve({ valid: false, error: 'NETWORK_ERROR', message: 'Could not connect to auth server' });
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
req.on('timeout', () => {
|
|
150
|
-
resolve({ valid: false, error: 'TIMEOUT', message: 'Auth validation timeout' });
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
req.end();
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const checkEnvironmentAuth = () => {
|
|
158
|
-
// Check for different types of auth tokens in environment variables
|
|
159
|
-
const teamToken = process.env.MOONUI_TEAM_TOKEN;
|
|
160
|
-
const ciToken = process.env.MOONUI_CI_TOKEN;
|
|
161
|
-
const envToken = process.env.MOONUI_AUTH_TOKEN || process.env.MOONUI_ACCESS_TOKEN;
|
|
162
|
-
const licenseKey = process.env.MOONUI_LICENSE_KEY;
|
|
163
|
-
|
|
164
|
-
if (teamToken) {
|
|
165
|
-
log('👥 Found team token in environment variables', colors.blue);
|
|
166
|
-
return { token: teamToken, type: 'team' };
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (ciToken) {
|
|
170
|
-
log('🤖 Found CI token in environment variables', colors.blue);
|
|
171
|
-
return { token: ciToken, type: 'ci' };
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (licenseKey) {
|
|
175
|
-
log('🔐 Found license key in environment variables', colors.blue);
|
|
176
|
-
return { token: licenseKey, type: 'license' };
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (envToken) {
|
|
180
|
-
log('🔑 Found auth token in environment variables', colors.blue);
|
|
181
|
-
return { token: envToken, type: 'personal' };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return null;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// Check for perpetual license stamp
|
|
188
|
-
const checkLicenseStamp = () => {
|
|
189
|
-
try {
|
|
190
|
-
const stampPath = path.join(process.cwd(), '.moonui-license-stamp');
|
|
191
|
-
if (fs.existsSync(stampPath)) {
|
|
192
|
-
const stamp = JSON.parse(fs.readFileSync(stampPath, 'utf8'));
|
|
193
|
-
|
|
194
|
-
if (stamp.projectId && stamp.licensedAt && stamp.version) {
|
|
195
|
-
log('📋 Using perpetual license stamp', colors.green);
|
|
196
|
-
log(` Licensed on: ${new Date(stamp.licensedAt).toLocaleDateString()}`, colors.blue);
|
|
197
|
-
log(` Version: ${stamp.version}`, colors.blue);
|
|
198
|
-
log(` Mode: Perpetual (no active license required)`, colors.green);
|
|
199
|
-
log('', '');
|
|
200
|
-
log('ℹ️ Your project has perpetual usage rights', colors.cyan);
|
|
201
|
-
log(' Updates require active license', colors.gray);
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
// Invalid stamp
|
|
207
|
-
}
|
|
208
|
-
return false;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
// Create license stamp for perpetual usage
|
|
212
|
-
const createLicenseStamp = (authInfo) => {
|
|
213
|
-
try {
|
|
214
|
-
const stamp = {
|
|
215
|
-
projectId: crypto.randomBytes(16).toString('hex'),
|
|
216
|
-
licensedAt: new Date().toISOString(),
|
|
217
|
-
version: process.env.npm_package_version || '2.x',
|
|
218
|
-
licensedTo: authInfo.user?.email || 'unknown',
|
|
219
|
-
plan: authInfo.user?.plan || 'unknown',
|
|
220
|
-
mode: 'perpetual',
|
|
221
|
-
installedComponents: []
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const stampPath = path.join(process.cwd(), '.moonui-license-stamp');
|
|
225
|
-
fs.writeFileSync(stampPath, JSON.stringify(stamp, null, 2), 'utf8');
|
|
226
|
-
|
|
227
|
-
log('', '');
|
|
228
|
-
log('📋 License stamp created!', colors.green + colors.bright);
|
|
229
|
-
log(' Your project now has perpetual usage rights', colors.green);
|
|
230
|
-
log(' You can build without active license', colors.blue);
|
|
231
|
-
log(' Commit .moonui-license-stamp to your repository', colors.yellow);
|
|
232
|
-
|
|
233
|
-
return true;
|
|
234
|
-
} catch (error) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const main = async () => {
|
|
240
|
-
log('', ''); // Empty line
|
|
241
|
-
log('🌙 MoonUI Pro Installation', colors.cyan + colors.bright);
|
|
242
|
-
log('═'.repeat(50), colors.gray);
|
|
243
|
-
|
|
244
|
-
// Check for Vercel environment with proper token
|
|
245
|
-
if (process.env.VERCEL) {
|
|
246
|
-
log('📦 Vercel Environment Detected', colors.blue);
|
|
247
|
-
|
|
248
|
-
// Check for admin token in Vercel environment
|
|
249
|
-
const vercelToken = process.env.MOONUI_AUTH_TOKEN;
|
|
250
|
-
if (vercelToken && vercelToken.startsWith('mpt_admin_')) {
|
|
251
|
-
log('✅ Admin token detected - skipping license check', colors.green);
|
|
252
|
-
log(' Vercel build can proceed without validation', colors.blue);
|
|
253
|
-
log('═'.repeat(50), colors.gray);
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
// Continue with normal auth flow - token will be checked below
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Check for perpetual license stamp first
|
|
260
|
-
if (checkLicenseStamp()) {
|
|
261
|
-
log('✅ Installation complete with perpetual license', colors.green);
|
|
262
|
-
log('═'.repeat(50), colors.gray);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Check for development bypass
|
|
267
|
-
if (process.env.MOONUI_DEV_MODE === 'true' || process.env.MOONUI_SKIP_AUTH === 'true') {
|
|
268
|
-
log('🔧 Development Mode Enabled', colors.yellow + colors.bright);
|
|
269
|
-
log(' Authentication bypassed for local development', colors.yellow);
|
|
270
|
-
log(' This mode should only be used during development', colors.gray);
|
|
271
|
-
log('', '');
|
|
272
|
-
log('✅ MoonUI Pro ready for development!', colors.green);
|
|
273
|
-
log('═'.repeat(50), colors.gray);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Check if running on localhost (development)
|
|
278
|
-
const isLocalDev = process.env.NODE_ENV === 'development' ||
|
|
279
|
-
process.cwd().includes('moonui') ||
|
|
280
|
-
fs.existsSync(path.join(process.cwd(), '.moonui-dev'));
|
|
281
|
-
|
|
282
|
-
if (isLocalDev && !process.env.MOONUI_FORCE_AUTH) {
|
|
283
|
-
log('🚀 Local Development Detected', colors.blue + colors.bright);
|
|
284
|
-
log(' Running in development mode without auth', colors.blue);
|
|
285
|
-
log(' To enable auth checks: MOONUI_FORCE_AUTH=true npm install', colors.gray);
|
|
286
|
-
log('', '');
|
|
287
|
-
log('✅ MoonUI Pro ready for development!', colors.green);
|
|
288
|
-
log('═'.repeat(50), colors.gray);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Check for environment-based authentication first
|
|
293
|
-
const envAuth = checkEnvironmentAuth();
|
|
294
|
-
|
|
295
|
-
if (envAuth) {
|
|
296
|
-
// Handle different token types
|
|
297
|
-
if (envAuth.type === 'team') {
|
|
298
|
-
log('🏢 Team License Mode', colors.blue + colors.bright);
|
|
299
|
-
log(' Multiple developers can use this token', colors.blue);
|
|
300
|
-
log(' No device restrictions applied', colors.gray);
|
|
301
|
-
|
|
302
|
-
// Validate team token
|
|
303
|
-
log('🔍 Validating team license...', colors.blue);
|
|
304
|
-
const validation = await validateAuth(envAuth.token);
|
|
305
|
-
|
|
306
|
-
if (validation.valid) {
|
|
307
|
-
log('✅ Team authentication successful!', colors.green);
|
|
308
|
-
log(` Team: ${validation.team?.name || 'N/A'}`, colors.blue);
|
|
309
|
-
log(` Seats: ${validation.team?.seats || 'N/A'}`, colors.blue);
|
|
310
|
-
|
|
311
|
-
// Create perpetual license stamp for team
|
|
312
|
-
createLicenseStamp({ user: { email: 'team', plan: 'team' }, ...validation });
|
|
313
|
-
return;
|
|
314
|
-
} else {
|
|
315
|
-
log('❌ Team authentication failed!', colors.red);
|
|
316
|
-
log(` Error: ${validation.message}`, colors.red);
|
|
317
|
-
process.exit(1);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (envAuth.type === 'ci' || process.env.CI) {
|
|
322
|
-
log('🤖 CI/CD Mode', colors.blue + colors.bright);
|
|
323
|
-
log(' Running in continuous integration environment', colors.blue);
|
|
324
|
-
|
|
325
|
-
// Validate CI token
|
|
326
|
-
log('🔍 Validating CI token...', colors.blue);
|
|
327
|
-
const validation = await validateAuth(envAuth.token);
|
|
328
|
-
|
|
329
|
-
if (validation.valid) {
|
|
330
|
-
log('✅ CI authentication successful!', colors.green);
|
|
331
|
-
log(` Environment: ${process.env.CI_NAME || 'CI'}`, colors.blue);
|
|
332
|
-
return;
|
|
333
|
-
} else {
|
|
334
|
-
log('❌ CI authentication failed!', colors.red);
|
|
335
|
-
log(` Error: ${validation.message}`, colors.red);
|
|
336
|
-
process.exit(1);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (envAuth.type === 'license') {
|
|
341
|
-
log('🔐 License Key Mode', colors.blue + colors.bright);
|
|
342
|
-
log(' Project-based licensing', colors.blue);
|
|
343
|
-
|
|
344
|
-
// Validate license key
|
|
345
|
-
log('🔍 Validating license key...', colors.blue);
|
|
346
|
-
const validation = await validateAuth(envAuth.token);
|
|
347
|
-
|
|
348
|
-
if (validation.valid) {
|
|
349
|
-
log('✅ License validation successful!', colors.green);
|
|
350
|
-
log(` Project: ${validation.project?.name || 'N/A'}`, colors.blue);
|
|
351
|
-
log(` Valid until: ${validation.expiresAt || 'Lifetime'}`, colors.blue);
|
|
352
|
-
return;
|
|
353
|
-
} else {
|
|
354
|
-
log('❌ License validation failed!', colors.red);
|
|
355
|
-
log(` Error: ${validation.message}`, colors.red);
|
|
356
|
-
process.exit(1);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Personal token with existing flow
|
|
361
|
-
if (envAuth.type === 'personal') {
|
|
362
|
-
log('👤 Personal License Mode', colors.blue + colors.bright);
|
|
363
|
-
log(' Single developer license', colors.blue);
|
|
364
|
-
|
|
365
|
-
const validation = await validateAuth(envAuth.token);
|
|
366
|
-
|
|
367
|
-
if (validation.valid) {
|
|
368
|
-
log('✅ Personal authentication successful!', colors.green);
|
|
369
|
-
log(` User: ${validation.user?.email || 'N/A'}`, colors.blue);
|
|
370
|
-
return;
|
|
371
|
-
} else {
|
|
372
|
-
log('❌ Personal authentication failed!', colors.red);
|
|
373
|
-
log(` Error: ${validation.message}`, colors.red);
|
|
374
|
-
process.exit(1);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// Check if this is a CI environment without token
|
|
380
|
-
const isCI = process.env.CI || process.env.CONTINUOUS_INTEGRATION || process.env.GITHUB_ACTIONS;
|
|
381
|
-
|
|
382
|
-
if (isCI && !envAuth) {
|
|
383
|
-
log('⚠️ CI Environment detected but no auth token found', colors.yellow);
|
|
384
|
-
log('', '');
|
|
385
|
-
log('📋 Please set one of the following environment variables:', colors.blue);
|
|
386
|
-
log(' MOONUI_CI_TOKEN - For CI/CD pipelines', colors.blue);
|
|
387
|
-
log(' MOONUI_TEAM_TOKEN - For team licenses', colors.blue);
|
|
388
|
-
log(' MOONUI_LICENSE_KEY - For project licenses', colors.blue);
|
|
389
|
-
log('', '');
|
|
390
|
-
log('📖 Documentation: https://moonui.dev/docs/ci-setup', colors.gray);
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Regular installation - check for existing auth
|
|
395
|
-
const authConfig = getAuthConfig();
|
|
396
|
-
|
|
397
|
-
if (!authConfig || !authConfig.accessToken) {
|
|
398
|
-
log('🔐 MoonUI Pro Authentication Required', colors.yellow + colors.bright);
|
|
399
|
-
log('', '');
|
|
400
|
-
log('This package requires authentication with a MoonUI Pro account.', colors.yellow);
|
|
401
|
-
log('', '');
|
|
402
|
-
log('📋 Next Steps:', colors.blue + colors.bright);
|
|
403
|
-
log(' 1. Install MoonUI CLI: npm install -g @moontra/moonui-cli', colors.blue);
|
|
404
|
-
log(' 2. Login to your account: moonui login', colors.blue);
|
|
405
|
-
log(' 3. Or set environment variable: MOONUI_AUTH_TOKEN=<your-token>', colors.blue);
|
|
406
|
-
log('', '');
|
|
407
|
-
log('📖 Documentation: https://moonui.dev/docs/authentication', colors.gray);
|
|
408
|
-
log('🔧 Get your account: https://moonui.dev/pricing', colors.gray);
|
|
409
|
-
log('', '');
|
|
410
|
-
process.exit(1);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// Check if Pro access
|
|
414
|
-
const hasPro = authConfig.user?.plan === 'pro_monthly' ||
|
|
415
|
-
authConfig.user?.plan === 'pro_annual' ||
|
|
416
|
-
authConfig.user?.plan === 'pro_lifetime' ||
|
|
417
|
-
authConfig.user?.features?.includes('pro_components');
|
|
418
|
-
|
|
419
|
-
if (!hasPro) {
|
|
420
|
-
log('❌ MoonUI Pro Access Required', colors.red + colors.bright);
|
|
421
|
-
log('', '');
|
|
422
|
-
log('Your account does not have access to Pro components.', colors.red);
|
|
423
|
-
log(`Current plan: ${authConfig.user?.plan || 'free'}`, colors.yellow);
|
|
424
|
-
log('', '');
|
|
425
|
-
log('📋 Upgrade your account:', colors.blue + colors.bright);
|
|
426
|
-
log(' Visit: https://moonui.dev/pricing', colors.blue);
|
|
427
|
-
log('', '');
|
|
428
|
-
process.exit(1);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// Validate existing auth
|
|
432
|
-
log('🔍 Validating authentication...', colors.blue);
|
|
433
|
-
|
|
434
|
-
const validation = await validateAuth(authConfig.accessToken);
|
|
435
|
-
|
|
436
|
-
if (validation.valid) {
|
|
437
|
-
log('✅ Authentication successful!', colors.green + colors.bright);
|
|
438
|
-
log(` Plan: ${validation.user?.plan || authConfig.user?.plan}`, colors.blue);
|
|
439
|
-
log(` Account: ${authConfig.user?.email || 'N/A'}`, colors.blue);
|
|
440
|
-
|
|
441
|
-
// Create perpetual license stamp
|
|
442
|
-
createLicenseStamp(authConfig);
|
|
443
|
-
|
|
444
|
-
if (validation.expiresAt) {
|
|
445
|
-
const expiryDate = new Date(validation.expiresAt);
|
|
446
|
-
const daysLeft = Math.ceil((expiryDate - new Date()) / (1000 * 60 * 60 * 24));
|
|
447
|
-
|
|
448
|
-
if (daysLeft > 0) {
|
|
449
|
-
log(` Expires: ${expiryDate.toLocaleDateString()} (${daysLeft} days)`, colors.blue);
|
|
450
|
-
} else {
|
|
451
|
-
log(` Status: EXPIRED on ${expiryDate.toLocaleDateString()}`, colors.red);
|
|
452
|
-
}
|
|
453
|
-
} else {
|
|
454
|
-
log(' Expires: Never (Lifetime)', colors.green);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (validation.downloadLimit) {
|
|
458
|
-
const { current, max, period } = validation.downloadLimit;
|
|
459
|
-
const percentage = Math.round((current / max) * 100);
|
|
460
|
-
const warningColor = percentage > 80 ? colors.yellow : colors.blue;
|
|
461
|
-
log(` Usage: ${current}/${max} downloads this ${period} (${percentage}%)`, warningColor);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
log('', '');
|
|
465
|
-
log('🚀 Ready to use MoonUI Pro components!', colors.green);
|
|
466
|
-
log(' Documentation: https://moonui.dev/docs/components', colors.gray);
|
|
467
|
-
|
|
468
|
-
} else {
|
|
469
|
-
log('❌ Authentication failed!', colors.red + colors.bright);
|
|
470
|
-
log(` Error: ${validation.message}`, colors.red);
|
|
471
|
-
log('', '');
|
|
472
|
-
|
|
473
|
-
if (validation.error === 'INVALID_TOKEN') {
|
|
474
|
-
log('🔧 Troubleshooting:', colors.yellow + colors.bright);
|
|
475
|
-
log(' • Your session may have expired', colors.yellow);
|
|
476
|
-
log(' • Run: moonui login', colors.yellow);
|
|
477
|
-
log(' • Contact support: support@moonui.dev', colors.yellow);
|
|
478
|
-
} else if (validation.error === 'NETWORK_ERROR') {
|
|
479
|
-
log('🌐 Network Issue:', colors.yellow + colors.bright);
|
|
480
|
-
log(' • Auth validation requires internet connection', colors.yellow);
|
|
481
|
-
log(' • Components will work offline after initial validation', colors.yellow);
|
|
482
|
-
log(' • Retry: npm install --force', colors.yellow);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
log('', '');
|
|
486
|
-
log('📖 Auth Guide: https://moonui.dev/docs/authentication', colors.gray);
|
|
487
|
-
|
|
488
|
-
// Don't fail installation for network issues, only for invalid auth
|
|
489
|
-
if (validation.error === 'INVALID_TOKEN') {
|
|
490
|
-
process.exit(1);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
log('═'.repeat(50), colors.gray);
|
|
495
|
-
log('', '');
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
// Run postinstall script
|
|
499
|
-
main().catch((error) => {
|
|
500
|
-
log('❌ Postinstall script failed:', colors.red);
|
|
501
|
-
log(` ${error.message}`, colors.red);
|
|
502
|
-
log('', '');
|
|
503
|
-
log('📖 If this persists, see: https://moonui.dev/docs/troubleshooting', colors.gray);
|
|
504
|
-
});
|