strapi-plugin-magic-mail 2.8.3 → 2.9.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.
@@ -4,8 +4,8 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const reactRouterDom = require("react-router-dom");
6
6
  const designSystem = require("@strapi/design-system");
7
- const outline = require("@heroicons/react/24/outline");
8
7
  const admin = require("@strapi/strapi/admin");
8
+ const outline = require("@heroicons/react/24/outline");
9
9
  const styled = require("styled-components");
10
10
  const icons = require("@strapi/icons");
11
11
  const StyledButtons = require("./StyledButtons-DVGuFoqy.js");
@@ -473,32 +473,26 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
473
473
  message: "✅ Gmail OAuth authorized! Please complete the account setup."
474
474
  });
475
475
  }
476
+ const OAUTH_MESSAGE_TYPES = {
477
+ "gmail-oauth-success": "Gmail",
478
+ "microsoft-oauth-success": "Microsoft",
479
+ "yahoo-oauth-success": "Yahoo Mail"
480
+ };
481
+ const isValidOAuthToken = (value) => typeof value === "string" && value.length > 0 && value.length < 8192;
476
482
  const handleMessage = (event) => {
477
483
  if (event.origin !== window.location.origin) return;
478
- if (event.data.type === "gmail-oauth-success") {
479
- setOauthCode(event.data.code);
480
- setOauthState(event.data.state);
481
- toggleNotification({
482
- type: "success",
483
- message: "✅ Gmail OAuth authorized! Please complete the account setup."
484
- });
485
- }
486
- if (event.data.type === "microsoft-oauth-success") {
487
- setOauthCode(event.data.code);
488
- setOauthState(event.data.state);
489
- toggleNotification({
490
- type: "success",
491
- message: "✅ Microsoft OAuth authorized! Please complete the account setup."
492
- });
493
- }
494
- if (event.data.type === "yahoo-oauth-success") {
495
- setOauthCode(event.data.code);
496
- setOauthState(event.data.state);
497
- toggleNotification({
498
- type: "success",
499
- message: "✅ Yahoo Mail OAuth authorized! Please complete the account setup."
500
- });
484
+ if (!event.data || typeof event.data !== "object") return;
485
+ const providerLabel = OAUTH_MESSAGE_TYPES[event.data.type];
486
+ if (!providerLabel) return;
487
+ if (!isValidOAuthToken(event.data.code) || !isValidOAuthToken(event.data.state)) {
488
+ return;
501
489
  }
490
+ setOauthCode(event.data.code);
491
+ setOauthState(event.data.state);
492
+ toggleNotification({
493
+ type: "success",
494
+ message: `✅ ${providerLabel} OAuth authorized! Please complete the account setup.`
495
+ });
502
496
  };
503
497
  window.addEventListener("message", handleMessage);
504
498
  return () => {
@@ -8575,6 +8569,10 @@ const LicenseGuard = ({ children }) => {
8575
8569
  }
8576
8570
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
8577
8571
  };
8572
+ const pluginId = "magic-mail";
8573
+ const pluginPermissions = {
8574
+ access: [{ action: `plugin::${pluginId}.access`, subject: null }]
8575
+ };
8578
8576
  const App = () => {
8579
8577
  const location = reactRouterDom.useLocation();
8580
8578
  const navigate = reactRouterDom.useNavigate();
@@ -8599,9 +8597,9 @@ const App = () => {
8599
8597
  if (tab === "whatsapp") navigate("/plugins/magic-mail/whatsapp");
8600
8598
  };
8601
8599
  if (isEditorRoute) {
8602
- return /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(EditorPage, {}) });
8600
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(EditorPage, {}) }) });
8603
8601
  }
