strapi-plugin-magic-mail 2.2.4 → 2.2.5
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/index.js +1 -1
- package/dist/server/index.mjs +1 -1
- package/package.json +1 -3
- package/admin/jsconfig.json +0 -10
- package/admin/src/components/AddAccountModal.jsx +0 -1943
- package/admin/src/components/Initializer.jsx +0 -14
- package/admin/src/components/LicenseGuard.jsx +0 -475
- package/admin/src/components/PluginIcon.jsx +0 -5
- package/admin/src/hooks/useAuthRefresh.js +0 -44
- package/admin/src/hooks/useLicense.js +0 -158
- package/admin/src/index.js +0 -87
- package/admin/src/pages/Analytics.jsx +0 -762
- package/admin/src/pages/App.jsx +0 -111
- package/admin/src/pages/EmailDesigner/EditorPage.jsx +0 -1424
- package/admin/src/pages/EmailDesigner/TemplateList.jsx +0 -1807
- package/admin/src/pages/HomePage.jsx +0 -1170
- package/admin/src/pages/LicensePage.jsx +0 -430
- package/admin/src/pages/RoutingRules.jsx +0 -1141
- package/admin/src/pages/Settings.jsx +0 -603
- package/admin/src/pluginId.js +0 -3
- package/admin/src/translations/de.json +0 -71
- package/admin/src/translations/en.json +0 -70
- package/admin/src/translations/es.json +0 -71
- package/admin/src/translations/fr.json +0 -71
- package/admin/src/translations/pt.json +0 -71
- package/admin/src/utils/fetchWithRetry.js +0 -123
- package/admin/src/utils/getTranslation.js +0 -5
- package/admin/src/utils/theme.js +0 -85
- package/server/jsconfig.json +0 -10
- package/server/src/bootstrap.js +0 -157
- package/server/src/config/features.js +0 -260
- package/server/src/config/index.js +0 -9
- package/server/src/content-types/email-account/schema.json +0 -93
- package/server/src/content-types/email-event/index.js +0 -8
- package/server/src/content-types/email-event/schema.json +0 -57
- package/server/src/content-types/email-link/index.js +0 -8
- package/server/src/content-types/email-link/schema.json +0 -49
- package/server/src/content-types/email-log/index.js +0 -8
- package/server/src/content-types/email-log/schema.json +0 -106
- package/server/src/content-types/email-template/schema.json +0 -74
- package/server/src/content-types/email-template-version/schema.json +0 -60
- package/server/src/content-types/index.js +0 -33
- package/server/src/content-types/routing-rule/schema.json +0 -59
- package/server/src/controllers/accounts.js +0 -229
- package/server/src/controllers/analytics.js +0 -361
- package/server/src/controllers/controller.js +0 -26
- package/server/src/controllers/email-designer.js +0 -474
- package/server/src/controllers/index.js +0 -21
- package/server/src/controllers/license.js +0 -269
- package/server/src/controllers/oauth.js +0 -474
- package/server/src/controllers/routing-rules.js +0 -129
- package/server/src/controllers/test.js +0 -301
- package/server/src/destroy.js +0 -27
- package/server/src/index.js +0 -25
- package/server/src/middlewares/index.js +0 -3
- package/server/src/policies/index.js +0 -3
- package/server/src/register.js +0 -5
- package/server/src/routes/admin.js +0 -469
- package/server/src/routes/content-api.js +0 -37
- package/server/src/routes/index.js +0 -9
- package/server/src/services/account-manager.js +0 -329
- package/server/src/services/analytics.js +0 -512
- package/server/src/services/email-designer.js +0 -717
- package/server/src/services/email-router.js +0 -1446
- package/server/src/services/index.js +0 -17
- package/server/src/services/license-guard.js +0 -423
- package/server/src/services/oauth.js +0 -515
- package/server/src/services/service.js +0 -7
- package/server/src/utils/encryption.js +0 -81
- package/server/src/utils/logger.js +0 -84
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* License Controller for MagicMail Plugin
|
|
3
|
-
* Manages licenses directly from the Admin Panel
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
module.exports = ({ strapi }) => ({
|
|
7
|
-
/**
|
|
8
|
-
* Auto-create license with logged-in admin user data
|
|
9
|
-
*/
|
|
10
|
-
async autoCreate(ctx) {
|
|
11
|
-
try {
|
|
12
|
-
// Get the logged-in admin user
|
|
13
|
-
const adminUser = ctx.state.user;
|
|
14
|
-
|
|
15
|
-
if (!adminUser) {
|
|
16
|
-
return ctx.unauthorized('No admin user logged in');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const licenseGuard = strapi.plugin('magic-mail').service('license-guard');
|
|
20
|
-
|
|
21
|
-
// Use admin user data for license creation
|
|
22
|
-
const license = await licenseGuard.createLicense({
|
|
23
|
-
email: adminUser.email,
|
|
24
|
-
firstName: adminUser.firstname || 'Admin',
|
|
25
|
-
lastName: adminUser.lastname || 'User',
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (!license) {
|
|
29
|
-
return ctx.badRequest('Failed to create license');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Store the license key
|
|
33
|
-
await licenseGuard.storeLicenseKey(license.licenseKey);
|
|
34
|
-
|
|
35
|
-
// Start pinging
|
|
36
|
-
const pingInterval = licenseGuard.startPinging(license.licenseKey, 15);
|
|
37
|
-
|
|
38
|
-
// Update global license guard
|
|
39
|
-
strapi.licenseGuardMagicMail = {
|
|
40
|
-
licenseKey: license.licenseKey,
|
|
41
|
-
pingInterval,
|
|
42
|
-
data: license,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return ctx.send({
|
|
46
|
-
success: true,
|
|
47
|
-
message: 'License automatically created and activated',
|
|
48
|
-
data: license,
|
|
49
|
-
});
|
|
50
|
-
} catch (error) {
|
|
51
|
-
strapi.log.error('[magic-mail] Error auto-creating license:', error);
|
|
52
|
-
return ctx.badRequest('Error creating license');
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get current license status
|
|
58
|
-
*/
|
|
59
|
-
async getStatus(ctx) {
|
|
60
|
-
try {
|
|
61
|
-
const licenseGuard = strapi.plugin('magic-mail').service('license-guard');
|
|
62
|
-
const pluginStore = strapi.store({
|
|
63
|
-
type: 'plugin',
|
|
64
|
-
name: 'magic-mail'
|
|
65
|
-
});
|
|
66
|
-
const licenseKey = await pluginStore.get({ key: 'licenseKey' });
|
|
67
|
-
|
|
68
|
-
if (!licenseKey) {
|
|
69
|
-
return ctx.send({
|
|
70
|
-
success: false,
|
|
71
|
-
demo: true,
|
|
72
|
-
valid: false,
|
|
73
|
-
message: 'No license found. Running in demo mode.',
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const verification = await licenseGuard.verifyLicense(licenseKey);
|
|
78
|
-
const license = await licenseGuard.getLicenseByKey(licenseKey);
|
|
79
|
-
|
|
80
|
-
return ctx.send({
|
|
81
|
-
success: true,
|
|
82
|
-
valid: verification.valid,
|
|
83
|
-
demo: false,
|
|
84
|
-
data: {
|
|
85
|
-
licenseKey,
|
|
86
|
-
email: license?.email || null,
|
|
87
|
-
firstName: license?.firstName || null,
|
|
88
|
-
lastName: license?.lastName || null,
|
|
89
|
-
isActive: license?.isActive || false,
|
|
90
|
-
isExpired: license?.isExpired || false,
|
|
91
|
-
isOnline: license?.isOnline || false,
|
|
92
|
-
expiresAt: license?.expiresAt,
|
|
93
|
-
lastPingAt: license?.lastPingAt,
|
|
94
|
-
deviceName: license?.deviceName,
|
|
95
|
-
deviceId: license?.deviceId,
|
|
96
|
-
ipAddress: license?.ipAddress,
|
|
97
|
-
features: {
|
|
98
|
-
premium: license?.featurePremium || false,
|
|
99
|
-
advanced: license?.featureAdvanced || false,
|
|
100
|
-
enterprise: license?.featureEnterprise || false,
|
|
101
|
-
},
|
|
102
|
-
maxDevices: license?.maxDevices || 1,
|
|
103
|
-
currentDevices: license?.currentDevices || 0,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
} catch (error) {
|
|
107
|
-
strapi.log.error('[magic-mail] Error getting license status:', error);
|
|
108
|
-
return ctx.badRequest('Error getting license status');
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Store and validate an existing license key
|
|
114
|
-
*/
|
|
115
|
-
async storeKey(ctx) {
|
|
116
|
-
try {
|
|
117
|
-
const { licenseKey, email } = ctx.request.body;
|
|
118
|
-
|
|
119
|
-
if (!licenseKey || !licenseKey.trim()) {
|
|
120
|
-
return ctx.badRequest('License key is required');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (!email || !email.trim()) {
|
|
124
|
-
return ctx.badRequest('Email address is required');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const trimmedKey = licenseKey.trim();
|
|
128
|
-
const trimmedEmail = email.trim().toLowerCase();
|
|
129
|
-
const licenseGuard = strapi.plugin('magic-mail').service('license-guard');
|
|
130
|
-
|
|
131
|
-
// Verify the license key first
|
|
132
|
-
const verification = await licenseGuard.verifyLicense(trimmedKey);
|
|
133
|
-
|
|
134
|
-
if (!verification.valid) {
|
|
135
|
-
strapi.log.warn(`[magic-mail] [WARNING] Invalid license key attempted: ${trimmedKey.substring(0, 8)}...`);
|
|
136
|
-
return ctx.badRequest('Invalid or expired license key');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Get license details to verify email
|
|
140
|
-
const license = await licenseGuard.getLicenseByKey(trimmedKey);
|
|
141
|
-
|
|
142
|
-
if (!license) {
|
|
143
|
-
return ctx.badRequest('License not found');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Verify email matches
|
|
147
|
-
if (license.email.toLowerCase() !== trimmedEmail) {
|
|
148
|
-
strapi.log.warn(`[magic-mail] [WARNING] Email mismatch for license key`);
|
|
149
|
-
return ctx.badRequest('Email address does not match this license key');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Store the license key
|
|
153
|
-
await licenseGuard.storeLicenseKey(trimmedKey);
|
|
154
|
-
|
|
155
|
-
// Start pinging
|
|
156
|
-
const pingInterval = licenseGuard.startPinging(trimmedKey, 15);
|
|
157
|
-
|
|
158
|
-
// Update global license guard
|
|
159
|
-
strapi.licenseGuardMagicMail = {
|
|
160
|
-
licenseKey: trimmedKey,
|
|
161
|
-
pingInterval,
|
|
162
|
-
data: verification.data,
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
strapi.log.info(`[magic-mail] [SUCCESS] License validated and stored`);
|
|
166
|
-
|
|
167
|
-
return ctx.send({
|
|
168
|
-
success: true,
|
|
169
|
-
message: 'License activated successfully',
|
|
170
|
-
data: verification.data,
|
|
171
|
-
});
|
|
172
|
-
} catch (error) {
|
|
173
|
-
strapi.log.error('[magic-mail] Error storing license key:', error);
|
|
174
|
-
return ctx.badRequest('Error storing license key');
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Debug endpoint to check license data
|
|
180
|
-
*/
|
|
181
|
-
async debugLicense(ctx) {
|
|
182
|
-
try {
|
|
183
|
-
const licenseGuard = strapi.plugin('magic-mail').service('license-guard');
|
|
184
|
-
const license = await licenseGuard.getCurrentLicense();
|
|
185
|
-
|
|
186
|
-
ctx.body = {
|
|
187
|
-
success: true,
|
|
188
|
-
rawLicense: license,
|
|
189
|
-
detectedFlags: {
|
|
190
|
-
featurePremium: license?.featurePremium,
|
|
191
|
-
featureAdvanced: license?.featureAdvanced,
|
|
192
|
-
featureEnterprise: license?.featureEnterprise,
|
|
193
|
-
},
|
|
194
|
-
detectedTier: license?.featureEnterprise ? 'enterprise' :
|
|
195
|
-
license?.featureAdvanced ? 'advanced' :
|
|
196
|
-
license?.featurePremium ? 'premium' : 'free',
|
|
197
|
-
};
|
|
198
|
-
} catch (error) {
|
|
199
|
-
strapi.log.error('[magic-mail] Error in debugLicense:', error);
|
|
200
|
-
ctx.throw(500, 'Error debugging license');
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Get license limits and available features
|
|
206
|
-
*/
|
|
207
|
-
async getLimits(ctx) {
|
|
208
|
-
try {
|
|
209
|
-
const licenseGuard = strapi.plugin('magic-mail').service('license-guard');
|
|
210
|
-
const features = require('../config/features');
|
|
211
|
-
|
|
212
|
-
const license = await licenseGuard.getCurrentLicense();
|
|
213
|
-
const maxAccounts = await licenseGuard.getMaxAccounts();
|
|
214
|
-
const maxRules = await licenseGuard.getMaxRoutingRules();
|
|
215
|
-
const maxTemplates = await licenseGuard.getMaxEmailTemplates();
|
|
216
|
-
|
|
217
|
-
// Get current counts using Document Service count()
|
|
218
|
-
const [currentAccounts, currentRules, currentTemplates] = await Promise.all([
|
|
219
|
-
strapi.documents('plugin::magic-mail.email-account').count(),
|
|
220
|
-
strapi.documents('plugin::magic-mail.routing-rule').count(),
|
|
221
|
-
strapi.documents('plugin::magic-mail.email-template').count(),
|
|
222
|
-
]);
|
|
223
|
-
|
|
224
|
-
// Get tier info - check both formats
|
|
225
|
-
let tier = 'free';
|
|
226
|
-
if (license?.featureEnterprise === true || license?.features?.enterprise === true) tier = 'enterprise';
|
|
227
|
-
else if (license?.featureAdvanced === true || license?.features?.advanced === true) tier = 'advanced';
|
|
228
|
-
else if (license?.featurePremium === true || license?.features?.premium === true) tier = 'premium';
|
|
229
|
-
|
|
230
|
-
const tierConfig = features[tier] || features.free;
|
|
231
|
-
|
|
232
|
-
// Only log in development mode
|
|
233
|
-
if (process.env.NODE_ENV === 'development') {
|
|
234
|
-
strapi.log.debug('[magic-mail] License tier:', tier);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
ctx.body = {
|
|
238
|
-
success: true,
|
|
239
|
-
tier,
|
|
240
|
-
limits: {
|
|
241
|
-
accounts: {
|
|
242
|
-
current: currentAccounts,
|
|
243
|
-
max: maxAccounts,
|
|
244
|
-
unlimited: maxAccounts === -1,
|
|
245
|
-
canCreate: maxAccounts === -1 || currentAccounts < maxAccounts,
|
|
246
|
-
},
|
|
247
|
-
routingRules: {
|
|
248
|
-
current: currentRules,
|
|
249
|
-
max: maxRules,
|
|
250
|
-
unlimited: maxRules === -1,
|
|
251
|
-
canCreate: maxRules === -1 || currentRules < maxRules,
|
|
252
|
-
},
|
|
253
|
-
emailTemplates: {
|
|
254
|
-
current: currentTemplates,
|
|
255
|
-
max: maxTemplates,
|
|
256
|
-
unlimited: maxTemplates === -1,
|
|
257
|
-
canCreate: maxTemplates === -1 || currentTemplates < maxTemplates,
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
allowedProviders: tierConfig.providers,
|
|
261
|
-
features: tierConfig.features,
|
|
262
|
-
};
|
|
263
|
-
} catch (error) {
|
|
264
|
-
strapi.log.error('[magic-mail] Error getting license limits:', error);
|
|
265
|
-
ctx.throw(500, 'Error getting license limits');
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
|