strapi-plugin-magic-sessionmanager 4.22.1 → 4.23.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +116 -82
  3. package/dist/admin/ActiveImpersonationsCard-CbyOAlrL.mjs +396 -0
  4. package/dist/admin/ActiveImpersonationsCard-D1CVmV-w.js +395 -0
  5. package/dist/admin/{Analytics-CIHgaURb.mjs → Analytics-DGAHD19E.mjs} +1 -1
  6. package/dist/admin/{Analytics-B7BAjApz.js → Analytics-_WA68oHb.js} +1 -1
  7. package/dist/admin/{App-DJkJC06E.js → App-CfhAQ17e.js} +304 -104
  8. package/dist/admin/{App-CPE-CQGz.mjs → App-VB66H73A.mjs} +276 -76
  9. package/dist/admin/ImpersonationTabBanner-B6Ps5-oe.mjs +244 -0
  10. package/dist/admin/ImpersonationTabBanner-DdwXNmh4.js +244 -0
  11. package/dist/admin/{OnlineUsersWidget-Dou2hxGY.mjs → OnlineUsersWidget-2u-fYMb7.mjs} +1 -1
  12. package/dist/admin/{OnlineUsersWidget-CcjNfzzf.js → OnlineUsersWidget-CmBqFLAA.js} +1 -1
  13. package/dist/admin/{Settings--eEiHv_a.js → Settings-BBs2FDp7.js} +27 -229
  14. package/dist/admin/{Settings-h_exWUiI.mjs → Settings-CKDNGJhl.mjs} +19 -221
  15. package/dist/admin/{de-Wz5Emtrb.mjs → de-CK-HuY41.mjs} +42 -4
  16. package/dist/admin/{de-oBmcAcXj.js → de-CSRQPn6F.js} +42 -4
  17. package/dist/admin/{en-B1TN5F62.js → en-DCtAgGEa.js} +42 -4
  18. package/dist/admin/{en-B_1Ka64U.mjs → en-KZ5ajaAR.mjs} +42 -4
  19. package/dist/admin/{es-CVgw4zsj.mjs → es-B7k8taWV.mjs} +42 -4
  20. package/dist/admin/{es-Bb515J0p.js → es-CKT00l4K.js} +42 -4
  21. package/dist/admin/{fr-yDdwunmg.js → fr-B2EdBFSb.js} +42 -4
  22. package/dist/admin/{fr-0AgMxTFc.mjs → fr-Q2gmYqCn.mjs} +42 -4
  23. package/dist/admin/{index-DVQ7tdTC.mjs → index-BPbs1GyP.mjs} +365 -57
  24. package/dist/admin/{index-qtN2dOm4.js → index-Cho0XGZ1.js} +319 -11
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +2 -2
  27. package/dist/admin/{pt-BAB07LY-.js → pt-CcMUcqDy.js} +42 -4
  28. package/dist/admin/{pt-DtM74ffN.mjs → pt-CmxZTaf2.mjs} +42 -4
  29. package/dist/admin/useBreakpoint-CoBfu0Ov.js +62 -0
  30. package/dist/admin/useBreakpoint-CuyIc2qy.mjs +63 -0
  31. package/dist/server/index.js +867 -10
  32. package/dist/server/index.mjs +867 -10
  33. package/package.json +6 -2
  34. package/dist/admin/dashboardModel-DNT_l-Bk.js +0 -169
  35. package/dist/admin/dashboardModel-fApbKGay.mjs +0 -170
@@ -1083,7 +1083,13 @@ const pluginPermissions = {
1083
1083
  * admin. The server also requires `access`, the switch and the
1084
1084
  * anti-escalation rules.
1085
1085
  */
1086
- impersonateAdmins: [{ action: `plugin::${pluginId$1}.impersonate.admins`, subject: null }]
1086
+ impersonateAdmins: [{ action: `plugin::${pluginId$1}.impersonate.admins`, subject: null }],
1087
+ /**
1088
+ * "Sign in as this admin" (4.23): a real admin session of another admin in
1089
+ * a separate tab. The server also requires `access`, the switch, a tested
1090
+ * Strapi release and the anti-escalation rules.
1091
+ */
1092
+ signInAsAdmin: [{ action: `plugin::${pluginId$1}.impersonate.admins.sign-in`, subject: null }]
1087
1093
  };
1088
1094
  const SAFE_SCOPE = /^[A-Za-z0-9_.:-]{1,48}$/;
1089
1095
  const CANCEL_NAMES = /* @__PURE__ */ new Set(["AbortError", "TimeoutError", "CanceledError"]);
@@ -2021,7 +2027,13 @@ function getRevealScrollDelta(listRect, tabRect) {
2021
2027
  if (tabRect.right > listRect.right + 0.5) return Math.round(tabRect.right - listRect.right);
2022
2028
  return 0;
2023
2029
  }
2024
- const SIGN_IN_FILTER_OPTIONS = Object.freeze(["all", "succeeded", "failed", "signed-out"]);
2030
+ const SIGN_IN_FILTER_OPTIONS = Object.freeze([
2031
+ "all",
2032
+ "succeeded",
2033
+ "failed",
2034
+ "signed-out",
2035
+ "impersonation"
2036
+ ]);
2025
2037
  const ALL_ADMINS_FILTER_OPTIONS = Object.freeze([...SIGN_IN_FILTER_OPTIONS, "changes"]);