8604
- return /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { value: activeTab, onValueChange: handleTabChange, children: [
8602
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { value: activeTab, onValueChange: handleTabChange, children: [
8605
8603
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.List, { children: [
8606
8604
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "accounts", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
8607
8605
  /* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { style: { width: 16, height: 16 } }),
@@ -8629,6 +8627,6 @@ const App = () => {
8629
8627
  hasEmailDesigner && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "templates", children: /* @__PURE__ */ jsxRuntime.jsx(TemplateList, {}) }),
8630
8628
  hasAnalytics && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "analytics", children: /* @__PURE__ */ jsxRuntime.jsx(Analytics, {}) }),
8631
8629
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "whatsapp", children: /* @__PURE__ */ jsxRuntime.jsx(WhatsAppPage, {}) })
8632
- ] }) }) });
8630
+ ] }) }) }) });
8633
8631
  };
8634
8632
  exports.default = App;
@@ -2,8 +2,8 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import React, { useRef, useEffect, useState, useCallback } from "react";
3
3
  import { useNavigate, useLocation } from "react-router-dom";
4
4
  import { Modal, Typography, Flex, Box, Field, TextInput, Alert, Textarea, NumberInput, Divider, Toggle, Badge, Button, Loader, SingleSelect, SingleSelectOption, Thead, Tr, Th, Tbody, Td, Table, Tabs, Accordion } from "@strapi/design-system";
5
+ import { useFetchClient, useNotification, Page } from "@strapi/strapi/admin";
5
6
  import { EnvelopeIcon, ServerIcon, SparklesIcon, PlusIcon, PencilIcon, PlayIcon, TrashIcon, MagnifyingGlassIcon, FunnelIcon, CheckIcon, Cog6ToothIcon, DocumentTextIcon, ChartBarIcon, BoltIcon, CheckCircleIcon, ArrowUpTrayIcon, ArrowDownTrayIcon, DocumentArrowDownIcon, CodeBracketIcon, DocumentDuplicateIcon, PaperAirplaneIcon, ClipboardDocumentIcon, ArrowLeftIcon, ClockIcon, XMarkIcon, ArrowUturnLeftIcon, EnvelopeOpenIcon, CursorArrowRaysIcon, ExclamationTriangleIcon, XCircleIcon, KeyIcon, ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
6
- import { useFetchClient, useNotification } from "@strapi/strapi/admin";
7
7
  import styled, { css, keyframes } from "styled-components";
8
8
  import { Star, Mail, Server, Lock, Cog, Check, Cloud, Key, ArrowLeft, ArrowRight, ArrowClockwise, Play, Cross } from "@strapi/icons";
9
9
  import { T as TertiaryButton, G as GradientButton$1, C as CTAButton, I as IconButton, a as IconButtonPrimary, b as IconButtonDanger, S as SecondaryButton, c as IconButtonPurple, d as IconButtonSuccess, D as DangerButton } from "./StyledButtons-CdOf4Sps.mjs";
@@ -450,32 +450,26 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
450
450
  message: "✅ Gmail OAuth authorized! Please complete the account setup."
451
451
  });
452
452
  }
