strapi-plugin-magic-link-v5 5.5.9 → 6.0.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/CHANGELOG.md +733 -0
- package/README.md +662 -928
- package/dist/admin/LicenseGuard-BgLA9go3.mjs +495 -0
- package/dist/admin/LicenseGuard-ewCjpc17.js +513 -0
- package/dist/admin/de-B1FNErPH.mjs +673 -0
- package/dist/admin/de-e75OECdq.js +673 -0
- package/dist/admin/en-CABKGbxH.js +673 -0
- package/dist/admin/en-HqDOFBCc.mjs +673 -0
- package/dist/admin/es-DpWl0Fax.js +673 -0
- package/dist/admin/es-jb94jqPR.mjs +673 -0
- package/dist/admin/fr-BQhLPvYw.js +673 -0
- package/dist/admin/fr-BseH1wrr.mjs +673 -0
- package/dist/admin/index-6ot9j1cN.js +5268 -0
- package/dist/admin/index-B390rccl.js +622 -0
- package/dist/admin/index-BPGKtruf.mjs +5266 -0
- package/dist/admin/index-BaTIQtnA.js +3869 -0
- package/dist/admin/index-CmG-93yx.js +141 -0
- package/dist/admin/index-DXe_ge4v.mjs +620 -0
- package/dist/admin/index-Dv5PVT1E.mjs +3867 -0
- package/dist/admin/index-k240ls6p.mjs +142 -0
- package/dist/admin/index.js +3 -3
- package/dist/admin/index.mjs +1 -2
- package/dist/admin/pt-CPkaveti.js +673 -0
- package/dist/admin/pt-DhlSCJn2.mjs +673 -0
- package/dist/admin/useUnsavedChangesGuard-BVZ4Mg4E.js +225 -0
- package/dist/admin/useUnsavedChangesGuard-QnkiZTLP.mjs +224 -0
- package/dist/server/i18n/de.json +32 -1
- package/dist/server/i18n/en.json +32 -1
- package/dist/server/i18n/es.json +32 -1
- package/dist/server/i18n/fr.json +32 -1
- package/dist/server/i18n/pt.json +32 -1
- package/dist/server/index.js +7092 -5971
- package/dist/server/index.mjs +7115 -5972
- package/package.json +42 -41
- package/strapi-admin.js +3 -1
- package/strapi-server.js +3 -2
- package/dist/_chunks/LicenseGuard-CiyjFnrw.js +0 -54
- package/dist/_chunks/LicenseGuard-DJ5fq2UZ.mjs +0 -55
- package/dist/_chunks/de-BSOk5suQ.js +0 -454
- package/dist/_chunks/de-CwhYs3O3.mjs +0 -454
- package/dist/_chunks/en-DnvSpXvu.js +0 -454
- package/dist/_chunks/en-gXXgGDV1.mjs +0 -454
- package/dist/_chunks/es-B-tnwByt.js +0 -407
- package/dist/_chunks/es-DG5gW3RZ.mjs +0 -407
- package/dist/_chunks/fr-BKo8t7Fx.js +0 -407
- package/dist/_chunks/fr-BQn1OHOR.mjs +0 -407
- package/dist/_chunks/index-01GHNxSr.js +0 -307
- package/dist/_chunks/index-5jsDgD-q.mjs +0 -330
- package/dist/_chunks/index-BWuj-5WE.js +0 -5068
- package/dist/_chunks/index-Bj3H_Z4B.js +0 -142
- package/dist/_chunks/index-CC4Eu9Dm.js +0 -332
- package/dist/_chunks/index-Csyi13vd.mjs +0 -2891
- package/dist/_chunks/index-DJqXiiP1.js +0 -2893
- package/dist/_chunks/index-DQUYFsLT.mjs +0 -143
- package/dist/_chunks/index-Dufv-daf.mjs +0 -305
- package/dist/_chunks/index-szeYJKpN.mjs +0 -5066
- package/dist/_chunks/pt-CjEkXBAz.js +0 -407
- package/dist/_chunks/pt-trziAOzT.mjs +0 -407
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const designSystem = require("@strapi/design-system");
|
|
6
|
+
const strapiAdmin = require("@strapi/strapi/admin");
|
|
7
|
+
const icons = require("@strapi/icons");
|
|
8
|
+
const styled = require("styled-components");
|
|
9
|
+
const LicenseGuard = require("./LicenseGuard-ewCjpc17.js");
|
|
10
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
11
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
12
|
+
const MASK_CHAR = "•";
|
|
13
|
+
const isMaskedKey = (value) => typeof value === "string" && (value.includes(MASK_CHAR) || value.includes("*"));
|
|
14
|
+
const maskLicenseKey = (key) => {
|
|
15
|
+
if (typeof key !== "string" || !key.trim()) return "";
|
|
16
|
+
const trimmed = key.trim();
|
|
17
|
+
if (isMaskedKey(trimmed)) return trimmed;
|
|
18
|
+
const hidden = MASK_CHAR.repeat(4);
|
|
19
|
+
if (trimmed.length < 12) return `${hidden}${hidden}`;
|
|
20
|
+
return `${hidden}-${hidden}-${trimmed.slice(-4)}`;
|
|
21
|
+
};
|
|
22
|
+
const getLicenseView = (payload) => {
|
|
23
|
+
const details = payload?.data && typeof payload.data === "object" ? payload.data : {};
|
|
24
|
+
const rawKey = typeof details.licenseKey === "string" ? details.licenseKey.trim() : "";
|
|
25
|
+
const fullKey = rawKey && !isMaskedKey(rawKey) ? rawKey : null;
|
|
26
|
+
const maskedKey = typeof details.licenseKeyMasked === "string" && details.licenseKeyMasked.trim() || maskLicenseKey(rawKey);
|
|
27
|
+
const hasKey = Boolean(payload?.hasKey);
|
|
28
|
+
const isValid = payload?.valid !== false;
|
|
29
|
+
let kind = "none";
|
|
30
|
+
if (hasKey) kind = isValid ? "active" : "unverified";
|
|
31
|
+
return {
|
|
32
|
+
kind,
|
|
33
|
+
hasKey,
|
|
34
|
+
fullKey,
|
|
35
|
+
maskedKey,
|
|
36
|
+
isActive: details.isActive !== false,
|
|
37
|
+
details
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const holderName = (details = {}) => [details.firstName, details.lastName].filter((part) => typeof part === "string" && part.trim()).map((part) => part.trim()).join(" ");
|
|
41
|
+
const buildLicenseFileContent = (values, labels) => {
|
|
42
|
+
const rule = "=".repeat(40);
|
|
43
|
+
const line = "-".repeat(40);
|
|
44
|
+
return [
|
|
45
|
+
labels.title,
|
|
46
|
+
rule,
|
|
47
|
+
"",
|
|
48
|
+
`${labels.key}: ${values.key}`,
|
|
49
|
+
"",
|
|
50
|
+
labels.holder,
|
|
51
|
+
line,
|
|
52
|
+
`${labels.name}: ${values.name}`,
|
|
53
|
+
`${labels.email}: ${values.email}`,
|
|
54
|
+
"",
|
|
55
|
+
labels.statusSection,
|
|
56
|
+
line,
|
|
57
|
+
`${labels.status}: ${values.status}`,
|
|
58
|
+
`${labels.expires}: ${values.expires}`,
|
|
59
|
+
"",
|
|
60
|
+
rule,
|
|
61
|
+
`${labels.generated}: ${values.generated}`,
|
|
62
|
+
""
|
|
63
|
+
].join("\n");
|
|
64
|
+
};
|
|
65
|
+
const LICENSE_FILE_NAME = "magic-link-license.txt";
|
|
66
|
+
const licenseErrorMessage = (error, t) => {
|
|
67
|
+
const status = error?.status ?? error?.response?.status;
|
|
68
|
+
if (status === 401 || status === 403) {
|
|
69
|
+
return t(
|
|
70
|
+
"license.error.forbidden",
|
|
71
|
+
"You do not have permission to view the license. Ask an administrator for the Settings read permission."
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return t("license.error.load", "The license information could not be loaded. Try again.");
|
|
75
|
+
};
|
|
76
|
+
const fadeIn = styled.keyframes`
|
|
77
|
+
from { opacity: 0; transform: translateY(8px); }
|
|
78
|
+
to { opacity: 1; transform: translateY(0); }
|
|
79
|
+
`;
|
|
80
|
+
const shimmer = styled.keyframes`
|
|
81
|
+
0% { background-position: -200% 0; }
|
|
82
|
+
100% { background-position: 200% 0; }
|
|
83
|
+
`;
|
|
84
|
+
const Container = styled__default.default(designSystem.Box)`
|
|
85
|
+
max-width: 1440px;
|
|
86
|
+
margin: 0 auto;
|
|
87
|
+
${LicenseGuard.motionSafe(styled.css`
|
|
88
|
+
animation: ${fadeIn} 0.4s ease-out;
|
|
89
|
+
`)}
|
|
90
|
+
`;
|
|
91
|
+
const StickyHeader = styled__default.default(designSystem.Box)`
|
|
92
|
+
position: sticky;
|
|
93
|
+
top: 0;
|
|
94
|
+
z-index: 10;
|
|
95
|
+
background: ${LicenseGuard.color("neutral0")};
|
|
96
|
+
border-bottom: 1px solid ${LicenseGuard.color("neutral200")};
|
|
97
|
+
box-shadow: ${LicenseGuard.theme.shadows.sm};
|
|
98
|
+
padding: ${LicenseGuard.space(6)};
|
|
99
|
+
|
|
100
|
+
@media (max-width: ${LicenseGuard.breakpoints.mobile}) {
|
|
101
|
+
padding: ${LicenseGuard.space(4)};
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
const HeaderRow = styled__default.default(designSystem.Flex)`
|
|
105
|
+
flex-wrap: wrap;
|
|
106
|
+
gap: ${LicenseGuard.space(4)};
|
|
107
|
+
justify-content: space-between;
|
|
108
|
+
align-items: center;
|
|
109
|
+
|
|
110
|
+
& > :first-child {
|
|
111
|
+
min-width: 0;
|
|
112
|
+
flex: 1 1 240px;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
const GradientButton = styled__default.default(designSystem.Button)`
|
|
116
|
+
background: ${LicenseGuard.brand.gradient};
|
|
117
|
+
border: none;
|
|
118
|
+
color: ${LicenseGuard.brand.onFill};
|
|
119
|
+
|
|
120
|
+
& > span,
|
|
121
|
+
& svg {
|
|
122
|
+
color: ${LicenseGuard.brand.onFill};
|
|
123
|
+
fill: ${LicenseGuard.brand.onFill};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&:hover:not([aria-disabled='true']) {
|
|
127
|
+
background: ${LicenseGuard.brand.gradientHover};
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
const Content = styled__default.default(designSystem.Box)`
|
|
131
|
+
padding: ${LicenseGuard.space(6)};
|
|
132
|
+
|
|
133
|
+
@media (max-width: ${LicenseGuard.breakpoints.mobile}) {
|
|
134
|
+
padding: ${LicenseGuard.space(4)};
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
const Stack = styled__default.default(designSystem.Flex)`
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
align-items: stretch;
|
|
140
|
+
gap: ${LicenseGuard.space(6)};
|
|
141
|
+
`;
|
|
142
|
+
const LicenseKeyBanner = styled__default.default.section`
|
|
143
|
+
background:
|
|
144
|
+
linear-gradient(rgba(15, 23, 42, 0.25), rgba(15, 23, 42, 0.25)), ${LicenseGuard.brand.violetGradient};
|
|
145
|
+
border-radius: ${LicenseGuard.theme.borderRadius.lg};
|
|
146
|
+
padding: ${LicenseGuard.space(6)} ${LicenseGuard.space(7)};
|
|
147
|
+
color: ${LicenseGuard.brand.onFill};
|
|
148
|
+
position: relative;
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
box-shadow: 0 4px 20px rgba(102, 126, 234, 0.25);
|
|
151
|
+
|
|
152
|
+
@media (max-width: ${LicenseGuard.breakpoints.mobile}) {
|
|
153
|
+
padding: ${LicenseGuard.space(4)};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&::after {
|
|
157
|
+
content: '';
|
|
158
|
+
position: absolute;
|
|
159
|
+
top: -50%;
|
|
160
|
+
right: -50%;
|
|
161
|
+
width: 200%;
|
|
162
|
+
height: 200%;
|
|
163
|
+
background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.08), transparent);
|
|
164
|
+
background-size: 200% 100%;
|
|
165
|
+
${LicenseGuard.motionSafe(styled.css`
|
|
166
|
+
animation: ${shimmer} 3s infinite;
|
|
167
|
+
`)}
|
|
168
|
+
pointer-events: none;
|
|
169
|
+
z-index: 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
& > * {
|
|
173
|
+
position: relative;
|
|
174
|
+
z-index: 1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
${LicenseGuard.reducedMotion}
|
|
178
|
+
`;
|
|
179
|
+
const BannerRow = styled__default.default.div`
|
|
180
|
+
display: flex;
|
|
181
|
+
flex-wrap: wrap;
|
|
182
|
+
gap: ${LicenseGuard.space(4)};
|
|
183
|
+
justify-content: space-between;
|
|
184
|
+
align-items: flex-start;
|
|
185
|
+
`;
|
|
186
|
+
const BannerBody = styled__default.default.div`
|
|
187
|
+
flex: 1 1 260px;
|
|
188
|
+
min-width: 0;
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
gap: ${LicenseGuard.space(3)};
|
|
192
|
+
`;
|
|
193
|
+
const BannerLabel = styled__default.default.h2`
|
|
194
|
+
margin: 0;
|
|
195
|
+
color: ${LicenseGuard.brand.onFill};
|
|
196
|
+
font-size: ${LicenseGuard.fontSize(0)};
|
|
197
|
+
font-weight: 600;
|
|
198
|
+
letter-spacing: 0.5px;
|
|
199
|
+
text-transform: uppercase;
|
|
200
|
+
`;
|
|
201
|
+
const KeyText = styled__default.default.p`
|
|
202
|
+
margin: 0;
|
|
203
|
+
color: ${LicenseGuard.brand.onFill};
|
|
204
|
+
font-family: monospace;
|
|
205
|
+
font-size: ${LicenseGuard.fontSize(6)};
|
|
206
|
+
font-weight: 700;
|
|
207
|
+
line-height: 1.25;
|
|
208
|
+
overflow-wrap: anywhere;
|
|
209
|
+
|
|
210
|
+
@media (max-width: ${LicenseGuard.breakpoints.mobile}) {
|
|
211
|
+
font-size: ${LicenseGuard.fontSize(4)};
|
|
212
|
+
}
|
|
213
|
+
`;
|
|
214
|
+
const FrostedButton = styled__default.default(designSystem.Button)`
|
|
215
|
+
background: rgba(15, 23, 42, 0.2);
|
|
216
|
+
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
217
|
+
color: ${LicenseGuard.brand.onFill};
|
|
218
|
+
|
|
219
|
+
& > span,
|
|
220
|
+
& svg {
|
|
221
|
+
color: ${LicenseGuard.brand.onFill};
|
|
222
|
+
fill: ${LicenseGuard.brand.onFill};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
&:hover:not([aria-disabled='true']) {
|
|
226
|
+
background: rgba(15, 23, 42, 0.32);
|
|
227
|
+
border-color: ${LicenseGuard.brand.onFill};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
&:focus-visible {
|
|
231
|
+
outline: 2px solid ${LicenseGuard.brand.onFill};
|
|
232
|
+
outline-offset: 2px;
|
|
233
|
+
}
|
|
234
|
+
`;
|
|
235
|
+
const DetailGrid = styled__default.default.dl`
|
|
236
|
+
display: grid;
|
|
237
|
+
grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
|
|
238
|
+
align-items: stretch;
|
|
239
|
+
gap: ${LicenseGuard.space(6)};
|
|
240
|
+
margin: 0;
|
|
241
|
+
`;
|
|
242
|
+
const DetailItem = styled__default.default.div`
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: column;
|
|
245
|
+
gap: ${LicenseGuard.space(2)};
|
|
246
|
+
min-width: 0;
|
|
247
|
+
|
|
248
|
+
& > dd {
|
|
249
|
+
margin: 0;
|
|
250
|
+
overflow-wrap: anywhere;
|
|
251
|
+
}
|
|
252
|
+
`;
|
|
253
|
+
const LoaderArea = styled__default.default(designSystem.Flex)`
|
|
254
|
+
min-height: 320px;
|
|
255
|
+
align-items: center;
|
|
256
|
+
justify-content: center;
|
|
257
|
+
`;
|
|
258
|
+
const Detail = ({ label, children }) => /* @__PURE__ */ jsxRuntime.jsxs(DetailItem, { children: [
|
|
259
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dt", variant: "sigma", textColor: "neutral600", children: label }),
|
|
260
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dd", variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children })
|
|
261
|
+
] });
|
|
262
|
+
const describeLicense = (view, t, formatDate) => {
|
|
263
|
+
const notProvided = t("license.value.notProvided", "Not provided");
|
|
264
|
+
return {
|
|
265
|
+
name: holderName(view.details),
|
|
266
|
+
notProvided,
|
|
267
|
+
expiresText: view.details.expiresAt ? formatDate(view.details.expiresAt, { dateStyle: "long" }, notProvided) : t("license.value.never", "Never"),
|
|
268
|
+
activeLabel: view.isActive ? t("license.status.active", "Active") : t("license.status.inactive", "Inactive")
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
const LicenseOverview = ({
|
|
272
|
+
view,
|
|
273
|
+
canUseFullKey,
|
|
274
|
+
revealed,
|
|
275
|
+
alertDismissed,
|
|
276
|
+
onDismissAlert,
|
|
277
|
+
onToggleReveal,
|
|
278
|
+
onCopy,
|
|
279
|
+
onDownload
|
|
280
|
+
}) => {
|
|
281
|
+
const { t } = LicenseGuard.useMagicLinkIntl();
|
|
282
|
+
const { formatDate } = LicenseGuard.useFormatters();
|
|
283
|
+
const { details } = view;
|
|
284
|
+
const { name, notProvided, expiresText, activeLabel } = describeLicense(view, t, formatDate);
|
|
285
|
+
const closeLabel = t("license.alert.close", "Dismiss message");
|
|
286
|
+
const isRevealed = revealed && canUseFullKey;
|
|
287
|
+
const alertProps = {
|
|
288
|
+
active: {
|
|
289
|
+
variant: "success",
|
|
290
|
+
title: t("license.alert.active.title", "License active"),
|
|
291
|
+
body: t(
|
|
292
|
+
"license.alert.active.body",
|
|
293
|
+
"License key registered. Thank you for supporting the plugin."
|
|
294
|
+
)
|
|
295
|
+
},
|
|
296
|
+
unverified: {
|
|
297
|
+
variant: "warning",
|
|
298
|
+
title: t("license.alert.unverified.title", "License not verified"),
|
|
299
|
+
body: t(
|
|
300
|
+
"license.alert.unverified.body",
|
|
301
|
+
"The license server could not be reached. The plugin keeps working. Refresh the status later."
|
|
302
|
+
)
|
|
303
|
+
},
|
|
304
|
+
none: {
|
|
305
|
+
variant: "default",
|
|
306
|
+
title: t("license.alert.none.title", "No license key registered"),
|
|
307
|
+
body: t(
|
|
308
|
+
"license.alert.none.body",
|
|
309
|
+
"All Magic Link features are available without activation."
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
}[view.kind];
|
|
313
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Stack, { children: [
|
|
314
|
+
!alertDismissed && /* @__PURE__ */ jsxRuntime.jsx(
|
|
315
|
+
designSystem.Alert,
|
|
316
|
+
{
|
|
317
|
+
variant: alertProps.variant,
|
|
318
|
+
title: alertProps.title,
|
|
319
|
+
closeLabel,
|
|
320
|
+
onClose: onDismissAlert,
|
|
321
|
+
children: alertProps.body
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
view.maskedKey && /* @__PURE__ */ jsxRuntime.jsx(LicenseKeyBanner, { "aria-labelledby": "magic-link-license-key-label", children: /* @__PURE__ */ jsxRuntime.jsxs(BannerRow, { children: [
|
|
325
|
+
/* @__PURE__ */ jsxRuntime.jsxs(BannerBody, { children: [
|
|
326
|
+
/* @__PURE__ */ jsxRuntime.jsx(BannerLabel, { id: "magic-link-license-key-label", children: t("license.key.label", "License key") }),
|
|
327
|
+
isRevealed ? /* @__PURE__ */ jsxRuntime.jsx(KeyText, { children: view.fullKey }) : /* @__PURE__ */ jsxRuntime.jsxs(KeyText, { children: [
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: view.maskedKey }),
|
|
329
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("license.key.hidden", "License key hidden") })
|
|
330
|
+
] }),
|
|
331
|
+
canUseFullKey && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
332
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
333
|
+
FrostedButton,
|
|
334
|
+
{
|
|
335
|
+
size: "M",
|
|
336
|
+
variant: "secondary",
|
|
337
|
+
onClick: onToggleReveal,
|
|
338
|
+
"aria-pressed": isRevealed,
|
|
339
|
+
startIcon: isRevealed ? /* @__PURE__ */ jsxRuntime.jsx(icons.EyeStriked, { "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, { "aria-hidden": "true" }),
|
|
340
|
+
children: isRevealed ? t("license.key.hide", "Hide key") : t("license.key.show", "Show key")
|
|
341
|
+
}
|
|
342
|
+
),
|
|
343
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
344
|
+
FrostedButton,
|
|
345
|
+
{
|
|
346
|
+
size: "M",
|
|
347
|
+
variant: "secondary",
|
|
348
|
+
onClick: onCopy,
|
|
349
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, { "aria-hidden": "true" }),
|
|
350
|
+
children: t("license.key.copy", "Copy key")
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
354
|
+
FrostedButton,
|
|
355
|
+
{
|
|
356
|
+
size: "M",
|
|
357
|
+
variant: "secondary",
|
|
358
|
+
onClick: onDownload,
|
|
359
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, { "aria-hidden": "true" }),
|
|
360
|
+
children: t("license.key.download", "Download as TXT")
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
] })
|
|
364
|
+
] }),
|
|
365
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
366
|
+
designSystem.Badge,
|
|
367
|
+
{
|
|
368
|
+
size: "M",
|
|
369
|
+
backgroundColor: view.isActive ? "success100" : "danger100",
|
|
370
|
+
textColor: view.isActive ? "success700" : "danger700",
|
|
371
|
+
children: activeLabel
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
] }) }),
|
|
375
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Root, { defaultValue: "account", children: [
|
|
376
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "account", children: [
|
|
377
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { icon: icons.User, children: t("license.section.account", "Account information") }) }),
|
|
378
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(DetailGrid, { children: [
|
|
379
|
+
/* @__PURE__ */ jsxRuntime.jsx(Detail, { label: t("license.field.email", "Email address"), children: details.email || notProvided }),
|
|
380
|
+
/* @__PURE__ */ jsxRuntime.jsx(Detail, { label: t("license.field.holder", "Name"), children: name || notProvided })
|
|
381
|
+
] }) }) })
|
|
382
|
+
] }),
|
|
383
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "details", children: [
|
|
384
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { icon: icons.Shield, children: t("license.section.details", "License details") }) }),
|
|
385
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(DetailGrid, { children: [
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
387
|
+
Detail,
|
|
388
|
+
{
|
|
389
|
+
label: details.isExpired ? t("license.field.expired", "Expired on") : t("license.field.expires", "Expires on"),
|
|
390
|
+
children: expiresText
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
/* @__PURE__ */ jsxRuntime.jsx(Detail, { label: t("license.field.deviceName", "Device name"), children: details.deviceName || notProvided }),
|
|
394
|
+
/* @__PURE__ */ jsxRuntime.jsx(Detail, { label: t("license.field.ipAddress", "IP address"), children: details.ipAddress || notProvided })
|
|
395
|
+
] }) }) })
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "status", children: [
|
|
398
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { icon: icons.ChartBubble, children: t("license.section.status", "System status") }) }),
|
|
399
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(DetailGrid, { children: [
|
|
400
|
+
/* @__PURE__ */ jsxRuntime.jsx(Detail, { label: t("license.field.status", "Status"), children: view.hasKey ? activeLabel : t("license.status.noKey", "No key registered") }),
|
|
401
|
+
/* @__PURE__ */ jsxRuntime.jsx(Detail, { label: t("license.field.mode", "Plugin mode"), children: t("license.mode.unlocked", "All features available") })
|
|
402
|
+
] }) }) })
|
|
403
|
+
] })
|
|
404
|
+
] })
|
|
405
|
+
] });
|
|
406
|
+
};
|
|
407
|
+
const LicenseView = () => {
|
|
408
|
+
const { get } = strapiAdmin.useFetchClient();
|
|
409
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
410
|
+
const { t } = LicenseGuard.useMagicLinkIntl();
|
|
411
|
+
const { formatDate, formatDateTime } = LicenseGuard.useFormatters();
|
|
412
|
+
const copy = LicenseGuard.useCopyToClipboard();
|
|
413
|
+
const {
|
|
414
|
+
canReadSettings,
|
|
415
|
+
canUpdateSettings,
|
|
416
|
+
isLoading: rbacLoading,
|
|
417
|
+
error: rbacError
|
|
418
|
+
} = LicenseGuard.useMagicLinkRBAC();
|
|
419
|
+
const [status, setStatus] = react.useState("loading");
|
|
420
|
+
const [licenseData, setLicenseData] = react.useState(null);
|
|
421
|
+
const [loadError, setLoadError] = react.useState(null);
|
|
422
|
+
const [isRefreshing, setIsRefreshing] = react.useState(true);
|
|
423
|
+
const [revealed, setRevealed] = react.useState(false);
|
|
424
|
+
const [alertDismissed, setAlertDismissed] = react.useState(false);
|
|
425
|
+
const requestRef = react.useRef(null);
|
|
426
|
+
const loadLicenseStatus = react.useCallback(async () => {
|
|
427
|
+
requestRef.current?.abort();
|
|
428
|
+
const controller = new AbortController();
|
|
429
|
+
requestRef.current = controller;
|
|
430
|
+
try {
|
|
431
|
+
const response = await get("/magic-link/license/status", { signal: controller.signal });
|
|
432
|
+
if (controller.signal.aborted) return;
|
|
433
|
+
setLicenseData(response.data);
|
|
434
|
+
setLoadError(null);
|
|
435
|
+
setStatus("ready");
|
|
436
|
+
} catch (err) {
|
|
437
|
+
if (controller.signal.aborted) return;
|
|
438
|
+
setLoadError({ status: err?.status ?? err?.response?.status });
|
|
439
|
+
setStatus("error");
|
|
440
|
+
} finally {
|
|
441
|
+
if (requestRef.current === controller) {
|
|
442
|
+
requestRef.current = null;
|
|
443
|
+
setIsRefreshing(false);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}, [get]);
|
|
447
|
+
const refreshLicenseStatus = react.useCallback(() => {
|
|
448
|
+
setIsRefreshing(true);
|
|
449
|
+
setRevealed(false);
|
|
450
|
+
setAlertDismissed(false);
|
|
451
|
+
return loadLicenseStatus();
|
|
452
|
+
}, [loadLicenseStatus]);
|
|
453
|
+
react.useEffect(() => {
|
|
454
|
+
if (!canReadSettings) return void 0;
|
|
455
|
+
const load = async () => {
|
|
456
|
+
await loadLicenseStatus();
|
|
457
|
+
};
|
|
458
|
+
load();
|
|
459
|
+
return () => requestRef.current?.abort();
|
|
460
|
+
}, [canReadSettings, loadLicenseStatus]);
|
|
461
|
+
const pageTitle = /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard.PluginPageTitle, { children: t("license.pageTitle", "License") });
|
|
462
|
+
if (rbacLoading) {
|
|
463
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
464
|
+
pageTitle,
|
|
465
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, { children: t("common.loading", "Loading...") })
|
|
466
|
+
] });
|
|
467
|
+
}
|
|
468
|
+
if (rbacError) {
|
|
469
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
470
|
+
pageTitle,
|
|
471
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
472
|
+
strapiAdmin.Page.Error,
|
|
473
|
+
{
|
|
474
|
+
content: t(
|
|
475
|
+
"common.permissions.loadError",
|
|
476
|
+
"Your permissions could not be loaded. Reload the page to try again."
|
|
477
|
+
)
|
|
478
|
+
}
|
|
479
|
+
)
|
|
480
|
+
] });
|
|
481
|
+
}
|
|
482
|
+
if (!canReadSettings) {
|
|
483
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
484
|
+
pageTitle,
|
|
485
|
+
/* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.NoPermissions, {})
|
|
486
|
+
] });
|
|
487
|
+
}
|
|
488
|
+
const view = getLicenseView(licenseData);
|
|
489
|
+
const canUseFullKey = canUpdateSettings && Boolean(view.fullKey);
|
|
490
|
+
const handleCopyLicenseKey = async () => {
|
|
491
|
+
if (!canUseFullKey) return;
|
|
492
|
+
await copy(view.fullKey, { success: t("license.copy.success", "License key copied") });
|
|
493
|
+
};
|
|
494
|
+
const handleDownloadLicenseKey = () => {
|
|
495
|
+
if (!canUseFullKey) return;
|
|
496
|
+
const { name, notProvided, expiresText, activeLabel } = describeLicense(view, t, formatDate);
|
|
497
|
+
let url = null;
|
|
498
|
+
try {
|
|
499
|
+
const content = buildLicenseFileContent(
|
|
500
|
+
{
|
|
501
|
+
key: view.fullKey,
|
|
502
|
+
name: name || notProvided,
|
|
503
|
+
email: view.details.email || notProvided,
|
|
504
|
+
status: activeLabel,
|
|
505
|
+
expires: expiresText,
|
|
506
|
+
generated: formatDateTime(/* @__PURE__ */ new Date())
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
title: t("license.file.title", "Magic Link plugin license key"),
|
|
510
|
+
key: t("license.key.label", "License key"),
|
|
511
|
+
holder: t("license.file.holder", "License holder"),
|
|
512
|
+
name: t("license.field.holder", "Name"),
|
|
513
|
+
email: t("license.field.email", "Email address"),
|
|
514
|
+
statusSection: t("license.file.statusSection", "License status"),
|
|
515
|
+
status: t("license.field.status", "Status"),
|
|
516
|
+
expires: t("license.field.expires", "Expires on"),
|
|
517
|
+
generated: t("license.file.generated", "Generated")
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
|
|
521
|
+
url = window.URL.createObjectURL(blob);
|
|
522
|
+
const link = document.createElement("a");
|
|
523
|
+
link.href = url;
|
|
524
|
+
link.download = LICENSE_FILE_NAME;
|
|
525
|
+
document.body.appendChild(link);
|
|
526
|
+
link.click();
|
|
527
|
+
document.body.removeChild(link);
|
|
528
|
+
toggleNotification({
|
|
529
|
+
type: "success",
|
|
530
|
+
message: t("license.download.success", "License file downloaded")
|
|
531
|
+
});
|
|
532
|
+
} catch {
|
|
533
|
+
toggleNotification({
|
|
534
|
+
type: "danger",
|
|
535
|
+
message: t("license.download.error", "The license file could not be downloaded.")
|
|
536
|
+
});
|
|
537
|
+
} finally {
|
|
538
|
+
if (url) {
|
|
539
|
+
const objectUrl = url;
|
|
540
|
+
window.setTimeout(() => window.URL.revokeObjectURL(objectUrl), 0);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
const renderBody = () => {
|
|
545
|
+
if (status === "loading") {
|
|
546
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LoaderArea, { "aria-busy": "true", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("license.loading", "Loading license information...") }) });
|
|
547
|
+
}
|
|
548
|
+
if (status === "error") {
|
|
549
|
+
if (alertDismissed) return null;
|
|
550
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
551
|
+
designSystem.Alert,
|
|
552
|
+
{
|
|
553
|
+
variant: "danger",
|
|
554
|
+
title: t("license.error.title", "License unavailable"),
|
|
555
|
+
closeLabel: t("license.alert.close", "Dismiss message"),
|
|
556
|
+
onClose: () => setAlertDismissed(true),
|
|
557
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
558
|
+
designSystem.Button,
|
|
559
|
+
{
|
|
560
|
+
variant: "danger-light",
|
|
561
|
+
size: "S",
|
|
562
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, { "aria-hidden": "true" }),
|
|
563
|
+
onClick: refreshLicenseStatus,
|
|
564
|
+
loading: isRefreshing,
|
|
565
|
+
children: t("license.retry", "Try again")
|
|
566
|
+
}
|
|
567
|
+
),
|
|
568
|
+
children: licenseErrorMessage(loadError, t)
|
|
569
|
+
}
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
573
|
+
LicenseOverview,
|
|
574
|
+
{
|
|
575
|
+
view,
|
|
576
|
+
canUseFullKey,
|
|
577
|
+
revealed,
|
|
578
|
+
alertDismissed,
|
|
579
|
+
onDismissAlert: () => setAlertDismissed(true),
|
|
580
|
+
onToggleReveal: () => setRevealed((current) => !current),
|
|
581
|
+
onCopy: handleCopyLicenseKey,
|
|
582
|
+
onDownload: handleDownloadLicenseKey
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
};
|
|
586
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Page.Main, { children: [
|
|
587
|
+
pageTitle,
|
|
588
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Container, { children: [
|
|
589
|
+
/* @__PURE__ */ jsxRuntime.jsx(StickyHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(HeaderRow, { children: [
|
|
590
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, children: [
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h1", variant: "alpha", textColor: "neutral800", children: t("license.title", "License management") }),
|
|
592
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: t("license.subtitle", "View the license of your Magic Link plugin") })
|
|
593
|
+
] }),
|
|
594
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
595
|
+
GradientButton,
|
|
596
|
+
{
|
|
597
|
+
size: "L",
|
|
598
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, { "aria-hidden": "true" }),
|
|
599
|
+
onClick: refreshLicenseStatus,
|
|
600
|
+
loading: isRefreshing && status !== "loading",
|
|
601
|
+
disabled: status === "loading",
|
|
602
|
+
children: t("license.refresh", "Refresh status")
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
] }) }),
|
|
606
|
+
/* @__PURE__ */ jsxRuntime.jsx(Content, { "aria-busy": isRefreshing ? "true" : void 0, children: renderBody() })
|
|
607
|
+
] })
|
|
608
|
+
] });
|
|
609
|
+
};
|
|
610
|
+
const LicensePage = () => /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard.LicenseGuard, { children: /* @__PURE__ */ jsxRuntime.jsx(LicenseGuard.LanguageProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(LicenseView, {}) }) });
|
|
611
|
+
exports.LICENSE_FILE_NAME = LICENSE_FILE_NAME;
|
|
612
|
+
exports.LicenseOverview = LicenseOverview;
|
|
613
|
+
exports.LicenseView = LicenseView;
|
|
614
|
+
exports.MASK_CHAR = MASK_CHAR;
|
|
615
|
+
exports.buildLicenseFileContent = buildLicenseFileContent;
|
|
616
|
+
exports.default = LicensePage;
|
|
617
|
+
exports.describeLicense = describeLicense;
|
|
618
|
+
exports.getLicenseView = getLicenseView;
|
|
619
|
+
exports.holderName = holderName;
|
|
620
|
+
exports.isMaskedKey = isMaskedKey;
|
|
621
|
+
exports.licenseErrorMessage = licenseErrorMessage;
|
|
622
|
+
exports.maskLicenseKey = maskLicenseKey;
|