2026
2038
  const ACTIVITY_ACTION_OPTIONS = Object.freeze([
2027
2039
  "all",
@@ -2290,6 +2302,14 @@ function getEventPresentation(row) {
2290
2302
  "adminPanel.activity.event.impersonationExpired",
2291
2303
  "Impersonation timed out"
2292
2304
  );
2305
+ case "impersonation.write":
2306
+ return appUserEvent(
2307
+ "impersonation-write",
2308
+ "warning",
2309
+ "impersonation",
2310
+ "adminPanel.activity.event.impersonationWrite",
2311
+ "Change made while signed in as this admin"
2312
+ );
2293
2313
  case "impersonation.refused":
2294
2314
  return appUserEvent(
2295
2315
  "impersonation-refused",
@@ -4527,6 +4547,290 @@ const SessionInfoPanel = ({ documentId, model, document: document2 }) => {
4527
4547
  )
4528
4548
  };
4529
4549
  };
4550
+ const TAB_STATE_KEY = "magic-sessionmanager.admin-impersonation";
4551
+ const LANDING_PATH = "/plugins/magic-sessionmanager/impersonate/land";
4552
+ const CODE_PATTERN = /^[A-Za-z0-9_-]{43}$/;
4553
+ const COOKIE_NAME_PATTERN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]{1,64}$/;
4554
+ const TOKEN_KEY = "jwtToken";
4555
+ const STATUS_KEY = "isLoggedIn";
4556
+ function readTabState(win) {
4557
+ try {
4558
+ const raw = win.sessionStorage.getItem(TAB_STATE_KEY);
4559
+ const value = raw ? JSON.parse(raw) : null;
4560
+ return value && typeof value === "object" && typeof value.phase === "string" ? value : null;
4561
+ } catch {
4562
+ return null;
4563
+ }
4564
+ }
4565
+ function writeTabState(win, state) {
4566
+ try {
4567
+ if (state) win.sessionStorage.setItem(TAB_STATE_KEY, JSON.stringify(state));
4568
+ else win.sessionStorage.removeItem(TAB_STATE_KEY);
4569
+ } catch {
4570
+ }
4571
+ }
4572
+ function landingBase(pathname) {
4573
+ const path = String(pathname || "").replace(/\/+$/, "");
4574
+ if (!path.endsWith(LANDING_PATH)) return null;
4575
+ return path.slice(0, path.length - LANDING_PATH.length);
4576
+ }
4577
+ function parseLandingHash(hash) {
4578
+ const params = new URLSearchParams(String(hash || "").replace(/^#/, ""));
4579
+ const code = params.get("code") || "";
4580
+ const cookieName = params.get("c") || "jwtToken";
4581
+ if (!CODE_PATTERN.test(code) || !COOKIE_NAME_PATTERN.test(cookieName)) return null;
4582
+ return { code, cookieName };
4583
+ }
4584
+ function landingUrl(adminBase2, handoff) {
4585
+ const params = new URLSearchParams({ code: handoff.code, c: handoff.cookieName || "jwtToken" });
4586
+ return `${String(adminBase2 || "").replace(/\/+$/, "")}${LANDING_PATH}#${params.toString()}`;
4587
+ }
4588
+ function cookieValue(cookies, name2) {
4589
+ let result = null;
4590
+ for (const part of String(cookies || "").split(";")) {
4591
+ const index2 = part.indexOf("=");
4592
+ if (index2 < 0) continue;
4593
+ if (part.slice(0, index2).trim() === name2) {
4594
+ try {
4595
+ result = decodeURIComponent(part.slice(index2 + 1).trim());
4596
+ } catch {
4597
+ result = null;
4598
+ }
4599
+ }
4600
+ }
4601
+ return result;
4602
+ }
4603
+ function withoutCookie(cookies, name2) {
4604
+ return String(cookies || "").split(";").filter((part) => part.split("=")[0].trim() !== name2 && part.trim() !== "").map((part) => part.trim()).join("; ");
4605
+ }
4606
+ function readRealToken(win, cookieName) {
4607
+ try {
4608
+ const stored = win.localStorage.getItem(TOKEN_KEY);
4609
+ if (stored) return JSON.parse(stored);
4610
+ } catch {
4611
+ }
4612
+ try {
4613
+ return cookieValue(win.document.cookie, cookieName);
4614
+ } catch {
4615
+ return null;
4616
+ }
4617
+ }
4618
+ function pathOf(win, input) {
4619
+ try {
4620
+ const url = typeof input === "string" ? input : input instanceof URL ? input.href : input?.url || "";
4621
+ return new URL(url, win.location.href).pathname.replace(/\/+$/, "");
4622
+ } catch {
4623
+ return null;
4624
+ }
4625
+ }
4626
+ function jsonResponse(win, status, body) {
4627
+ return new win.Response(JSON.stringify(body), {
4628
+ status,
4629
+ headers: { "Content-Type": "application/json" }
4630
+ });
4631
+ }
4632
+ function installTabShim(win, hooks = {}) {
4633
+ if (win.__msmImpersonationShim) return false;
4634
+ win.__msmImpersonationShim = true;
4635
+ const localStore = win.localStorage;
4636
+ const proto = win.Storage.prototype;
4637
+ const original = {
4638
+ getItem: proto.getItem,
4639
+ setItem: proto.setItem,
4640
+ removeItem: proto.removeItem
4641
+ };
4642
+ const shadowed = (store, key) => store === localStore && (key === TOKEN_KEY || key === STATUS_KEY) && readTabState(win) !== null;
4643
+ proto.getItem = function getItem(key) {
4644
+ if (shadowed(this, key)) {
4645
+ const state = readTabState(win);
4646
+ const active = state?.phase === "active" && typeof state.token === "string";
4647
+ if (key === TOKEN_KEY) return active ? JSON.stringify(state.token) : null;
4648
+ return active ? "true" : null;
4649
+ }
4650
+ return original.getItem.call(this, key);
4651
+ };
4652
+ proto.setItem = function setItem(key, value) {
4653
+ if (shadowed(this, key)) return void 0;
4654
+ return original.setItem.call(this, key, value);
4655
+ };
4656
+ proto.removeItem = function removeItem(key) {
4657
+ if (shadowed(this, key)) return void 0;
4658
+ return original.removeItem.call(this, key);
4659
+ };
4660
+ const cookieName = () => readTabState(win)?.cookieName || "jwtToken";
4661
+ const descriptor = Object.getOwnPropertyDescriptor(win.Document.prototype, "cookie");
4662
+ if (descriptor?.get && descriptor?.set) {
4663
+ Object.defineProperty(win.document, "cookie", {
4664
+ configurable: true,
4665
+ get() {
4666
+ const raw = descriptor.get.call(win.document);
4667
+ return readTabState(win) ? withoutCookie(raw, cookieName()) : raw;
4668
+ },
4669
+ set(value) {
4670
+ if (readTabState(win) && String(value).trim().startsWith(`${cookieName()}=`)) return;
4671
+ descriptor.set.call(win.document, value);
4672
+ }
4673
+ });
4674
+ }
4675
+ const originalFetch = win.fetch.bind(win);
4676
+ win.fetch = async (input, init) => {
4677
+ if (!readTabState(win)) return originalFetch(input, init);
4678
+ const path = pathOf(win, input) || "";
4679
+ if (/\/admin\/access-token$/.test(path)) {
4680
+ return jsonResponse(win, 401, {
4681
+ data: null,
4682
+ error: {
4683
+ status: 401,
4684
+ name: "UnauthorizedError",
4685
+ message: "An impersonation is not renewed",
4686
+ details: {}
4687
+ }
4688
+ });
4689
+ }
4690
+ if (/\/admin\/(login|register|register-admin|forgot-password|reset-password)$/.test(path)) {
4691
+ return jsonResponse(win, 403, {
4692
+ data: null,
4693
+ error: {
4694
+ status: 403,
4695
+ name: "ForbiddenError",
4696
+ message: "Not available in an impersonation tab",
4697
+ details: {}
4698
+ }
4699
+ });
4700
+ }
4701
+ if (/\/admin\/logout$/.test(path)) {
4702
+ hooks.onLogout?.();
4703
+ return jsonResponse(win, 200, { data: {} });
4704
+ }
4705
+ return originalFetch(input, init);
4706
+ };
4707
+ return true;
4708
+ }
4709
+ let landingCredential = null;
4710
+ let adminBase = null;
4711
+ let started = false;
4712
+ const backendURL = () => String(window.strapi?.backendURL || window.location.origin);
4713
+ const adminPath = () => {
4714
+ if (adminBase !== null) return adminBase;
4715
+ const stored = readTabState(window)?.adminBase;
4716
+ return typeof stored === "string" && /^(\/[A-Za-z0-9._~-]+)*$/.test(stored) ? stored : "/admin";
4717
+ };
4718
+ function markEnded(reason) {
4719
+ const state = readTabState(window);
4720
+ if (!state) return;
4721
+ writeTabState(window, {
4722
+ phase: state.phase === "landing" ? "failed" : "ended",
4723
+ cookieName: state.cookieName,
4724
+ adminBase: state.adminBase,
4725
+ impersonation: state.impersonation,
4726
+ reason
4727
+ });
4728
+ window.dispatchEvent(new Event("msm-impersonation-change"));
4729
+ }
4730
+ async function endImpersonation(reason = "ended") {
4731
+ const state = readTabState(window);
4732
+ if (state?.phase === "active" && state.token) {
4733
+ try {
4734
+ await window.fetch(`${backendURL()}/magic-sessionmanager/admin-impersonation/self/end`, {
4735
+ method: "POST",
4736
+ headers: { Authorization: `Bearer ${state.token}`, Accept: "application/json" }
4737
+ });
4738
+ } catch {
4739
+ }
4740
+ }
4741
+ markEnded(reason);
4742
+ }
4743
+ function leaveImpersonationTab() {
4744
+ writeTabState(window, null);
4745
+ window.location.replace(`${adminPath()}/`);
4746
+ }
4747
+ function bootImpersonationTab() {
4748
+ if (typeof window === "undefined" || !window.sessionStorage) return;
4749
+ const base = landingBase(window.location.pathname);
4750
+ if (base !== null) {
4751
+ adminBase = base;
4752
+ const handoff = parseLandingHash(window.location.hash);
4753
+ window.history.replaceState(null, "", window.location.pathname);
4754
+ if (handoff && readTabState(window)?.phase !== "active") {
4755
+ landingCredential = readRealToken(window, handoff.cookieName);
4756
+ writeTabState(window, {
4757
+ phase: "landing",
4758
+ code: handoff.code,
4759
+ cookieName: handoff.cookieName,
4760
+ adminBase: base
4761
+ });
4762
+ }
4763
+ }
4764
+ const state = readTabState(window);
4765
+ if (!state) return;
4766
+ installTabShim(window, {
4767
+ onLogout: () => {
4768
+ endImpersonation("ended");
4769
+ }
4770
+ });
4771
+ }
4772
+ async function completeLanding() {
4773
+ const state = readTabState(window);
4774
+ if (state?.phase !== "landing") return;
4775
+ const credential = landingCredential;
4776
+ landingCredential = null;
4777
+ let data = null;
4778
+ if (credential && state.code) {
4779
+ try {
4780
+ const response = await window.fetch(
4781
+ `${backendURL()}/magic-sessionmanager/admin-impersonation/exchange`,
4782
+ {
4783
+ method: "POST",
4784
+ headers: {
4785
+ Authorization: `Bearer ${credential}`,
4786
+ "Content-Type": "application/json",
4787
+ Accept: "application/json"
4788
+ },
4789
+ body: JSON.stringify({ code: state.code })
4790
+ }
4791
+ );
4792
+ if (response.ok) data = (await response.json())?.data || null;
4793
+ } catch {
4794
+ data = null;
4795
+ }
4796
+ }
4797
+ if (!data?.token) {
4798
+ writeTabState(window, {
4799
+ phase: "failed",
4800
+ cookieName: state.cookieName,
4801
+ adminBase: state.adminBase,
4802
+ reason: "exchange"
4803
+ });
4804
+ window.dispatchEvent(new Event("msm-impersonation-change"));
4805
+ return;
4806
+ }
4807
+ writeTabState(window, {
4808
+ phase: "active",
4809
+ token: data.token,
4810
+ expiresAt: data.expiresAt,
4811
+ cookieName: data.cookieName || state.cookieName,
4812
+ adminBase: state.adminBase,
4813
+ impersonation: data.impersonation
4814
+ });
4815
+ window.location.replace(`${adminPath()}/`);
4816
+ }
4817
+ function startImpersonationTab() {
4818
+ if (started || typeof window === "undefined") return;
4819
+ const state = readTabState(window);
4820
+ if (!state) return;
4821
+ started = true;
4822
+ if (state.phase === "landing") completeLanding();
4823
+ Promise.resolve().then(() => require("./ImpersonationTabBanner-DdwXNmh4.js")).then(
4824
+ ({ mountImpersonationBanner }) => mountImpersonationBanner({
4825
+ end: endImpersonation,
4826
+ leave: leaveImpersonationTab,
4827
+ markEnded,
4828
+ backendURL
4829
+ })
4830
+ ).catch(() => {
4831
+ });
4832
+ }
4833
+ bootImpersonationTab();
4530
4834
  const prefixPluginTranslations = (data, pluginId2) => {
4531
4835
  const prefixed = {};
4532
4836
  Object.keys(data).forEach((key) => {
@@ -4538,6 +4842,7 @@ const name = pluginPkg.strapi.name;
4538
4842
  const index = {
4539
4843
  register(app) {
4540
4844
  const pluginPermissions$1 = pluginPermissions.access;
4845
+ startImpersonationTab();
4541
4846
  app.addMenuLink({
4542
4847
  to: `plugins/${pluginId$1}`,
4543
4848
  icon: PluginIcon,
@@ -4545,7 +4850,7 @@ const index = {
4545
4850
  id: `${pluginId$1}.plugin.name`,
4546
4851
  defaultMessage: pluginPkg.strapi.displayName
4547
4852
  },
4548
- Component: () => Promise.resolve().then(() => require("./App-DJkJC06E.js")),
4853
+ Component: () => Promise.resolve().then(() => require("./App-CfhAQ17e.js")),
4549
4854
  permissions: pluginPermissions$1
4550
4855
  });
4551
4856
  app.addSettingsLink(
@@ -4561,7 +4866,7 @@ const index = {
4561
4866
  },
4562
4867
  id: "general",
4563
4868
  to: `${pluginId$1}/general`,
4564
- Component: () => Promise.resolve().then(() => require("./Settings--eEiHv_a.js")),
4869
+ Component: () => Promise.resolve().then(() => require("./Settings-BBs2FDp7.js")),
4565
4870
  permissions: pluginPermissions$1
4566
4871
  },
4567
4872
  {
@@ -4571,7 +4876,7 @@ const index = {
4571
4876
  },
4572
4877
  id: "analytics",
4573
4878
  to: `${pluginId$1}/analytics`,
4574
- Component: () => Promise.resolve().then(() => require("./Analytics-B7BAjApz.js")),
4879
+ Component: () => Promise.resolve().then(() => require("./Analytics-_WA68oHb.js")),
4575
4880
  permissions: pluginPermissions$1
4576
4881
  }
4577
4882
  ]
@@ -4597,7 +4902,7 @@ const index = {
4597
4902
  href: `/plugins/${pluginId$1}`
4598
4903
  },
4599
4904
  component: async () => {
4600
- const component = await Promise.resolve().then(() => require("./OnlineUsersWidget-CcjNfzzf.js"));
4905
+ const component = await Promise.resolve().then(() => require("./OnlineUsersWidget-CmBqFLAA.js"));
4601
4906
  return component.default;
4602
4907
  },
4603
4908
  id: "online-users-widget",
@@ -4618,11 +4923,11 @@ const index = {
4618
4923
  },
4619
4924
  async registerTrads({ locales }) {
4620
4925
  const importedTrads = {
4621
- en: () => Promise.resolve().then(() => require("./en-B1TN5F62.js")),
4622
- de: () => Promise.resolve().then(() => require("./de-oBmcAcXj.js")),
4623
- es: () => Promise.resolve().then(() => require("./es-Bb515J0p.js")),
4624
- fr: () => Promise.resolve().then(() => require("./fr-yDdwunmg.js")),
4625
- pt: () => Promise.resolve().then(() => require("./pt-BAB07LY-.js"))
4926
+ en: () => Promise.resolve().then(() => require("./en-DCtAgGEa.js")),
4927
+ de: () => Promise.resolve().then(() => require("./de-CSRQPn6F.js")),
4928
+ es: () => Promise.resolve().then(() => require("./es-CKT00l4K.js")),
4929
+ fr: () => Promise.resolve().then(() => require("./fr-B2EdBFSb.js")),
4930
+ pt: () => Promise.resolve().then(() => require("./pt-CcMUcqDy.js"))
4626
4931
  };
4627
4932
  const translatedLanguages = Object.keys(importedTrads).filter((lang) => locales.includes(lang));
4628
4933
  const translations = await Promise.all(
@@ -4721,6 +5026,7 @@ exports.isCancelledRequest = isCancelledRequest;
4721
5026
  exports.isEndReasonFilter = isEndReasonFilter;
4722
5027
  exports.isNativeOnlySession = isNativeOnlySession;
4723
5028
  exports.isSessionFilter = isSessionFilter;
5029
+ exports.landingUrl = landingUrl;
4724
5030
  exports.logSafeAdminError = logSafeAdminError;
4725
5031
  exports.normalizeDeviceType = normalizeDeviceType;
4726
5032
  exports.parseActivityPageQuery = parseActivityPageQuery;
@@ -4729,11 +5035,13 @@ exports.parseUserActivityQuery = parseUserActivityQuery;
4729
5035
  exports.pluginId = pluginId$1;
4730
5036
  exports.pluginPermissions = pluginPermissions;
4731
5037
  exports.presentText = presentText;
5038
+ exports.readTabState = readTabState;
4732
5039
  exports.refocusIfLost = refocusIfLost;
4733
5040
  exports.requireSessionList = requireSessionList;
4734
5041
  exports.requireSuccessfulMutation = requireSuccessfulMutation;
4735
5042
  exports.resolveSettingsTab = resolveSettingsTab;
4736
5043
  exports.restoreDialogFocus = restoreDialogFocus;
5044
+ exports.secondsUntil = secondsUntil;
4737
5045
  exports.splitDuration = splitDuration;
4738
5046
  exports.toValidDate = toValidDate;
4739
5047
  exports.useElementWidth = useElementWidth;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-qtN2dOm4.js");
3
+ const index = require("./index-Cho0XGZ1.js");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { aP } from "./index-DVQ7tdTC.mjs";
1
+ import { aS } from "./index-BPbs1GyP.mjs";
2
2
  export {
3
- aP as default
3
+ aS as default
4
4
  };
@@ -1086,7 +1086,7 @@ const pt = {
1086
1086
  "impersonation.preview.conditions": "{action}: somente {conditions}",
1087
1087
  "impersonation.preview.error.start": "Não foi possível abrir a prévia.",
1088
1088
  "impersonation.preview.ended": "Prévia encerrada.",
1089
- "impersonation.preview.title": "Ver como {name}",
1089
+ "impersonation.preview.title": "Permissões de {name}",
1090
1090
  "impersonation.preview.intro": "Veja quais tipos de conteúdo e ações este admin pode usar, com base nas funções dele. Somente leitura: ninguém faz login e nada pode ser alterado. Isso é registrado no registro de segurança.",
1091
1091
  "impersonation.preview.reason.hint": "Fica no registro de segurança.",
1092
1092
  "impersonation.preview.banner.ended": "A prévia terminou.",
@@ -1098,8 +1098,6 @@ const pt = {
1098
1098
  "impersonation.preview.other": "Outras permissões",
1099
1099
  "impersonation.preview.close": "Encerrar e fechar",
1100
1100
  "impersonation.preview.start": "Ver permissões",
1101
- "adminPanel.actions.viewAs": "Ver como {name}",
1102
- "adminPanel.actions.viewAsShort": "Ver como",
1103
1101
  "adminPanel.activity.event.impersonationStarted": "Acesso como usuário iniciado",
1104
1102
  "adminPanel.activity.event.impersonationEnded": "Acesso como usuário encerrado",
1105
1103
  "adminPanel.activity.event.impersonationExpired": "Acesso como usuário expirado",
@@ -1169,6 +1167,46 @@ const pt = {
1169
1167
  "userActivity.panel.title": "Atividade de segurança",
1170
1168
  "userActivity.recent.empty": "Ainda não há eventos de segurança de usuários do aplicativo.",
1171
1169
  "userActivity.recent.subtitle": "Os últimos acessos com falha e recusados, bloqueios, novos dispositivos, viagens impossíveis e acessos como usuário dos usuários do seu aplicativo. Selecione um evento para ver os detalhes.",
1172
- "userActivity.recent.title": "Atividade de segurança"
1170
+ "userActivity.recent.title": "Atividade de segurança",
1171
+ "impersonation.tab.banner.signedInAs": "Sessão iniciada como {name}",
1172
+ "impersonation.tab.banner.changes": "Alterações permitidas",
1173
+ "impersonation.tab.banner.readOnly": "Só leitura",
1174
+ "impersonation.tab.banner.endsIn": "Termina em {time}",
1175
+ "impersonation.tab.banner.end": "Terminar personificação",
1176
+ "impersonation.tab.landing.title": "A iniciar sessão como outro administrador…",
1177
+ "impersonation.tab.failed.title": "O início de sessão não funcionou",
1178
+ "impersonation.tab.failed.body": "A ligação já foi usada ou tem mais de um minuto. Comece de novo na página Painel de administração do Session Manager.",
1179
+ "impersonation.tab.ended.expiredTitle": "A personificação expirou",
1180
+ "impersonation.tab.ended.title": "A personificação terminou",
1181
+ "impersonation.tab.ended.body": "Já não tem sessão iniciada como {name}. Os seus outros separadores não foram afetados. Pode fechar este separador.",
1182
+ "impersonation.tab.backToMyAdmin": "Voltar ao meu painel de administração",
1183
+ "impersonation.tab.close": "Fechar separador",
1184
+ "impersonation.signIn.unsupported.lifespan": "Indisponível: a duração do token de acesso de administração é inferior a 15 minutos.",
1185
+ "impersonation.signIn.unsupported.version": "Indisponível no Strapi {version}: esta versão do plugin foi testada com o Strapi 5.50 a 5.64. Atualize o plugin para o usar.",
1186
+ "impersonation.signIn.error.start": "Não foi possível iniciar a sessão.",
1187
+ "impersonation.signIn.error.unsupported": "Iniciar sessão como outro administrador não está disponível nesta versão do Strapi.",
1188
+ "impersonation.signIn.error.self": "Não pode iniciar sessão como si próprio.",
1189
+ "impersonation.signIn.error.superAdmin": "Não pode iniciar sessão como Super Admin.",
1190
+ "impersonation.signIn.error.notSubset": "Este administrador tem permissões que o utilizador não tem, por isso não pode iniciar sessão como ele.",
1191
+ "impersonation.signIn.error.inactive": "Esta conta de administrador não está ativa.",
1192
+ "impersonation.signIn.error.alreadyActive": "Alguém já iniciou sessão como este administrador. Termine primeiro essa personificação.",
1193
+ "impersonation.signIn.error.nested": "Não pode iniciar uma personificação durante outra.",
1194
+ "impersonation.signIn.title": "Iniciar sessão como {name}",
1195
+ "impersonation.signIn.intro": "Abre um novo separador com sessão iniciada como este administrador, com o menu e as permissões dele. Os seus outros separadores continuam com a sua sessão. O início, o fim e cada alteração ficam registados no registo de segurança.",
1196
+ "impersonation.signIn.allowChanges": "Permitir alterações",
1197
+ "impersonation.signIn.allowChanges.hint": "Desligado: o separador é só de leitura. A conta, a palavra-passe, as sessões, os administradores, as funções e os tokens de API nunca podem ser alterados.",
1198
+ "impersonation.signIn.allowChanges.warning": "As alterações que fizer aparecem no Strapi como feitas por {name} (por exemplo, em «Editado por último por»). O registo de segurança regista-o a si como autor.",
1199
+ "impersonation.signIn.ready": "Pronto. Abra o separador dentro de um minuto; a ligação funciona uma vez. Termine a personificação na barra no topo desse separador ou nesta página.",
1200
+ "impersonation.signIn.open": "Abrir separador como {name}",
1201
+ "impersonation.signIn.start": "Iniciar sessão",
1202
+ "impersonation.list.kind.adminChanges": "Administrador, sessão iniciada, alterações permitidas",
1203
+ "impersonation.list.kind.adminSignedIn": "Administrador, sessão iniciada, só leitura",
1204
+ "adminPanel.activity.filter.impersonation": "Personificação",
1205
+ "adminPanel.actions.viewPermissions": "Ver permissões de {name}",
1206
+ "adminPanel.actions.viewPermissionsShort": "Ver permissões",
1207
+ "adminPanel.actions.signInAs": "Iniciar sessão como {name}",
1208
+ "adminPanel.actions.signInAsShort": "Iniciar sessão como",
1209
+ "adminPanel.activity.event.impersonationWrite": "Alteração feita com a sessão deste administrador",
1210
+ "impersonation.tab.banner.endShort": "Terminar"
1173
1211
  };
1174
1212
  exports.default = pt;
@@ -1084,7 +1084,7 @@ const pt = {
1084
1084
  "impersonation.preview.conditions": "{action}: somente {conditions}",
1085
1085
  "impersonation.preview.error.start": "Não foi possível abrir a prévia.",
1086
1086
  "impersonation.preview.ended": "Prévia encerrada.",
1087
- "impersonation.preview.title": "Ver como {name}",
1087
+ "impersonation.preview.title": "Permissões de {name}",
1088
1088
  "impersonation.preview.intro": "Veja quais tipos de conteúdo e ações este admin pode usar, com base nas funções dele. Somente leitura: ninguém faz login e nada pode ser alterado. Isso é registrado no registro de segurança.",
1089
1089
  "impersonation.preview.reason.hint": "Fica no registro de segurança.",
1090
1090
  "impersonation.preview.banner.ended": "A prévia terminou.",
@@ -1096,8 +1096,6 @@ const pt = {
1096
1096
  "impersonation.preview.other": "Outras permissões",
1097
1097
  "impersonation.preview.close": "Encerrar e fechar",
1098
1098
  "impersonation.preview.start": "Ver permissões",
1099
- "adminPanel.actions.viewAs": "Ver como {name}",
1100
- "adminPanel.actions.viewAsShort": "Ver como",
1101
1099
  "adminPanel.activity.event.impersonationStarted": "Acesso como usuário iniciado",
1102
1100
  "adminPanel.activity.event.impersonationEnded": "Acesso como usuário encerrado",
1103
1101
  "adminPanel.activity.event.impersonationExpired": "Acesso como usuário expirado",
@@ -1167,7 +1165,47 @@ const pt = {
1167
1165
  "userActivity.panel.title": "Atividade de segurança",
1168
1166
  "userActivity.recent.empty": "Ainda não há eventos de segurança de usuários do aplicativo.",
1169
1167
  "userActivity.recent.subtitle": "Os últimos acessos com falha e recusados, bloqueios, novos dispositivos, viagens impossíveis e acessos como usuário dos usuários do seu aplicativo. Selecione um evento para ver os detalhes.",
1170
- "userActivity.recent.title": "Atividade de segurança"
1168
+ "userActivity.recent.title": "Atividade de segurança",
1169
+ "impersonation.tab.banner.signedInAs": "Sessão iniciada como {name}",
1170
+ "impersonation.tab.banner.changes": "Alterações permitidas",
1171
+ "impersonation.tab.banner.readOnly": "Só leitura",
1172
+ "impersonation.tab.banner.endsIn": "Termina em {time}",
1173
+ "impersonation.tab.banner.end": "Terminar personificação",
1174
+ "impersonation.tab.landing.title": "A iniciar sessão como outro administrador…",
1175
+ "impersonation.tab.failed.title": "O início de sessão não funcionou",
1176
+ "impersonation.tab.failed.body": "A ligação já foi usada ou tem mais de um minuto. Comece de novo na página Painel de administração do Session Manager.",
1177
+ "impersonation.tab.ended.expiredTitle": "A personificação expirou",
1178
+ "impersonation.tab.ended.title": "A personificação terminou",
1179
+ "impersonation.tab.ended.body": "Já não tem sessão iniciada como {name}. Os seus outros separadores não foram afetados. Pode fechar este separador.",
1180
+ "impersonation.tab.backToMyAdmin": "Voltar ao meu painel de administração",
1181
+ "impersonation.tab.close": "Fechar separador",
1182
+ "impersonation.signIn.unsupported.lifespan": "Indisponível: a duração do token de acesso de administração é inferior a 15 minutos.",
1183
+ "impersonation.signIn.unsupported.version": "Indisponível no Strapi {version}: esta versão do plugin foi testada com o Strapi 5.50 a 5.64. Atualize o plugin para o usar.",
1184
+ "impersonation.signIn.error.start": "Não foi possível iniciar a sessão.",
1185
+ "impersonation.signIn.error.unsupported": "Iniciar sessão como outro administrador não está disponível nesta versão do Strapi.",
1186
+ "impersonation.signIn.error.self": "Não pode iniciar sessão como si próprio.",
1187
+ "impersonation.signIn.error.superAdmin": "Não pode iniciar sessão como Super Admin.",
1188
+ "impersonation.signIn.error.notSubset": "Este administrador tem permissões que o utilizador não tem, por isso não pode iniciar sessão como ele.",
1189
+ "impersonation.signIn.error.inactive": "Esta conta de administrador não está ativa.",
1190
+ "impersonation.signIn.error.alreadyActive": "Alguém já iniciou sessão como este administrador. Termine primeiro essa personificação.",
1191
+ "impersonation.signIn.error.nested": "Não pode iniciar uma personificação durante outra.",
1192
+ "impersonation.signIn.title": "Iniciar sessão como {name}",
1193
+ "impersonation.signIn.intro": "Abre um novo separador com sessão iniciada como este administrador, com o menu e as permissões dele. Os seus outros separadores continuam com a sua sessão. O início, o fim e cada alteração ficam registados no registo de segurança.",
1194
+ "impersonation.signIn.allowChanges": "Permitir alterações",
1195
+ "impersonation.signIn.allowChanges.hint": "Desligado: o separador é só de leitura. A conta, a palavra-passe, as sessões, os administradores, as funções e os tokens de API nunca podem ser alterados.",
1196
+ "impersonation.signIn.allowChanges.warning": "As alterações que fizer aparecem no Strapi como feitas por {name} (por exemplo, em «Editado por último por»). O registo de segurança regista-o a si como autor.",
1197
+ "impersonation.signIn.ready": "Pronto. Abra o separador dentro de um minuto; a ligação funciona uma vez. Termine a personificação na barra no topo desse separador ou nesta página.",
1198
+ "impersonation.signIn.open": "Abrir separador como {name}",
1199
+ "impersonation.signIn.start": "Iniciar sessão",
1200
+ "impersonation.list.kind.adminChanges": "Administrador, sessão iniciada, alterações permitidas",
1201
+ "impersonation.list.kind.adminSignedIn": "Administrador, sessão iniciada, só leitura",
1202
+ "adminPanel.activity.filter.impersonation": "Personificação",
1203
+ "adminPanel.actions.viewPermissions": "Ver permissões de {name}",
1204
+ "adminPanel.actions.viewPermissionsShort": "Ver permissões",
1205
+ "adminPanel.actions.signInAs": "Iniciar sessão como {name}",
1206
+ "adminPanel.actions.signInAsShort": "Iniciar sessão como",
1207
+ "adminPanel.activity.event.impersonationWrite": "Alteração feita com a sessão deste administrador",
1208
+ "impersonation.tab.banner.endShort": "Terminar"
1171
1209
  };
1172
1210
  export {
1173
1211
  pt as default
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ const react = require("react");
3
+ const styled = require("styled-components");
4
+ const DS_BREAKPOINTS = Object.freeze({
5
+ small: "@media(min-width: 520px)",
6
+ medium: "@media(min-width: 768px)",
7
+ large: "@media(min-width: 1080px)"
8
+ });
9
+ const BREAKPOINT_ORDER = Object.freeze(["initial", "small", "medium", "large"]);
10
+ function mediaQueryFromBreakpoint(breakpoint) {
11
+ if (typeof breakpoint !== "string") return "";
12
+ const query = breakpoint.replace(/^\s*@media\s*/i, "").trim();
13
+ return /^\(.*\)$/.test(query) ? query : "";
14
+ }
15
+ function getBreakpointQueries(theme) {
16
+ const source = theme?.breakpoints || {};
17
+ return {
18
+ small: mediaQueryFromBreakpoint(source.small) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.small),
19
+ medium: mediaQueryFromBreakpoint(source.medium) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.medium),
20
+ large: mediaQueryFromBreakpoint(source.large) || mediaQueryFromBreakpoint(DS_BREAKPOINTS.large)
21
+ };
22
+ }
23
+ function resolveBreakpoint(matches = {}) {
24
+ if (matches.large) return "large";
25
+ if (matches.medium) return "medium";
26
+ if (matches.small) return "small";
27
+ return "initial";
28
+ }
29
+ function isBelowBreakpoint(current, target) {
30
+ return BREAKPOINT_ORDER.indexOf(current) < BREAKPOINT_ORDER.indexOf(target);
31
+ }
32
+ const readMatches = (queries) => {
33
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
34
+ return { small: true, medium: true, large: true };
35
+ }
36
+ return {
37
+ small: window.matchMedia(queries.small).matches,
38
+ medium: window.matchMedia(queries.medium).matches,
39
+ large: window.matchMedia(queries.large).matches
40
+ };
41
+ };
42
+ function useBreakpoint() {
43
+ const theme = styled.useTheme();
44
+ const queries = react.useMemo(() => getBreakpointQueries(theme), [theme]);
45
+ const [matches, setMatches] = react.useState(() => readMatches(queries));
46
+ react.useEffect(() => {
47
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return void 0;
48
+ const lists = ["small", "medium", "large"].map((name) => window.matchMedia(queries[name]));
49
+ const update = () => setMatches(readMatches(queries));
50
+ update();
51
+ lists.forEach((list) => list.addEventListener?.("change", update));
52
+ return () => lists.forEach((list) => list.removeEventListener?.("change", update));
53
+ }, [queries]);
54
+ const breakpoint = resolveBreakpoint(matches);
55
+ return {
56
+ breakpoint,
57
+ isBelowSmall: isBelowBreakpoint(breakpoint, "small"),
58
+ isBelowMedium: isBelowBreakpoint(breakpoint, "medium"),
59
+ isBelowLarge: isBelowBreakpoint(breakpoint, "large")
60
+ };
61
+ }
62
+ exports.useBreakpoint = useBreakpoint;