453
+ const OAUTH_MESSAGE_TYPES = {
454
+ "gmail-oauth-success": "Gmail",
455
+ "microsoft-oauth-success": "Microsoft",
456
+ "yahoo-oauth-success": "Yahoo Mail"
457
+ };
458
+ const isValidOAuthToken = (value) => typeof value === "string" && value.length > 0 && value.length < 8192;
453
459
  const handleMessage = (event) => {
454
460
  if (event.origin !== window.location.origin) return;
455
- if (event.data.type === "gmail-oauth-success") {
456
- setOauthCode(event.data.code);
457
- setOauthState(event.data.state);
458
- toggleNotification({
459
- type: "success",
460
- message: "✅ Gmail OAuth authorized! Please complete the account setup."
461
- });
462
- }
463
- if (event.data.type === "microsoft-oauth-success") {
464
- setOauthCode(event.data.code);
465
- setOauthState(event.data.state);
466
- toggleNotification({
467
- type: "success",
468
- message: "✅ Microsoft OAuth authorized! Please complete the account setup."
469
- });
470
- }
471
- if (event.data.type === "yahoo-oauth-success") {
472
- setOauthCode(event.data.code);
473
- setOauthState(event.data.state);
474
- toggleNotification({
475
- type: "success",
476
- message: "✅ Yahoo Mail OAuth authorized! Please complete the account setup."
477
- });
461
+ if (!event.data || typeof event.data !== "object") return;
462
+ const providerLabel = OAUTH_MESSAGE_TYPES[event.data.type];
463
+ if (!providerLabel) return;
464
+ if (!isValidOAuthToken(event.data.code) || !isValidOAuthToken(event.data.state)) {
465
+ return;
478
466
  }
467
+ setOauthCode(event.data.code);
468
+ setOauthState(event.data.state);
469
+ toggleNotification({
470
+ type: "success",
471
+ message: `✅ ${providerLabel} OAuth authorized! Please complete the account setup.`
472
+ });
479
473
  };
480
474
  window.addEventListener("message", handleMessage);
481
475
  return () => {
@@ -8552,6 +8546,10 @@ const LicenseGuard = ({ children }) => {
8552
8546
  }
8553
8547
  return /* @__PURE__ */ jsx(Fragment, { children });
8554
8548
  };
8549
+ const pluginId = "magic-mail";
8550
+ const pluginPermissions = {
8551
+ access: [{ action: `plugin::${pluginId}.access`, subject: null }]
8552
+ };
8555
8553
  const App = () => {
8556
8554
  const location = useLocation();
8557
8555
  const navigate = useNavigate();
@@ -8576,9 +8574,9 @@ const App = () => {
8576
8574
  if (tab === "whatsapp") navigate("/plugins/magic-mail/whatsapp");
8577
8575
  };
8578
8576
  if (isEditorRoute) {
8579
- return /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(EditorPage, {}) });
8577
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(EditorPage, {}) }) });
8580
8578
  }
8581
- return /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTab, onValueChange: handleTabChange, children: [
8579
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTab, onValueChange: handleTabChange, children: [
8582
8580
  /* @__PURE__ */ jsxs(Tabs.List, { children: [
8583
8581
  /* @__PURE__ */ jsx(Tabs.Trigger, { value: "accounts", children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
8584
8582
  /* @__PURE__ */ jsx(EnvelopeIcon, { style: { width: 16, height: 16 } }),
@@ -8606,7 +8604,7 @@ const App = () => {
8606
8604
  hasEmailDesigner && /* @__PURE__ */ jsx(Tabs.Content, { value: "templates", children: /* @__PURE__ */ jsx(TemplateList, {}) }),
8607
8605
  hasAnalytics && /* @__PURE__ */ jsx(Tabs.Content, { value: "analytics", children: /* @__PURE__ */ jsx(Analytics, {}) }),
8608
8606
  /* @__PURE__ */ jsx(Tabs.Content, { value: "whatsapp", children: /* @__PURE__ */ jsx(WhatsAppPage, {}) })
8609
- ] }) }) });
8607
+ ] }) }) }) });
8610
8608
  };
