strapi-plugin-magic-mail 2.2.4 → 2.2.6

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.
Files changed (71) hide show
  1. package/README.md +0 -2
  2. package/dist/server/index.js +1 -1
  3. package/dist/server/index.mjs +1 -1
  4. package/package.json +1 -3
  5. package/admin/jsconfig.json +0 -10
  6. package/admin/src/components/AddAccountModal.jsx +0 -1943
  7. package/admin/src/components/Initializer.jsx +0 -14
  8. package/admin/src/components/LicenseGuard.jsx +0 -475
  9. package/admin/src/components/PluginIcon.jsx +0 -5
  10. package/admin/src/hooks/useAuthRefresh.js +0 -44
  11. package/admin/src/hooks/useLicense.js +0 -158
  12. package/admin/src/index.js +0 -87
  13. package/admin/src/pages/Analytics.jsx +0 -762
  14. package/admin/src/pages/App.jsx +0 -111
  15. package/admin/src/pages/EmailDesigner/EditorPage.jsx +0 -1424
  16. package/admin/src/pages/EmailDesigner/TemplateList.jsx +0 -1807
  17. package/admin/src/pages/HomePage.jsx +0 -1170
  18. package/admin/src/pages/LicensePage.jsx +0 -430
  19. package/admin/src/pages/RoutingRules.jsx +0 -1141
  20. package/admin/src/pages/Settings.jsx +0 -603
  21. package/admin/src/pluginId.js +0 -3
  22. package/admin/src/translations/de.json +0 -71
  23. package/admin/src/translations/en.json +0 -70
  24. package/admin/src/translations/es.json +0 -71
  25. package/admin/src/translations/fr.json +0 -71
  26. package/admin/src/translations/pt.json +0 -71
  27. package/admin/src/utils/fetchWithRetry.js +0 -123
  28. package/admin/src/utils/getTranslation.js +0 -5
  29. package/admin/src/utils/theme.js +0 -85
  30. package/server/jsconfig.json +0 -10
  31. package/server/src/bootstrap.js +0 -157
  32. package/server/src/config/features.js +0 -260
  33. package/server/src/config/index.js +0 -9
  34. package/server/src/content-types/email-account/schema.json +0 -93
  35. package/server/src/content-types/email-event/index.js +0 -8
  36. package/server/src/content-types/email-event/schema.json +0 -57
  37. package/server/src/content-types/email-link/index.js +0 -8
  38. package/server/src/content-types/email-link/schema.json +0 -49
  39. package/server/src/content-types/email-log/index.js +0 -8
  40. package/server/src/content-types/email-log/schema.json +0 -106
  41. package/server/src/content-types/email-template/schema.json +0 -74
  42. package/server/src/content-types/email-template-version/schema.json +0 -60
  43. package/server/src/content-types/index.js +0 -33
  44. package/server/src/content-types/routing-rule/schema.json +0 -59
  45. package/server/src/controllers/accounts.js +0 -229
  46. package/server/src/controllers/analytics.js +0 -361
  47. package/server/src/controllers/controller.js +0 -26
  48. package/server/src/controllers/email-designer.js +0 -474
  49. package/server/src/controllers/index.js +0 -21
  50. package/server/src/controllers/license.js +0 -269
  51. package/server/src/controllers/oauth.js +0 -474
  52. package/server/src/controllers/routing-rules.js +0 -129
  53. package/server/src/controllers/test.js +0 -301
  54. package/server/src/destroy.js +0 -27
  55. package/server/src/index.js +0 -25
  56. package/server/src/middlewares/index.js +0 -3
  57. package/server/src/policies/index.js +0 -3
  58. package/server/src/register.js +0 -5
  59. package/server/src/routes/admin.js +0 -469
  60. package/server/src/routes/content-api.js +0 -37
  61. package/server/src/routes/index.js +0 -9
  62. package/server/src/services/account-manager.js +0 -329
  63. package/server/src/services/analytics.js +0 -512
  64. package/server/src/services/email-designer.js +0 -717
  65. package/server/src/services/email-router.js +0 -1446
  66. package/server/src/services/index.js +0 -17
  67. package/server/src/services/license-guard.js +0 -423
  68. package/server/src/services/oauth.js +0 -515
  69. package/server/src/services/service.js +0 -7
  70. package/server/src/utils/encryption.js +0 -81
  71. package/server/src/utils/logger.js +0 -84
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- const emailRouter = require('./email-router');
4
- const accountManager = require('./account-manager');
5
- const oauth = require('./oauth');
6
- const licenseGuard = require('./license-guard');
7
- const emailDesigner = require('./email-designer');
8
- const analytics = require('./analytics');
9
-
10
- module.exports = {
11
- 'email-router': emailRouter,
12
- 'account-manager': accountManager,
13
- oauth,
14
- 'license-guard': licenseGuard,
15
- 'email-designer': emailDesigner,
16
- analytics,
17
- };
@@ -1,423 +0,0 @@
1
- /**
2
- * License Guard Service for MagicMail
3
- * Handles license creation, verification, and ping tracking
4
- */
5
-
6
- const crypto = require('crypto');
7
- const os = require('os');
8
- const pluginPkg = require('../../../package.json');
9
- const { createLogger } = require('../utils/logger');
10
-
11
- // FIXED LICENSE SERVER URL
12
- const LICENSE_SERVER_URL = 'https://magicapi.fitlex.me';
13
-
14
- module.exports = ({ strapi }) => {
15
- const log = createLogger(strapi);
16
-
17
- return {
18
- /**
19
- * Get license server URL
20
- */
21
- getLicenseServerUrl() {
22
- return LICENSE_SERVER_URL;
23
- },
24
-
25
- /**
26
- * Generate device ID
27
- */
28
- generateDeviceId() {
29
- try {
30
- const networkInterfaces = os.networkInterfaces();
31
- const macAddresses = [];
32
-
33
- Object.values(networkInterfaces).forEach(interfaces => {
34
- interfaces?.forEach(iface => {
35
- if (iface.mac && iface.mac !== '00:00:00:00:00:00') {
36
- macAddresses.push(iface.mac);
37
- }
38
- });
39
- });
40
-
41
- const identifier = `${macAddresses.join('-')}-${os.hostname()}`;
42
- return crypto.createHash('sha256').update(identifier).digest('hex').substring(0, 32);
43
- } catch (error) {
44
- return crypto.randomBytes(16).toString('hex');
45
- }
46
- },
47
-
48
- getDeviceName() {
49
- try {
50
- return os.hostname() || 'Unknown Device';
51
- } catch (error) {
52
- return 'Unknown Device';
53
- }
54
- },
55
-
56
- getIpAddress() {
57
- try {
58
- const networkInterfaces = os.networkInterfaces();
59
- for (const name of Object.keys(networkInterfaces)) {
60
- const interfaces = networkInterfaces[name];
61
- if (interfaces) {
62
- for (const iface of interfaces) {
63
- if (iface.family === 'IPv4' && !iface.internal) {
64
- return iface.address;
65
- }
66
- }
67
- }
68
- }
69
- return '127.0.0.1';
70
- } catch (error) {
71
- return '127.0.0.1';
72
- }
73
- },
74
-
75
- getUserAgent() {
76
- const pluginVersion = pluginPkg.version || '1.0.0';
77
- const strapiVersion = strapi.config.get('info.strapi') || '5.0.0';
78
- return `MagicMail/${pluginVersion} Strapi/${strapiVersion} Node/${process.version} ${os.platform()}/${os.release()}`;
79
- },
80
-
81
- async createLicense({ email, firstName, lastName }) {
82
- try {
83
- const deviceId = this.generateDeviceId();
84
- const deviceName = this.getDeviceName();
85
- const ipAddress = this.getIpAddress();
86
- const userAgent = this.getUserAgent();
87
-
88
- const licenseServerUrl = this.getLicenseServerUrl();
89
- const response = await fetch(`${licenseServerUrl}/api/licenses/create`, {
90
- method: 'POST',
91
- headers: { 'Content-Type': 'application/json' },
92
- body: JSON.stringify({
93
- email,
94
- firstName,
95
- lastName,
96
- deviceName,
97
- deviceId,
98
- ipAddress,
99
- userAgent,
100
- pluginName: 'magic-mail',
101
- productName: 'MagicMail - Email Business Suite',
102
- }),
103
- });
104
-
105
- const data = await response.json();
106
-
107
- if (data.success) {
108
- log.info('[SUCCESS] License created:', data.data.licenseKey);
109
- return data.data;
110
- } else {
111
- log.error('[ERROR] License creation failed:', data);
112
- return null;
113
- }
114
- } catch (error) {
115
- log.error('[ERROR] Error creating license:', error);
116
- return null;
117
- }
118
- },
119
-
120
- async verifyLicense(licenseKey, allowGracePeriod = false) {
121
- try {
122
- const controller = new AbortController();
123
- const timeoutId = setTimeout(() => controller.abort(), 5000);
124
-
125
- const licenseServerUrl = this.getLicenseServerUrl();
126
- const response = await fetch(`${licenseServerUrl}/api/licenses/verify`, {
127
- method: 'POST',
128
- headers: { 'Content-Type': 'application/json' },
129
- body: JSON.stringify({
130
- licenseKey,
131
- pluginName: 'magic-mail',
132
- productName: 'MagicMail - Email Business Suite',
133
- }),
134
- signal: controller.signal,
135
- });
136
-
137
- clearTimeout(timeoutId);
138
- const data = await response.json();
139
-
140
- if (data.success && data.data) {
141
- return { valid: true, data: data.data, gracePeriod: false };
142
- } else {
143
- return { valid: false, data: null };
144
- }
145
- } catch (error) {
146
- if (allowGracePeriod) {
147
- log.warn('[WARNING] License verification timeout - grace period active');
148
- return { valid: true, data: null, gracePeriod: true };
149
- }
150
- log.error('[ERROR] License verification error:', error.message);
151
- return { valid: false, data: null };
152
- }
153
- },
154
-
155
- async getLicenseByKey(licenseKey) {
156
- try {
157
- const licenseServerUrl = this.getLicenseServerUrl();
158
- const url = `${licenseServerUrl}/api/licenses/key/${licenseKey}`;
159
-
160
- const response = await fetch(url, {
161
- method: 'GET',
162
- headers: { 'Content-Type': 'application/json' },
163
- });
164
-
165
- const data = await response.json();
166
-
167
- if (data.success && data.data) {
168
- return data.data;
169
- }
170
-
171
- return null;
172
- } catch (error) {
173
- log.error('Error fetching license by key:', error);
174
- return null;
175
- }
176
- },
177
-
178
- async pingLicense(licenseKey) {
179
- try {
180
- const deviceId = this.generateDeviceId();
181
- const deviceName = this.getDeviceName();
182
- const ipAddress = this.getIpAddress();
183
- const userAgent = this.getUserAgent();
184
-
185
- const licenseServerUrl = this.getLicenseServerUrl();
186
- const response = await fetch(`${licenseServerUrl}/api/licenses/ping`, {
187
- method: 'POST',
188
- headers: { 'Content-Type': 'application/json' },
189
- body: JSON.stringify({
190
- licenseKey,
191
- deviceId,
192
- deviceName,
193
- ipAddress,
194
- userAgent,
195
- pluginName: 'magic-mail',
196
- }),
197
- });
198
-
199
- const data = await response.json();
200
- return data.success ? data.data : null;
201
- } catch (error) {
202
- // Silent fail for pings
203
- return null;
204
- }
205
- },
206
-
207
- async storeLicenseKey(licenseKey) {
208
- const pluginStore = strapi.store({
209
- type: 'plugin',
210
- name: 'magic-mail'
211
- });
212
- await pluginStore.set({ key: 'licenseKey', value: licenseKey });
213
- log.info(`[SUCCESS] License key stored: ${licenseKey.substring(0, 8)}...`);
214
- },
215
-
216
- startPinging(licenseKey, intervalMinutes = 15) {
217
- // Immediate ping
218
- this.pingLicense(licenseKey);
219
-
220
- const interval = setInterval(async () => {
221
- try {
222
- await this.pingLicense(licenseKey);
223
- } catch (error) {
224
- console.error('Ping error:', error);
225
- }
226
- }, intervalMinutes * 60 * 1000);
227
-
228
- return interval;
229
- },
230
-
231
- /**
232
- * Get current license data from store
233
- */
234
- async getCurrentLicense() {
235
- try {
236
- const pluginStore = strapi.store({
237
- type: 'plugin',
238
- name: 'magic-mail'
239
- });
240
- const licenseKey = await pluginStore.get({ key: 'licenseKey' });
241
-
242
- if (!licenseKey) {
243
- return null;
244
- }
245
-
246
- const license = await this.getLicenseByKey(licenseKey);
247
- return license;
248
- } catch (error) {
249
- log.error(`[ERROR] Error loading license:`, error);
250
- return null;
251
- }
252
- },
253
-
254
- /**
255
- * Check if license has specific feature
256
- */
257
- async hasFeature(featureName) {
258
- const license = await this.getCurrentLicense();
259
- const features = require('../config/features');
260
- return features.hasFeature(license, featureName);
261
- },
262
-
263
- /**
264
- * Check if provider is allowed
265
- */
266
- async isProviderAllowed(provider) {
267
- const license = await this.getCurrentLicense();
268
- const features = require('../config/features');
269
- return features.isProviderAllowed(license, provider);
270
- },
271
-
272
- /**
273
- * Get max allowed accounts
274
- */
275
- async getMaxAccounts() {
276
- const license = await this.getCurrentLicense();
277
- const features = require('../config/features');
278
- return features.getMaxAccounts(license);
279
- },
280
-
281
- /**
282
- * Get max allowed routing rules
283
- */
284
- async getMaxRoutingRules() {
285
- const license = await this.getCurrentLicense();
286
- const features = require('../config/features');
287
- return features.getMaxRoutingRules(license);
288
- },
289
-
290
- /**
291
- * Get max allowed email templates
292
- */
293
- async getMaxEmailTemplates() {
294
- const license = await this.getCurrentLicense();
295
- const features = require('../config/features');
296
- return features.getMaxEmailTemplates(license);
297
- },
298
-
299
- /**
300
- * Initialize license guard
301
- * Checks for existing license and starts pinging
302
- */
303
- async initialize() {
304
- try {
305
- log.info('[INIT] Initializing License Guard...');
306
-
307
- // Check if license key exists in plugin store
308
- const pluginStore = strapi.store({
309
- type: 'plugin',
310
- name: 'magic-mail'
311
- });
312
- const licenseKey = await pluginStore.get({ key: 'licenseKey' });
313
-
314
- // Check last validation timestamp
315
- const lastValidated = await pluginStore.get({ key: 'lastValidated' });
316
- const now = new Date();
317
- const gracePeriodHours = 24;
318
- let withinGracePeriod = false;
319
-
320
- if (lastValidated) {
321
- const lastValidatedDate = new Date(lastValidated);
322
- const hoursSinceValidation = (now.getTime() - lastValidatedDate.getTime()) / (1000 * 60 * 60);
323
- withinGracePeriod = hoursSinceValidation < gracePeriodHours;
324
- }
325
-
326
- log.info('──────────────────────────────────────────────────────────');
327
- log.info(`📦 Plugin Store Check:`);
328
- if (licenseKey) {
329
- log.info(` [SUCCESS] License Key found: ${licenseKey}`);
330
- log.info(` [LICENSE] Key (short): ${licenseKey.substring(0, 10)}...`);
331
- if (lastValidated) {
332
- const lastValidatedDate = new Date(lastValidated);
333
- const hoursAgo = Math.floor((now.getTime() - lastValidatedDate.getTime()) / (1000 * 60 * 60));
334
- log.info(` [TIME] Last validated: ${hoursAgo}h ago (Grace: ${withinGracePeriod ? 'ACTIVE' : 'EXPIRED'})`);
335
- } else {
336
- log.info(` [TIME] Last validated: Never (Grace: ACTIVE for first ${gracePeriodHours}h)`);
337
- }
338
- } else {
339
- log.info(` [ERROR] No license key stored`);
340
- }
341
- log.info('──────────────────────────────────────────────────────────');
342
-
343
- if (!licenseKey) {
344
- log.info('[DEMO] No license found - Running in demo mode');
345
- log.info('[INFO] Create a license in the admin panel to activate full features');
346
- return {
347
- valid: false,
348
- demo: true,
349
- data: null,
350
- };
351
- }
352
-
353
- log.info('[VERIFY] Verifying stored license key...');
354
-
355
- // Verify license (allow grace period if we have a last validation)
356
- const verification = await this.verifyLicense(licenseKey, withinGracePeriod);
357
-
358
- if (verification.valid) {
359
- // Get license details for display
360
- const license = await this.getLicenseByKey(licenseKey);
361
-
362
- log.info(`[SUCCESS] License verified online: ACTIVE (Key: ${licenseKey.substring(0, 10)}...)`);
363
-
364
- // Update last validated timestamp
365
- await pluginStore.set({
366
- key: 'lastValidated',
367
- value: now.toISOString()
368
- });
369
-
370
- log.info('[SUCCESS] License is valid and active');
371
-
372
- // Start automatic pinging
373
- const pingInterval = this.startPinging(licenseKey, 15);
374
- log.info('[PING] Started pinging license every 15 minutes');
375
-
376
- // Store interval globally so we can clean it up
377
- strapi.licenseGuardMagicMail = {
378
- licenseKey,
379
- pingInterval,
380
- data: verification.data,
381
- };
382
-
383
- // Display license info box
384
- log.info('╔════════════════════════════════════════════════════════════════╗');
385
- log.info('║ [SUCCESS] MAGIC MAIL PLUGIN LICENSE ACTIVE ║');
386
- log.info('║ ║');
387
- log.info(`║ License: ${licenseKey.padEnd(38, ' ')}║`);
388
- log.info(`║ User: ${(license?.firstName + ' ' + license?.lastName).padEnd(41, ' ')}║`);
389
- log.info(`║ Email: ${(license?.email || 'N/A').padEnd(40, ' ')}║`);
390
- log.info('║ ║');
391
- log.info('║ [AUTO] Pinging every 15 minutes ║');
392
- log.info('╚════════════════════════════════════════════════════════════════╝');
393
-
394
- return {
395
- valid: true,
396
- demo: false,
397
- data: verification.data,
398
- gracePeriod: verification.gracePeriod || false,
399
- };
400
- } else {
401
- log.error(`[ERROR] License validation failed (Key: ${licenseKey.substring(0, 10)}...)`);
402
- log.info('──────────────────────────────────────────────────────────');
403
- log.info('[WARNING] Running in demo mode with limited features');
404
- return {
405
- valid: false,
406
- demo: true,
407
- error: 'Invalid or expired license',
408
- data: null,
409
- };
410
- }
411
- } catch (error) {
412
- log.error('[ERROR] Error initializing License Guard:', error);
413
- return {
414
- valid: false,
415
- demo: true,
416
- error: error.message,
417
- data: null,
418
- };
419
- }
420
- },
421
- };
422
- };
423
-