8611
8609
  export {
8612
8610
  App as default
@@ -60,6 +60,7 @@ const prefixPluginTranslations = (data, pluginId2) => {
60
60
  };
61
61
  const index = {
62
62
  register(app) {
63
+ const pluginPermissions = [{ action: `plugin::${pluginId}.access`, subject: null }];
63
64
  app.addMenuLink({
64
65
  to: `plugins/${pluginId}`,
65
66
  icon: PluginIcon,
@@ -67,7 +68,8 @@ const index = {
67
68
  id: `${pluginId}.plugin.name`,
68
69
  defaultMessage: "MagicMail"
69
70
  },
70
- Component: () => Promise.resolve().then(() => require("../_chunks/App-DGGqHEPC.js"))
71
+ Component: () => Promise.resolve().then(() => require("../_chunks/App-BSZzEkaa.js")),
72
+ permissions: pluginPermissions
71
73
  });
72
74
  app.createSettingSection(
73
75
  {
@@ -83,7 +85,8 @@ const index = {
83
85
  },
84
86
  id: "plugin-settings",
85
87
  to: `${pluginId}/plugin-settings`,
86
- Component: () => Promise.resolve().then(() => require("../_chunks/PluginSettings-cZXE_vy8.js"))
88
+ Component: () => Promise.resolve().then(() => require("../_chunks/PluginSettings-cZXE_vy8.js")),
89
+ permissions: pluginPermissions
87
90
  },
88
91
  {
89
92
  intlLabel: {
@@ -92,7 +95,8 @@ const index = {
92
95
  },
93
96
  id: "upgrade",
94
97
  to: `${pluginId}/upgrade`,
95
- Component: () => Promise.resolve().then(() => require("../_chunks/LicensePage-sB-xDRL9.js"))
98
+ Component: () => Promise.resolve().then(() => require("../_chunks/LicensePage-sB-xDRL9.js")),
99
+ permissions: pluginPermissions
96
100
  },
97
101
  {
98
102
  intlLabel: {
@@ -101,7 +105,8 @@ const index = {
101
105
  },
102
106
  id: "license",
103
107
  to: `${pluginId}/license`,
104
- Component: () => Promise.resolve().then(() => require("../_chunks/Settings-BRFoD1yZ.js"))
108
+ Component: () => Promise.resolve().then(() => require("../_chunks/Settings-BRFoD1yZ.js")),
109
+ permissions: pluginPermissions
105
110
  }
106
111
  ]
107
112
  );
@@ -59,6 +59,7 @@ const prefixPluginTranslations = (data, pluginId2) => {
59
59
  };
60
60
  const index = {
61
61
  register(app) {
62
+ const pluginPermissions = [{ action: `plugin::${pluginId}.access`, subject: null }];
62
63
  app.addMenuLink({
63
64
  to: `plugins/${pluginId}`,
64
65
  icon: PluginIcon,
@@ -66,7 +67,8 @@ const index = {
66
67
  id: `${pluginId}.plugin.name`,
67
68
  defaultMessage: "MagicMail"
68
69
  },
69
- Component: () => import("../_chunks/App-CaT5U0uM.mjs")
70
+ Component: () => import("../_chunks/App-BZQTPVdT.mjs"),
71
+ permissions: pluginPermissions
70
72
  });
71
73
  app.createSettingSection(
72
74
  {
@@ -82,7 +84,8 @@ const index = {
82
84
  },
83
85
  id: "plugin-settings",
84
86
  to: `${pluginId}/plugin-settings`,
85
- Component: () => import("../_chunks/PluginSettings-XwyzH95_.mjs")
87
+ Component: () => import("../_chunks/PluginSettings-XwyzH95_.mjs"),
88
+ permissions: pluginPermissions
86
89
  },
87
90
  {
88
91
  intlLabel: {
@@ -91,7 +94,8 @@ const index = {
91
94
  },
92
95
  id: "upgrade",
93
96
  to: `${pluginId}/upgrade`,
94
- Component: () => import("../_chunks/LicensePage-B61HnhyD.mjs")
97
+ Component: () => import("../_chunks/LicensePage-B61HnhyD.mjs"),
98
+ permissions: pluginPermissions
95
99
  },
96
100
  {
97
101
  intlLabel: {
@@ -100,7 +104,8 @@ const index = {
100
104
  },
101
105
  id: "license",
102
106
  to: `${pluginId}/license`,
103
- Component: () => import("../_chunks/Settings-DoSrZKfp.mjs")
107
+ Component: () => import("../_chunks/Settings-DoSrZKfp.mjs"),
108
+ permissions: pluginPermissions
104
109
  }
105
110
  ]
106
111
  );