@strapi/admin 5.53.0 → 5.54.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 (105) hide show
  1. package/dist/admin/admin/src/App.js +1 -1
  2. package/dist/admin/admin/src/App.js.map +1 -1
  3. package/dist/admin/admin/src/App.mjs +1 -1
  4. package/dist/admin/admin/src/App.mjs.map +1 -1
  5. package/dist/admin/admin/src/components/DismissibleBanner.js +60 -0
  6. package/dist/admin/admin/src/components/DismissibleBanner.js.map +1 -0
  7. package/dist/admin/admin/src/components/DismissibleBanner.mjs +58 -0
  8. package/dist/admin/admin/src/components/DismissibleBanner.mjs.map +1 -0
  9. package/dist/admin/admin/src/components/Form.js +11 -2
  10. package/dist/admin/admin/src/components/Form.js.map +1 -1
  11. package/dist/admin/admin/src/components/Form.mjs +11 -2
  12. package/dist/admin/admin/src/components/Form.mjs.map +1 -1
  13. package/dist/admin/admin/src/components/FormInputs/DateTime.js +1 -1
  14. package/dist/admin/admin/src/components/FormInputs/DateTime.js.map +1 -1
  15. package/dist/admin/admin/src/components/FormInputs/DateTime.mjs +1 -1
  16. package/dist/admin/admin/src/components/FormInputs/DateTime.mjs.map +1 -1
  17. package/dist/admin/admin/src/components/FormInputs/Time.js +1 -1
  18. package/dist/admin/admin/src/components/FormInputs/Time.js.map +1 -1
  19. package/dist/admin/admin/src/components/FormInputs/Time.mjs +1 -1
  20. package/dist/admin/admin/src/components/FormInputs/Time.mjs.map +1 -1
  21. package/dist/admin/admin/src/components/MainNav/NavUser.js +1 -2
  22. package/dist/admin/admin/src/components/MainNav/NavUser.js.map +1 -1
  23. package/dist/admin/admin/src/components/MainNav/NavUser.mjs +1 -2
  24. package/dist/admin/admin/src/components/MainNav/NavUser.mjs.map +1 -1
  25. package/dist/admin/admin/src/components/MediaLibraryBanner.js +85 -0
  26. package/dist/admin/admin/src/components/MediaLibraryBanner.js.map +1 -0
  27. package/dist/admin/admin/src/components/MediaLibraryBanner.mjs +83 -0
  28. package/dist/admin/admin/src/components/MediaLibraryBanner.mjs.map +1 -0
  29. package/dist/admin/admin/src/components/Providers.js +6 -6
  30. package/dist/admin/admin/src/components/Providers.js.map +1 -1
  31. package/dist/admin/admin/src/components/Providers.mjs +6 -6
  32. package/dist/admin/admin/src/components/Providers.mjs.map +1 -1
  33. package/dist/admin/admin/src/components/UpsellBanner.js +56 -86
  34. package/dist/admin/admin/src/components/UpsellBanner.js.map +1 -1
  35. package/dist/admin/admin/src/components/UpsellBanner.mjs +58 -88
  36. package/dist/admin/admin/src/components/UpsellBanner.mjs.map +1 -1
  37. package/dist/admin/admin/src/core/store/configure.js +14 -2
  38. package/dist/admin/admin/src/core/store/configure.js.map +1 -1
  39. package/dist/admin/admin/src/core/store/configure.mjs +14 -2
  40. package/dist/admin/admin/src/core/store/configure.mjs.map +1 -1
  41. package/dist/admin/admin/src/core/store/hooks.mjs +1 -1
  42. package/dist/admin/admin/src/features/Auth.js +162 -46
  43. package/dist/admin/admin/src/features/Auth.js.map +1 -1
  44. package/dist/admin/admin/src/features/Auth.mjs +164 -48
  45. package/dist/admin/admin/src/features/Auth.mjs.map +1 -1
  46. package/dist/admin/admin/src/hooks/useRegisterUnsavedChanges.js +19 -0
  47. package/dist/admin/admin/src/hooks/useRegisterUnsavedChanges.js.map +1 -0
  48. package/dist/admin/admin/src/hooks/useRegisterUnsavedChanges.mjs +17 -0
  49. package/dist/admin/admin/src/hooks/useRegisterUnsavedChanges.mjs.map +1 -0
  50. package/dist/admin/admin/src/hooks/{useIdleSessionLogout.js → useSessionKeepalive.js} +34 -27
  51. package/dist/admin/admin/src/hooks/useSessionKeepalive.js.map +1 -0
  52. package/dist/admin/admin/src/hooks/{useIdleSessionLogout.mjs → useSessionKeepalive.mjs} +34 -27
  53. package/dist/admin/admin/src/hooks/useSessionKeepalive.mjs.map +1 -0
  54. package/dist/admin/admin/src/layouts/AuthenticatedLayout.js +2 -0
  55. package/dist/admin/admin/src/layouts/AuthenticatedLayout.js.map +1 -1
  56. package/dist/admin/admin/src/layouts/AuthenticatedLayout.mjs +2 -0
  57. package/dist/admin/admin/src/layouts/AuthenticatedLayout.mjs.map +1 -1
  58. package/dist/admin/admin/src/pages/SessionsPage.js +2 -5
  59. package/dist/admin/admin/src/pages/SessionsPage.js.map +1 -1
  60. package/dist/admin/admin/src/pages/SessionsPage.mjs +2 -5
  61. package/dist/admin/admin/src/pages/SessionsPage.mjs.map +1 -1
  62. package/dist/admin/admin/src/render.js +5 -0
  63. package/dist/admin/admin/src/render.js.map +1 -1
  64. package/dist/admin/admin/src/render.mjs +5 -0
  65. package/dist/admin/admin/src/render.mjs.map +1 -1
  66. package/dist/admin/admin/src/translations/en.json.js +12 -0
  67. package/dist/admin/admin/src/translations/en.json.js.map +1 -1
  68. package/dist/admin/admin/src/translations/en.json.mjs +12 -0
  69. package/dist/admin/admin/src/translations/en.json.mjs.map +1 -1
  70. package/dist/admin/admin/src/utils/baseQuery.js +3 -13
  71. package/dist/admin/admin/src/utils/baseQuery.js.map +1 -1
  72. package/dist/admin/admin/src/utils/baseQuery.mjs +3 -13
  73. package/dist/admin/admin/src/utils/baseQuery.mjs.map +1 -1
  74. package/dist/admin/admin/src/utils/getFetchClient.js +34 -5
  75. package/dist/admin/admin/src/utils/getFetchClient.js.map +1 -1
  76. package/dist/admin/admin/src/utils/getFetchClient.mjs +34 -6
  77. package/dist/admin/admin/src/utils/getFetchClient.mjs.map +1 -1
  78. package/dist/admin/admin/src/utils/unsavedChangesRegistry.js +25 -0
  79. package/dist/admin/admin/src/utils/unsavedChangesRegistry.js.map +1 -0
  80. package/dist/admin/admin/src/utils/unsavedChangesRegistry.mjs +22 -0
  81. package/dist/admin/admin/src/utils/unsavedChangesRegistry.mjs.map +1 -0
  82. package/dist/admin/admin/tests/utils.js +14 -14
  83. package/dist/admin/admin/tests/utils.js.map +1 -1
  84. package/dist/admin/admin/tests/utils.mjs +14 -14
  85. package/dist/admin/admin/tests/utils.mjs.map +1 -1
  86. package/dist/admin/ee/admin/src/pages/SettingsPage/pages/AuditLogs/utils/getActionTypesDefaultMessages.js +5 -1
  87. package/dist/admin/ee/admin/src/pages/SettingsPage/pages/AuditLogs/utils/getActionTypesDefaultMessages.js.map +1 -1
  88. package/dist/admin/ee/admin/src/pages/SettingsPage/pages/AuditLogs/utils/getActionTypesDefaultMessages.mjs +5 -1
  89. package/dist/admin/ee/admin/src/pages/SettingsPage/pages/AuditLogs/utils/getActionTypesDefaultMessages.mjs.map +1 -1
  90. package/dist/admin/index.js +1 -0
  91. package/dist/admin/index.js.map +1 -1
  92. package/dist/admin/index.mjs +1 -1
  93. package/dist/admin/src/components/DismissibleBanner.d.ts +8 -0
  94. package/dist/admin/src/components/MediaLibraryBanner.d.ts +2 -0
  95. package/dist/admin/src/hooks/useRegisterUnsavedChanges.d.ts +6 -0
  96. package/dist/admin/src/hooks/useSessionKeepalive.d.ts +88 -0
  97. package/dist/admin/src/utils/getFetchClient.d.ts +14 -6
  98. package/dist/admin/src/utils/unsavedChangesRegistry.d.ts +11 -0
  99. package/dist/ee/admin/src/pages/SettingsPage/pages/AuditLogs/utils/getActionTypesDefaultMessages.d.ts +4 -0
  100. package/dist/shared/contracts/shared.d.ts +1 -0
  101. package/dist/shared/contracts/shared.d.ts.map +1 -1
  102. package/package.json +7 -7
  103. package/dist/admin/admin/src/hooks/useIdleSessionLogout.js.map +0 -1
  104. package/dist/admin/admin/src/hooks/useIdleSessionLogout.mjs.map +0 -1
  105. package/dist/admin/src/hooks/useIdleSessionLogout.d.ts +0 -87
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sources":["../../../../admin/src/render.ts"],"sourcesContent":["/* eslint-disable no-undef */\nimport { createRoot } from 'react-dom/client';\n\nimport { StrapiApp, StrapiAppConstructorArgs } from './StrapiApp';\nimport { getFetchClient } from './utils/getFetchClient';\nimport { getProjectType } from './utils/getProjectType';\nimport { createAbsoluteUrl } from './utils/urls';\n\nimport type { Modules } from '@strapi/types';\n\ninterface RenderAdminArgs {\n customisations: {\n register?: (app: StrapiApp) => Promise<void> | void;\n bootstrap?: (app: StrapiApp) => Promise<void> | void;\n config?: StrapiAppConstructorArgs['config'];\n };\n plugins: StrapiAppConstructorArgs['appPlugins'];\n features?: Modules.Features.FeaturesService['config'];\n}\n\nconst renderAdmin = async (\n mountNode: HTMLElement | null,\n { plugins, customisations, features }: RenderAdminArgs\n) => {\n if (!mountNode) {\n throw new Error('[@strapi/admin]: Could not find the root element to mount the admin app');\n }\n\n window.strapi = {\n /**\n * This ENV variable is passed from the strapi instance, by default no url is set\n * in the config and therefore the instance returns you an empty string so URLs are relative.\n *\n * To ensure that the backendURL is always set, we use the window.location.origin as a fallback.\n */\n backendURL: createAbsoluteUrl(process.env.STRAPI_ADMIN_BACKEND_URL),\n isEE: false,\n isTrial: false,\n telemetryDisabled: process.env.STRAPI_TELEMETRY_DISABLED === 'true',\n future: {\n isEnabled: (name: keyof NonNullable<Modules.Features.FeaturesConfig['future']>) => {\n return features?.future?.[name] === true;\n },\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision. Cannot use @ts-expect-error because of build:code and build:types context collision.\n features: {\n SSO: 'sso',\n AUDIT_LOGS: 'audit-logs',\n REVIEW_WORKFLOWS: 'review-workflows',\n /**\n * If we don't get the license then we know it's not EE\n * so no feature is enabled.\n */\n isEnabled: () => false,\n },\n projectType: 'Community',\n flags: {\n nps: false,\n promoteEE: true,\n docLinks: true,\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n ai: {\n enabled: true,\n },\n };\n\n const { get } = getFetchClient();\n\n interface ProjectType extends Pick<Window['strapi'], 'flags'> {\n isEE: boolean;\n isTrial: boolean;\n /**\n * The licensed plan price id, sent by the license registry (EE only).\n * Used to distinguish the Growth plan from other Enterprise plans.\n */\n planPriceId?: string;\n features: {\n name: string;\n }[];\n ai: {\n enabled: boolean;\n };\n }\n\n try {\n const {\n data: {\n data: { isEE, isTrial, features, flags, ai, planPriceId },\n },\n } = await get<{ data: ProjectType }>('/admin/project-type');\n\n window.strapi.isEE = isEE;\n window.strapi.isTrialLicense = isTrial;\n window.strapi.flags = flags;\n window.strapi.features = {\n ...window.strapi.features,\n isEnabled: (featureName: string | undefined) =>\n features.some((feature) => feature.name === featureName),\n };\n window.strapi.projectType = getProjectType({ isEE, planPriceId });\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n window.strapi.ai = ai;\n } catch (err) {\n /**\n * If this fails, we simply don't activate any EE features.\n * Should we warn clearer in the UI?\n */\n console.error(err);\n }\n\n const app = new StrapiApp({\n config: customisations?.config,\n appPlugins: plugins,\n });\n\n await app.register(customisations?.register);\n await app.bootstrap(customisations?.bootstrap);\n await app.loadTrads(customisations?.config?.translations);\n\n createRoot(mountNode).render(app.render());\n\n if (\n typeof module !== 'undefined' &&\n module &&\n 'hot' in module &&\n typeof module.hot === 'object' &&\n module.hot !== null &&\n 'accept' in module.hot &&\n typeof module.hot.accept === 'function'\n ) {\n module.hot.accept();\n }\n\n if (typeof import.meta.hot?.accept === 'function') {\n import.meta.hot.accept();\n }\n};\n\nexport { renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":["renderAdmin","mountNode","plugins","customisations","features","Error","window","strapi","backendURL","createAbsoluteUrl","process","env","STRAPI_ADMIN_BACKEND_URL","isEE","isTrial","telemetryDisabled","STRAPI_TELEMETRY_DISABLED","future","isEnabled","name","SSO","AUDIT_LOGS","REVIEW_WORKFLOWS","projectType","flags","nps","promoteEE","docLinks","ai","enabled","get","getFetchClient","data","planPriceId","isTrialLicense","featureName","some","feature","getProjectType","err","console","error","app","StrapiApp","config","appPlugins","register","bootstrap","loadTrads","translations","createRoot","render","module","hot","accept"],"mappings":";;;;;;;;AAoBA,MAAMA,WAAAA,GAAc,OAClBC,SAAAA,EACA,EAAEC,OAAO,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OC,GAAG,KAAK,IAAA,IACf,QAAA,IAAYD,MAAAA,CAAOC,GAAG,IACtB,OAAOD,MAAAA,CAAOC,GAAG,CAACC,MAAM,KAAK,UAAA,EAC7B;QACAF,MAAAA,CAAOC,GAAG,CAACC,MAAM,EAAA;AACnB,IAAA;AAEA,IAAA,IAAI,OAAO,SAAe,EAAEA,WAAW,UAAA,EAAY;QACjD,SAAe,CAACA,MAAM,EAAA;AACxB,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"render.js","sources":["../../../../admin/src/render.ts"],"sourcesContent":["/* eslint-disable no-undef */\nimport { createRoot } from 'react-dom/client';\n\nimport { StrapiApp, StrapiAppConstructorArgs } from './StrapiApp';\nimport { getFetchClient } from './utils/getFetchClient';\nimport { getProjectType } from './utils/getProjectType';\nimport { createAbsoluteUrl } from './utils/urls';\n\nimport type { Modules } from '@strapi/types';\n\ninterface RenderAdminArgs {\n customisations: {\n register?: (app: StrapiApp) => Promise<void> | void;\n bootstrap?: (app: StrapiApp) => Promise<void> | void;\n config?: StrapiAppConstructorArgs['config'];\n };\n plugins: StrapiAppConstructorArgs['appPlugins'];\n features?: Modules.Features.FeaturesService['config'];\n}\n\nconst renderAdmin = async (\n mountNode: HTMLElement | null,\n { plugins, customisations, features }: RenderAdminArgs\n) => {\n if (!mountNode) {\n throw new Error('[@strapi/admin]: Could not find the root element to mount the admin app');\n }\n\n window.strapi = {\n /**\n * This ENV variable is passed from the strapi instance, by default no url is set\n * in the config and therefore the instance returns you an empty string so URLs are relative.\n *\n * To ensure that the backendURL is always set, we use the window.location.origin as a fallback.\n */\n backendURL: createAbsoluteUrl(process.env.STRAPI_ADMIN_BACKEND_URL),\n isEE: false,\n isTrial: false,\n telemetryDisabled: process.env.STRAPI_TELEMETRY_DISABLED === 'true',\n future: {\n isEnabled: (name: keyof NonNullable<Modules.Features.FeaturesConfig['future']>) => {\n return features?.future?.[name] === true;\n },\n },\n featureFlags: {\n isEnabled: (name: keyof Omit<Modules.Features.FeaturesConfig, 'future'>) => {\n return features?.[name] === true;\n },\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision. Cannot use @ts-expect-error because of build:code and build:types context collision.\n features: {\n SSO: 'sso',\n AUDIT_LOGS: 'audit-logs',\n REVIEW_WORKFLOWS: 'review-workflows',\n /**\n * If we don't get the license then we know it's not EE\n * so no feature is enabled.\n */\n isEnabled: () => false,\n },\n projectType: 'Community',\n flags: {\n nps: false,\n promoteEE: true,\n docLinks: true,\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n ai: {\n enabled: true,\n },\n };\n\n const { get } = getFetchClient();\n\n interface ProjectType extends Pick<Window['strapi'], 'flags'> {\n isEE: boolean;\n isTrial: boolean;\n /**\n * The licensed plan price id, sent by the license registry (EE only).\n * Used to distinguish the Growth plan from other Enterprise plans.\n */\n planPriceId?: string;\n features: {\n name: string;\n }[];\n ai: {\n enabled: boolean;\n };\n }\n\n try {\n const {\n data: {\n data: { isEE, isTrial, features, flags, ai, planPriceId },\n },\n } = await get<{ data: ProjectType }>('/admin/project-type');\n\n window.strapi.isEE = isEE;\n window.strapi.isTrialLicense = isTrial;\n window.strapi.flags = flags;\n window.strapi.features = {\n ...window.strapi.features,\n isEnabled: (featureName: string | undefined) =>\n features.some((feature) => feature.name === featureName),\n };\n window.strapi.projectType = getProjectType({ isEE, planPriceId });\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n window.strapi.ai = ai;\n } catch (err) {\n /**\n * If this fails, we simply don't activate any EE features.\n * Should we warn clearer in the UI?\n */\n console.error(err);\n }\n\n const app = new StrapiApp({\n config: customisations?.config,\n appPlugins: plugins,\n });\n\n await app.register(customisations?.register);\n await app.bootstrap(customisations?.bootstrap);\n await app.loadTrads(customisations?.config?.translations);\n\n createRoot(mountNode).render(app.render());\n\n if (\n typeof module !== 'undefined' &&\n module &&\n 'hot' in module &&\n typeof module.hot === 'object' &&\n module.hot !== null &&\n 'accept' in module.hot &&\n typeof module.hot.accept === 'function'\n ) {\n module.hot.accept();\n }\n\n if (typeof import.meta.hot?.accept === 'function') {\n import.meta.hot.accept();\n }\n};\n\nexport { renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":["renderAdmin","mountNode","plugins","customisations","features","Error","window","strapi","backendURL","createAbsoluteUrl","process","env","STRAPI_ADMIN_BACKEND_URL","isEE","isTrial","telemetryDisabled","STRAPI_TELEMETRY_DISABLED","future","isEnabled","name","featureFlags","SSO","AUDIT_LOGS","REVIEW_WORKFLOWS","projectType","flags","nps","promoteEE","docLinks","ai","enabled","get","getFetchClient","data","planPriceId","isTrialLicense","featureName","some","feature","getProjectType","err","console","error","app","StrapiApp","config","appPlugins","register","bootstrap","loadTrads","translations","createRoot","render","module","hot","accept"],"mappings":";;;;;;;;AAoBA,MAAMA,WAAAA,GAAc,OAClBC,SAAAA,EACA,EAAEC,OAAO,EAAEC,cAAc,EAAEC,QAAQ,EAAmB,GAAA;AAEtD,IAAA,IAAI,CAACH,SAAAA,EAAW;AACd,QAAA,MAAM,IAAII,KAAAA,CAAM,yEAAA,CAAA;AAClB,IAAA;AAEAC,IAAAA,MAAAA,CAAOC,MAAM,GAAG;AACd;;;;;AAKC,QACDC,UAAAA,EAAYC,sBAAAA,CAAkBC,OAAAA,CAAQC,GAAG,CAACC,wBAAwB,CAAA;QAClEC,IAAAA,EAAM,KAAA;QACNC,OAAAA,EAAS,KAAA;AACTC,QAAAA,iBAAAA,EAAmBL,OAAAA,CAAQC,GAAG,CAACK,yBAAyB,KAAK,MAAA;QAC7DC,MAAAA,EAAQ;AACNC,YAAAA,SAAAA,EAAW,CAACC,IAAAA,GAAAA;AACV,gBAAA,OAAOf,QAAAA,EAAUa,MAAAA,GAASE,IAAAA,CAAK,KAAK,IAAA;AACtC,YAAA;AACF,SAAA;QACAC,YAAAA,EAA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;;;QAG/D5B,MAAAA,CAAOC,MAAM,CAACsB,EAAE,GAAGA,EAAAA;AACrB,IAAA,CAAA,CAAE,OAAOW,GAAAA,EAAK;AACZ;;;QAIAC,OAAAA,CAAQC,KAAK,CAACF,GAAAA,CAAAA;AAChB,IAAA;IAEA,MAAMG,GAAAA,GAAM,IAAIC,mBAAAA,CAAU;AACxBC,QAAAA,MAAAA,EAAQ1C,cAAAA,EAAgB0C,MAAAA;QACxBC,UAAAA,EAAY5C;AACd,KAAA,CAAA;IAEA,MAAMyC,GAAAA,CAAII,QAAQ,CAAC5C,cAAAA,EAAgB4C,QAAAA,CAAAA;IACnC,MAAMJ,GAAAA,CAAIK,SAAS,CAAC7C,cAAAA,EAAgB6C,SAAAA,CAAAA;AACpC,IAAA,MAAML,GAAAA,CAAIM,SAAS,CAAC9C,cAAAA,EAAgB0C,MAAAA,EAAQK,YAAAA,CAAAA;AAE5CC,IAAAA,iBAAAA,CAAWlD,SAAAA,CAAAA,CAAWmD,MAAM,CAACT,GAAAA,CAAIS,MAAM,EAAA,CAAA;IAEvC,IACE,OAAOC,MAAAA,KAAW,WAAA,IAClBA,MAAAA,IACA,KAAA,IAASA,UACT,OAAOA,MAAAA,CAAOC,GAAG,KAAK,QAAA,IACtBD,MAAAA,CAAOC,GAAG,KAAK,IAAA,IACf,QAAA,IAAYD,MAAAA,CAAOC,GAAG,IACtB,OAAOD,MAAAA,CAAOC,GAAG,CAACC,MAAM,KAAK,UAAA,EAC7B;QACAF,MAAAA,CAAOC,GAAG,CAACC,MAAM,EAAA;AACnB,IAAA;AAEA,IAAA,IAAI,OAAO,SAAe,EAAEA,WAAW,UAAA,EAAY;QACjD,SAAe,CAACA,MAAM,EAAA;AACxB,IAAA;AACF;;;;"}
@@ -23,6 +23,11 @@ const renderAdmin = async (mountNode, { plugins, customisations, features })=>{
23
23
  return features?.future?.[name] === true;
24
24
  }
25
25
  },
26
+ featureFlags: {
27
+ isEnabled: (name)=>{
28
+ return features?.[name] === true;
29
+ }
30
+ },
26
31
  // eslint-disable-next-line
27
32
  // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision. Cannot use @ts-expect-error because of build:code and build:types context collision.
28
33
  features: {
@@ -1 +1 @@
1
- {"version":3,"file":"render.mjs","sources":["../../../../admin/src/render.ts"],"sourcesContent":["/* eslint-disable no-undef */\nimport { createRoot } from 'react-dom/client';\n\nimport { StrapiApp, StrapiAppConstructorArgs } from './StrapiApp';\nimport { getFetchClient } from './utils/getFetchClient';\nimport { getProjectType } from './utils/getProjectType';\nimport { createAbsoluteUrl } from './utils/urls';\n\nimport type { Modules } from '@strapi/types';\n\ninterface RenderAdminArgs {\n customisations: {\n register?: (app: StrapiApp) => Promise<void> | void;\n bootstrap?: (app: StrapiApp) => Promise<void> | void;\n config?: StrapiAppConstructorArgs['config'];\n };\n plugins: StrapiAppConstructorArgs['appPlugins'];\n features?: Modules.Features.FeaturesService['config'];\n}\n\nconst renderAdmin = async (\n mountNode: HTMLElement | null,\n { plugins, customisations, features }: RenderAdminArgs\n) => {\n if (!mountNode) {\n throw new Error('[@strapi/admin]: Could not find the root element to mount the admin app');\n }\n\n window.strapi = {\n /**\n * This ENV variable is passed from the strapi instance, by default no url is set\n * in the config and therefore the instance returns you an empty string so URLs are relative.\n *\n * To ensure that the backendURL is always set, we use the window.location.origin as a fallback.\n */\n backendURL: createAbsoluteUrl(process.env.STRAPI_ADMIN_BACKEND_URL),\n isEE: false,\n isTrial: false,\n telemetryDisabled: process.env.STRAPI_TELEMETRY_DISABLED === 'true',\n future: {\n isEnabled: (name: keyof NonNullable<Modules.Features.FeaturesConfig['future']>) => {\n return features?.future?.[name] === true;\n },\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision. Cannot use @ts-expect-error because of build:code and build:types context collision.\n features: {\n SSO: 'sso',\n AUDIT_LOGS: 'audit-logs',\n REVIEW_WORKFLOWS: 'review-workflows',\n /**\n * If we don't get the license then we know it's not EE\n * so no feature is enabled.\n */\n isEnabled: () => false,\n },\n projectType: 'Community',\n flags: {\n nps: false,\n promoteEE: true,\n docLinks: true,\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n ai: {\n enabled: true,\n },\n };\n\n const { get } = getFetchClient();\n\n interface ProjectType extends Pick<Window['strapi'], 'flags'> {\n isEE: boolean;\n isTrial: boolean;\n /**\n * The licensed plan price id, sent by the license registry (EE only).\n * Used to distinguish the Growth plan from other Enterprise plans.\n */\n planPriceId?: string;\n features: {\n name: string;\n }[];\n ai: {\n enabled: boolean;\n };\n }\n\n try {\n const {\n data: {\n data: { isEE, isTrial, features, flags, ai, planPriceId },\n },\n } = await get<{ data: ProjectType }>('/admin/project-type');\n\n window.strapi.isEE = isEE;\n window.strapi.isTrialLicense = isTrial;\n window.strapi.flags = flags;\n window.strapi.features = {\n ...window.strapi.features,\n isEnabled: (featureName: string | undefined) =>\n features.some((feature) => feature.name === featureName),\n };\n window.strapi.projectType = getProjectType({ isEE, planPriceId });\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n window.strapi.ai = ai;\n } catch (err) {\n /**\n * If this fails, we simply don't activate any EE features.\n * Should we warn clearer in the UI?\n */\n console.error(err);\n }\n\n const app = new StrapiApp({\n config: customisations?.config,\n appPlugins: plugins,\n });\n\n await app.register(customisations?.register);\n await app.bootstrap(customisations?.bootstrap);\n await app.loadTrads(customisations?.config?.translations);\n\n createRoot(mountNode).render(app.render());\n\n if (\n typeof module !== 'undefined' &&\n module &&\n 'hot' in module &&\n typeof module.hot === 'object' &&\n module.hot !== null &&\n 'accept' in module.hot &&\n typeof module.hot.accept === 'function'\n ) {\n module.hot.accept();\n }\n\n if (typeof import.meta.hot?.accept === 'function') {\n import.meta.hot.accept();\n }\n};\n\nexport { renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":["renderAdmin","mountNode","plugins","customisations","features","Error","window","strapi","backendURL","createAbsoluteUrl","process","env","STRAPI_ADMIN_BACKEND_URL","isEE","isTrial","telemetryDisabled","STRAPI_TELEMETRY_DISABLED","future","isEnabled","name","SSO","AUDIT_LOGS","REVIEW_WORKFLOWS","projectType","flags","nps","promoteEE","docLinks","ai","enabled","get","getFetchClient","data","planPriceId","isTrialLicense","featureName","some","feature","getProjectType","err","console","error","app","StrapiApp","config","appPlugins","register","bootstrap","loadTrads","translations","createRoot","render","module","hot","accept"],"mappings":";;;;;;AAoBA,MAAMA,WAAAA,GAAc,OAClBC,SAAAA,EACA,EAAEC,OAAO,EAAEC,cAAc,EAAEC,QAAQ,EAAmB,GAAA;AAEtD,IAAA,IAAI,CAACH,SAAAA,EAAW;AACd,QAAA,MAAM,IAAII,KAAAA,CAAM,yEAAA,CAAA;AAClB,IAAA;AAEAC,IAAAA,MAAAA,CAAOC,MAAM,GAAG;AACd;;;;;AAKC,QACDC,UAAAA,EAAYC,iBAAAA,CAAkBC,OAAAA,CAAQC,GAAG,CAACC,wBAAwB,CAAA;QAClEC,IAAAA,EAAM,KAAA;QACNC,OAAAA,EAAS,KAAA;AACTC,QAAAA,iBAAAA,EAAmBL,OAAAA,CAAQC,GAAG,CAACK,yBAAyB,KAAK,MAAA;QAC7DC,MAAAA,EAAQ;AACNC,YAAAA,SAAAA,EAAW,CAACC,IAAAA,GAAAA;AACV,gBAAA,OAAOf,QAAAA,EAAUa,MAAAA,GAASE,IAAAA,CAAK,KAAK,IAAA;AACtC,YAAA;AACF,SAAA;;;QAGAf,QAAAA,EAAU;YACRgB,GAAAA,EAAK,KAAA;YACLC,UAAAA,EAAY,YAAA;YACZC,gBAAAA,EAAkB,kBAAA;AAClB;;;AAGC,UACDJ,WAAW,IAAM;AACnB,SAAA;QACAK,WAAAA,EAAa,WAAA;QACbC,KAAAA,EAAO;YACLC,GAAAA,EAAK,KAAA;YACLC,SAAAA,EAAW,IAAA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2C,QAAAA,CAAAA;IACnC,MAAMJ,GAAAA,CAAIK,SAAS,CAAC5C,cAAAA,EAAgB4C,SAAAA,CAAAA;AACpC,IAAA,MAAML,GAAAA,CAAIM,SAAS,CAAC7C,cAAAA,EAAgByC,MAAAA,EAAQK,YAAAA,CAAAA;AAE5CC,IAAAA,UAAAA,CAAWjD,SAAAA,CAAAA,CAAWkD,MAAM,CAACT,GAAAA,CAAIS,MAAM,EAAA,CAAA;IAEvC,IACE,OAAOC,MAAAA,KAAW,WAAA,IAClBA,MAAAA,IACA,KAAA,IAASA,UACT,OAAOA,MAAAA,CAAOC,GAAG,KAAK,QAAA,IACtBD,MAAAA,CAAOC,GAAG,KAAK,IAAA,IACf,QAAA,IAAYD,MAAAA,CAAOC,GAAG,IACtB,OAAOD,MAAAA,CAAOC,GAAG,CAACC,MAAM,KAAK,UAAA,EAC7B;QACAF,MAAAA,CAAOC,GAAG,CAACC,MAAM,EAAA;AACnB,IAAA;AAEA,IAAA,IAAI,OAAO,MAAA,CAAA,IAAA,CAAYD,GAAG,EAAEC,WAAW,UAAA,EAAY;QACjD,MAAA,CAAA,IAAA,CAAYD,GAAG,CAACC,MAAM,EAAA;AACxB,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"render.mjs","sources":["../../../../admin/src/render.ts"],"sourcesContent":["/* eslint-disable no-undef */\nimport { createRoot } from 'react-dom/client';\n\nimport { StrapiApp, StrapiAppConstructorArgs } from './StrapiApp';\nimport { getFetchClient } from './utils/getFetchClient';\nimport { getProjectType } from './utils/getProjectType';\nimport { createAbsoluteUrl } from './utils/urls';\n\nimport type { Modules } from '@strapi/types';\n\ninterface RenderAdminArgs {\n customisations: {\n register?: (app: StrapiApp) => Promise<void> | void;\n bootstrap?: (app: StrapiApp) => Promise<void> | void;\n config?: StrapiAppConstructorArgs['config'];\n };\n plugins: StrapiAppConstructorArgs['appPlugins'];\n features?: Modules.Features.FeaturesService['config'];\n}\n\nconst renderAdmin = async (\n mountNode: HTMLElement | null,\n { plugins, customisations, features }: RenderAdminArgs\n) => {\n if (!mountNode) {\n throw new Error('[@strapi/admin]: Could not find the root element to mount the admin app');\n }\n\n window.strapi = {\n /**\n * This ENV variable is passed from the strapi instance, by default no url is set\n * in the config and therefore the instance returns you an empty string so URLs are relative.\n *\n * To ensure that the backendURL is always set, we use the window.location.origin as a fallback.\n */\n backendURL: createAbsoluteUrl(process.env.STRAPI_ADMIN_BACKEND_URL),\n isEE: false,\n isTrial: false,\n telemetryDisabled: process.env.STRAPI_TELEMETRY_DISABLED === 'true',\n future: {\n isEnabled: (name: keyof NonNullable<Modules.Features.FeaturesConfig['future']>) => {\n return features?.future?.[name] === true;\n },\n },\n featureFlags: {\n isEnabled: (name: keyof Omit<Modules.Features.FeaturesConfig, 'future'>) => {\n return features?.[name] === true;\n },\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision. Cannot use @ts-expect-error because of build:code and build:types context collision.\n features: {\n SSO: 'sso',\n AUDIT_LOGS: 'audit-logs',\n REVIEW_WORKFLOWS: 'review-workflows',\n /**\n * If we don't get the license then we know it's not EE\n * so no feature is enabled.\n */\n isEnabled: () => false,\n },\n projectType: 'Community',\n flags: {\n nps: false,\n promoteEE: true,\n docLinks: true,\n },\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n ai: {\n enabled: true,\n },\n };\n\n const { get } = getFetchClient();\n\n interface ProjectType extends Pick<Window['strapi'], 'flags'> {\n isEE: boolean;\n isTrial: boolean;\n /**\n * The licensed plan price id, sent by the license registry (EE only).\n * Used to distinguish the Growth plan from other Enterprise plans.\n */\n planPriceId?: string;\n features: {\n name: string;\n }[];\n ai: {\n enabled: boolean;\n };\n }\n\n try {\n const {\n data: {\n data: { isEE, isTrial, features, flags, ai, planPriceId },\n },\n } = await get<{ data: ProjectType }>('/admin/project-type');\n\n window.strapi.isEE = isEE;\n window.strapi.isTrialLicense = isTrial;\n window.strapi.flags = flags;\n window.strapi.features = {\n ...window.strapi.features,\n isEnabled: (featureName: string | undefined) =>\n features.some((feature) => feature.name === featureName),\n };\n window.strapi.projectType = getProjectType({ isEE, planPriceId });\n // eslint-disable-next-line\n // @ts-ignore – there's pollution from the global scope of Node. Cannot use @ts-expect-error because of build:code and build:types context collision.\n window.strapi.ai = ai;\n } catch (err) {\n /**\n * If this fails, we simply don't activate any EE features.\n * Should we warn clearer in the UI?\n */\n console.error(err);\n }\n\n const app = new StrapiApp({\n config: customisations?.config,\n appPlugins: plugins,\n });\n\n await app.register(customisations?.register);\n await app.bootstrap(customisations?.bootstrap);\n await app.loadTrads(customisations?.config?.translations);\n\n createRoot(mountNode).render(app.render());\n\n if (\n typeof module !== 'undefined' &&\n module &&\n 'hot' in module &&\n typeof module.hot === 'object' &&\n module.hot !== null &&\n 'accept' in module.hot &&\n typeof module.hot.accept === 'function'\n ) {\n module.hot.accept();\n }\n\n if (typeof import.meta.hot?.accept === 'function') {\n import.meta.hot.accept();\n }\n};\n\nexport { renderAdmin };\nexport type { RenderAdminArgs };\n"],"names":["renderAdmin","mountNode","plugins","customisations","features","Error","window","strapi","backendURL","createAbsoluteUrl","process","env","STRAPI_ADMIN_BACKEND_URL","isEE","isTrial","telemetryDisabled","STRAPI_TELEMETRY_DISABLED","future","isEnabled","name","featureFlags","SSO","AUDIT_LOGS","REVIEW_WORKFLOWS","projectType","flags","nps","promoteEE","docLinks","ai","enabled","get","getFetchClient","data","planPriceId","isTrialLicense","featureName","some","feature","getProjectType","err","console","error","app","StrapiApp","config","appPlugins","register","bootstrap","loadTrads","translations","createRoot","render","module","hot","accept"],"mappings":";;;;;;AAoBA,MAAMA,WAAAA,GAAc,OAClBC,SAAAA,EACA,EAAEC,OAAO,EAAEC,cAAc,EAAEC,QAAQ,EAAmB,GAAA;AAEtD,IAAA,IAAI,CAACH,SAAAA,EAAW;AACd,QAAA,MAAM,IAAII,KAAAA,CAAM,yEAA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A,IACtBD,MAAAA,CAAOC,GAAG,KAAK,IAAA,IACf,QAAA,IAAYD,MAAAA,CAAOC,GAAG,IACtB,OAAOD,MAAAA,CAAOC,GAAG,CAACC,MAAM,KAAK,UAAA,EAC7B;QACAF,MAAAA,CAAOC,GAAG,CAACC,MAAM,EAAA;AACnB,IAAA;AAEA,IAAA,IAAI,OAAO,MAAA,CAAA,IAAA,CAAYD,GAAG,EAAEC,WAAW,UAAA,EAAY;QACjD,MAAA,CAAA,IAAA,CAAYD,GAAG,CAACC,MAAM,EAAA;AACxB,IAAA;AACF;;;;"}
@@ -210,6 +210,10 @@ var en = {
210
210
  "Settings.permissions.auditLogs.listview.export.ready.title": "Export ready",
211
211
  "Settings.permissions.auditLogs.listview.header.subtitle": "Logs of all the activities that happened in your environment",
212
212
  "Settings.permissions.auditLogs.not-available": "Audit Logs is only available as part of a paid plan. Upgrade to get a searchable and filterable display of all activities.",
213
+ "Settings.permissions.auditLogs.locale.create": "Create locale",
214
+ "Settings.permissions.auditLogs.locale.default.update": "Change default locale",
215
+ "Settings.permissions.auditLogs.locale.delete": "Delete locale",
216
+ "Settings.permissions.auditLogs.locale.update": "Update locale",
213
217
  "Settings.permissions.auditLogs.media.create": "Create media",
214
218
  "Settings.permissions.auditLogs.media.delete": "Delete media",
215
219
  "Settings.permissions.auditLogs.media.update": "Update media",
@@ -540,6 +544,12 @@ var en = {
540
544
  "app.components.PluginCard.PopUpWarning.install.impossible.title": "Downloading is impossible",
541
545
  "app.components.PluginCard.compatible": "Compatible with your app",
542
546
  "app.components.PluginCard.compatibleCommunity": "Compatible with the community",
547
+ "app.components.MediaLibraryBanner.button": "Docs",
548
+ "app.components.MediaLibraryBanner.button.enabled": "Read blog post",
549
+ "app.components.MediaLibraryBanner.close": "Close the banner. ",
550
+ "app.components.MediaLibraryBanner.intro": "Introducing the new Media Library ",
551
+ "app.components.MediaLibraryBanner.text": "Check the documentation to learn how to switch to the new one.",
552
+ "app.components.MediaLibraryBanner.text.enabled": "You're now using the revamped version.",
543
553
  "app.components.PluginCard.more-details": "More details",
544
554
  "app.components.Select.placeholder": "Select",
545
555
  "app.components.ToggleCheckbox.off-label": "False",
@@ -579,6 +589,8 @@ var en = {
579
589
  "app.containers.Users.ModalForm.footer.button-success": "Invite user",
580
590
  "app.links.configure-view": "Configure the view",
581
591
  "app.page.not.found": "Oops! We can't seem to find the page you're looking for...",
592
+ "app.session.ended.title": "Session ended",
593
+ "app.session.ended.unsaved": "Your session has ended and can't be resumed. Your unsaved changes will be lost when you log out.",
582
594
  "app.static.links.cheatsheet": "CheatSheet",
583
595
  "app.utils.SelectOption.defaultMessage": " ",
584
596
  "app.utils.add-filter": "Add filter",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -206,6 +206,10 @@ var en = {
206
206
  "Settings.permissions.auditLogs.listview.export.ready.title": "Export ready",
207
207
  "Settings.permissions.auditLogs.listview.header.subtitle": "Logs of all the activities that happened in your environment",
208
208
  "Settings.permissions.auditLogs.not-available": "Audit Logs is only available as part of a paid plan. Upgrade to get a searchable and filterable display of all activities.",
209
+ "Settings.permissions.auditLogs.locale.create": "Create locale",
210
+ "Settings.permissions.auditLogs.locale.default.update": "Change default locale",
211
+ "Settings.permissions.auditLogs.locale.delete": "Delete locale",
212
+ "Settings.permissions.auditLogs.locale.update": "Update locale",
209
213
  "Settings.permissions.auditLogs.media.create": "Create media",
210
214
  "Settings.permissions.auditLogs.media.delete": "Delete media",
211
215
  "Settings.permissions.auditLogs.media.update": "Update media",
@@ -536,6 +540,12 @@ var en = {
536
540
  "app.components.PluginCard.PopUpWarning.install.impossible.title": "Downloading is impossible",
537
541
  "app.components.PluginCard.compatible": "Compatible with your app",
538
542
  "app.components.PluginCard.compatibleCommunity": "Compatible with the community",
543
+ "app.components.MediaLibraryBanner.button": "Docs",
544
+ "app.components.MediaLibraryBanner.button.enabled": "Read blog post",
545
+ "app.components.MediaLibraryBanner.close": "Close the banner. ",
546
+ "app.components.MediaLibraryBanner.intro": "Introducing the new Media Library ",
547
+ "app.components.MediaLibraryBanner.text": "Check the documentation to learn how to switch to the new one.",
548
+ "app.components.MediaLibraryBanner.text.enabled": "You're now using the revamped version.",
539
549
  "app.components.PluginCard.more-details": "More details",
540
550
  "app.components.Select.placeholder": "Select",
541
551
  "app.components.ToggleCheckbox.off-label": "False",
@@ -575,6 +585,8 @@ var en = {
575
585
  "app.containers.Users.ModalForm.footer.button-success": "Invite user",
576
586
  "app.links.configure-view": "Configure the view",
577
587
  "app.page.not.found": "Oops! We can't seem to find the page you're looking for...",
588
+ "app.session.ended.title": "Session ended",
589
+ "app.session.ended.unsaved": "Your session has ended and can't be resumed. Your unsaved changes will be lost when you log out.",
578
590
  "app.static.links.cheatsheet": "CheatSheet",
579
591
  "app.utils.SelectOption.defaultMessage": " ",
580
592
  "app.utils.add-filter": "Add filter",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var reducer = require('../reducer.js');
4
3
  var getFetchClient = require('./getFetchClient.js');
5
4
 
6
5
  const isAuthPath = (url)=>/^\/admin\/(login|logout|access-token)\b/.test(url);
7
6
  const simpleQuery = async (query, api)=>{
8
- const { signal, dispatch } = api;
7
+ const { signal } = api;
9
8
  const executeQuery = async (queryToExecute)=>{
10
9
  const { get, post, del, put } = getFetchClient.getFetchClient();
11
10
  if (typeof queryToExecute === 'string') {
@@ -51,17 +50,8 @@ const simpleQuery = async (query, api)=>{
51
50
  if (err.status === 401) {
52
51
  const url = typeof query === 'string' ? query : query.url;
53
52
  if (!isAuthPath(url)) {
54
- try {
55
- const { post } = getFetchClient.getFetchClient();
56
- await post('/admin/logout');
57
- } catch {
58
- // no-op
59
- }
60
- dispatch(reducer.logout());
61
- // Notify the React layer so the active tab redirects to /auth/login.
62
- // Without this, only other tabs (via the storage event) would react;
63
- // the tab that originated the failing request would stay put until
64
- // the user clicked something or refreshed.
53
+ // Defer clearing auth state to AuthProvider so unsaved-change guards
54
+ // can run before token removal (which unmounts edit forms).
65
55
  getFetchClient.triggerSessionExpired();
66
56
  }
67
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"baseQuery.js","sources":["../../../../../admin/src/utils/baseQuery.ts"],"sourcesContent":["import { SerializedError } from '@reduxjs/toolkit';\nimport { BaseQueryFn } from '@reduxjs/toolkit/query';\n\nimport { logout as logoutAction } from '../reducer';\nimport {\n getFetchClient,\n triggerSessionExpired,\n type FetchOptions,\n ApiError,\n isFetchError,\n} from '../utils/getFetchClient';\n\ninterface QueryArguments {\n url: string;\n method?: 'GET' | 'POST' | 'DELETE' | 'PUT';\n data?: unknown;\n config?: FetchOptions;\n}\n\ninterface UnknownApiError {\n name: 'UnknownError';\n message: string;\n details?: unknown;\n status?: number;\n}\n\ntype BaseQueryError = ApiError | UnknownApiError;\n\nconst isAuthPath = (url: string) => /^\\/admin\\/(login|logout|access-token)\\b/.test(url);\n\nconst simpleQuery: BaseQueryFn<\n string | QueryArguments,\n unknown,\n BaseQueryError | SerializedError\n> = async (query, api) => {\n const { signal, dispatch } = api;\n\n const executeQuery = async (queryToExecute: string | QueryArguments) => {\n const { get, post, del, put } = getFetchClient();\n if (typeof queryToExecute === 'string') {\n const result = await get(queryToExecute, { signal });\n return result;\n }\n\n const { url, method = 'GET', data, config } = queryToExecute;\n if (method === 'POST') {\n return post(url, data, { ...config, signal });\n }\n if (method === 'DELETE') {\n return del(url, { ...config, signal });\n }\n if (method === 'PUT') {\n return put(url, data, { ...config, signal });\n }\n return get(url, { ...config, signal });\n };\n\n try {\n const result = await executeQuery(query);\n return { data: result.data };\n } catch (err) {\n // Handle error of type FetchError\n\n if (isFetchError(err)) {\n // If we receive a 401 here, getFetchClient already tried to refresh and failed.\n // Log the user out since their session is no longer valid.\n if (err.status === 401) {\n const url = typeof query === 'string' ? query : query.url;\n\n if (!isAuthPath(url)) {\n try {\n const { post } = getFetchClient();\n await post('/admin/logout');\n } catch {\n // no-op\n }\n\n dispatch(logoutAction());\n // Notify the React layer so the active tab redirects to /auth/login.\n // Without this, only other tabs (via the storage event) would react;\n // the tab that originated the failing request would stay put until\n // the user clicked something or refreshed.\n triggerSessionExpired();\n }\n }\n\n const responseData = err.response?.data;\n\n if (typeof responseData === 'object' && responseData !== null && 'error' in responseData) {\n /**\n * This will most likely be ApiError\n */\n return { data: undefined, error: responseData.error as BaseQueryError };\n } else {\n return {\n data: undefined,\n error: {\n name: 'UnknownError',\n message: err.message,\n details: err.response,\n status: err.status,\n } as UnknownApiError,\n };\n }\n }\n\n const error = err instanceof Error ? err : new Error('Unknown error');\n return {\n data: undefined,\n error: {\n name: error.name,\n message: error.message,\n stack: error.stack,\n } satisfies SerializedError,\n };\n }\n};\n\nconst fetchBaseQuery = () => simpleQuery;\n\nconst isBaseQueryError = (error: BaseQueryError | SerializedError): error is BaseQueryError => {\n return error.name !== undefined;\n};\n\nexport { fetchBaseQuery, isBaseQueryError };\nexport type { BaseQueryError, UnknownApiError, QueryArguments };\n"],"names":["isAuthPath","url","test","simpleQuery","query","api","signal","dispatch","executeQuery","queryToExecute","get","post","del","put","getFetchClient","result","method","data","config","err","isFetchError","status","logoutAction","triggerSessionExpired","responseData","response","undefined","error","name","message","details","Error","stack","fetchBaseQuery","isBaseQueryError"],"mappings":";;;;;AA4BA,MAAMA,UAAAA,GAAa,CAACC,GAAAA,GAAgB,yCAAA,CAA0CC,IAAI,CAACD,GAAAA,CAAAA;AAEnF,MAAME,WAAAA,GAIF,OAAOC,KAAAA,EAAOC,GAAAA,GAAAA;AAChB,IAAA,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF,GAAAA;AAE7B,IAAA,MAAMG,eAAe,OAAOC,cAAAA,GAAAA;QAC1B,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,GAAG,EAAE,GAAGC,6BAAAA,EAAAA;QAChC,IAAI,OAAOL,mBAAmB,QAAA,EAAU;YACtC,MAAMM,MAAAA,GAAS,MAAML,GAAAA,CAAID,cAAAA,EAAgB;AAAEH,gBAAAA;AAAO,aAAA,CAAA;YAClD,OAAOS,MAAAA;AACT,QAAA;QAEA,MAAM,EAAEd,GAAG,EAAEe,MAAAA,GAAS,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGT,cAAAA;AA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AA,oCAAAA,EAAAA;AACF,gBAAA;AACF,YAAA;YAEA,MAAMC,YAAAA,GAAeL,GAAAA,CAAIM,QAAQ,EAAER,IAAAA;AAEnC,YAAA,IAAI,OAAOO,YAAAA,KAAiB,QAAA,IAAYA,YAAAA,KAAiB,IAAA,IAAQ,WAAWA,YAAAA,EAAc;AACxF;;AAEC,YACD,OAAO;oBAAEP,IAAAA,EAAMS,SAAAA;AAAWC,oBAAAA,KAAAA,EAAOH,aAAaG;AAAwB,iBAAA;YACxE,CAAA,MAAO;gBACL,OAAO;oBACLV,IAAAA,EAAMS,SAAAA;oBACNC,KAAAA,EAAO;wBACLC,IAAAA,EAAM,cAAA;AACNC,wBAAAA,OAAAA,EAASV,IAAIU,OAAO;AACpBC,wBAAAA,OAAAA,EAASX,IAAIM,QAAQ;AACrBJ,wBAAAA,MAAAA,EAAQF,IAAIE;AACd;AACF,iBAAA;AACF,YAAA;AACF,QAAA;AAEA,QAAA,MAAMM,KAAAA,GAAQR,GAAAA,YAAeY,KAAAA,GAAQZ,GAAAA,GAAM,IAAIY,KAAAA,CAAM,eAAA,CAAA;QACrD,OAAO;YACLd,IAAAA,EAAMS,SAAAA;YACNC,KAAAA,EAAO;AACLC,gBAAAA,IAAAA,EAAMD,MAAMC,IAAI;AAChBC,gBAAAA,OAAAA,EAASF,MAAME,OAAO;AACtBG,gBAAAA,KAAAA,EAAOL,MAAMK;AACf;AACF,SAAA;AACF,IAAA;AACF,CAAA;AAEA,MAAMC,iBAAiB,IAAM9B;AAE7B,MAAM+B,mBAAmB,CAACP,KAAAA,GAAAA;IACxB,OAAOA,KAAAA,CAAMC,IAAI,KAAKF,SAAAA;AACxB;;;;;"}
1
+ {"version":3,"file":"baseQuery.js","sources":["../../../../../admin/src/utils/baseQuery.ts"],"sourcesContent":["import { SerializedError } from '@reduxjs/toolkit';\nimport { BaseQueryFn } from '@reduxjs/toolkit/query';\n\nimport {\n getFetchClient,\n triggerSessionExpired,\n type FetchOptions,\n ApiError,\n isFetchError,\n} from '../utils/getFetchClient';\n\ninterface QueryArguments {\n url: string;\n method?: 'GET' | 'POST' | 'DELETE' | 'PUT';\n data?: unknown;\n config?: FetchOptions;\n}\n\ninterface UnknownApiError {\n name: 'UnknownError';\n message: string;\n details?: unknown;\n status?: number;\n}\n\ntype BaseQueryError = ApiError | UnknownApiError;\n\nconst isAuthPath = (url: string) => /^\\/admin\\/(login|logout|access-token)\\b/.test(url);\n\nconst simpleQuery: BaseQueryFn<\n string | QueryArguments,\n unknown,\n BaseQueryError | SerializedError\n> = async (query, api) => {\n const { signal } = api;\n\n const executeQuery = async (queryToExecute: string | QueryArguments) => {\n const { get, post, del, put } = getFetchClient();\n if (typeof queryToExecute === 'string') {\n const result = await get(queryToExecute, { signal });\n return result;\n }\n\n const { url, method = 'GET', data, config } = queryToExecute;\n if (method === 'POST') {\n return post(url, data, { ...config, signal });\n }\n if (method === 'DELETE') {\n return del(url, { ...config, signal });\n }\n if (method === 'PUT') {\n return put(url, data, { ...config, signal });\n }\n return get(url, { ...config, signal });\n };\n\n try {\n const result = await executeQuery(query);\n return { data: result.data };\n } catch (err) {\n // Handle error of type FetchError\n\n if (isFetchError(err)) {\n // If we receive a 401 here, getFetchClient already tried to refresh and failed.\n // Log the user out since their session is no longer valid.\n if (err.status === 401) {\n const url = typeof query === 'string' ? query : query.url;\n\n if (!isAuthPath(url)) {\n // Defer clearing auth state to AuthProvider so unsaved-change guards\n // can run before token removal (which unmounts edit forms).\n triggerSessionExpired();\n }\n }\n\n const responseData = err.response?.data;\n\n if (typeof responseData === 'object' && responseData !== null && 'error' in responseData) {\n /**\n * This will most likely be ApiError\n */\n return { data: undefined, error: responseData.error as BaseQueryError };\n } else {\n return {\n data: undefined,\n error: {\n name: 'UnknownError',\n message: err.message,\n details: err.response,\n status: err.status,\n } as UnknownApiError,\n };\n }\n }\n\n const error = err instanceof Error ? err : new Error('Unknown error');\n return {\n data: undefined,\n error: {\n name: error.name,\n message: error.message,\n stack: error.stack,\n } satisfies SerializedError,\n };\n }\n};\n\nconst fetchBaseQuery = () => simpleQuery;\n\nconst isBaseQueryError = (error: BaseQueryError | SerializedError): error is BaseQueryError => {\n return error.name !== undefined;\n};\n\nexport { fetchBaseQuery, isBaseQueryError };\nexport type { BaseQueryError, UnknownApiError, QueryArguments };\n"],"names":["isAuthPath","url","test","simpleQuery","query","api","signal","executeQuery","queryToExecute","get","post","del","put","getFetchClient","result","method","data","config","err","isFetchError","status","triggerSessionExpired","responseData","response","undefined","error","name","message","details","Error","stack","fetchBaseQuery","isBaseQueryError"],"mappings":";;;;AA2BA,MAAMA,UAAAA,GAAa,CAACC,GAAAA,GAAgB,yCAAA,CAA0CC,IAAI,CAACD,GAAAA,CAAAA;AAEnF,MAAME,WAAAA,GAIF,OAAOC,KAAAA,EAAOC,GAAAA,GAAAA;IAChB,MAAM,EAAEC,MAAM,EAAE,GAAGD,GAAAA;AAEnB,IAAA,MAAME,eAAe,OAAOC,cAAAA,GAAAA;QAC1B,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,GAAG,EAAE,GAAGC,6BAAAA,EAAAA;QAChC,IAAI,OAAOL,mBAAmB,QAAA,EAAU;YACtC,MAAMM,MAAAA,GAAS,MAAML,GAAAA,CAAID,cAAAA,EAAgB;AAAEF,gBAAAA;AAAO,aAAA,CAAA;YAClD,OAAOQ,MAAAA;AACT,QAAA;QAEA,MAAM,EAAEb,GAAG,EAAEc,MAAAA,GAAS,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGT,cAAAA;AAC9C,QAAA,IAAIO,WAAW,MAAA,EAAQ;YACrB,OAAOL,IAAAA,CAAKT,KAAKe,IAAAA,EAAM;AAAE,gBAAA,GAAGC,MAAM;AAAEX,gBAAAA;AAAO,aAAA,CAAA;AAC7C,QAAA;AACA,QAAA,IAAIS,WAAW,QAAA,EAAU;AACvB,YAAA,OAAOJ,IAAIV,GAAAA,EAAK;AAAE,gBAAA,GAAGgB,MAAM;AA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AAA,OAAAA,EAASV,IAAIK,QAAQ;AACrBH,wBAAAA,MAAAA,EAAQF,IAAIE;AACd;AACF,iBAAA;AACF,YAAA;AACF,QAAA;AAEA,QAAA,MAAMK,KAAAA,GAAQP,GAAAA,YAAeW,KAAAA,GAAQX,GAAAA,GAAM,IAAIW,KAAAA,CAAM,eAAA,CAAA;QACrD,OAAO;YACLb,IAAAA,EAAMQ,SAAAA;YACNC,KAAAA,EAAO;AACLC,gBAAAA,IAAAA,EAAMD,MAAMC,IAAI;AAChBC,gBAAAA,OAAAA,EAASF,MAAME,OAAO;AACtBG,gBAAAA,KAAAA,EAAOL,MAAMK;AACf;AACF,SAAA;AACF,IAAA;AACF,CAAA;AAEA,MAAMC,iBAAiB,IAAM5B;AAE7B,MAAM6B,mBAAmB,CAACP,KAAAA,GAAAA;IACxB,OAAOA,KAAAA,CAAMC,IAAI,KAAKF,SAAAA;AACxB;;;;;"}
@@ -1,9 +1,8 @@
1
- import { logout } from '../reducer.mjs';
2
1
  import { isFetchError, getFetchClient, triggerSessionExpired } from './getFetchClient.mjs';
3
2
 
4
3
  const isAuthPath = (url)=>/^\/admin\/(login|logout|access-token)\b/.test(url);
5
4
  const simpleQuery = async (query, api)=>{
6
- const { signal, dispatch } = api;
5
+ const { signal } = api;
7
6
  const executeQuery = async (queryToExecute)=>{
8
7
  const { get, post, del, put } = getFetchClient();
9
8
  if (typeof queryToExecute === 'string') {
@@ -49,17 +48,8 @@ const simpleQuery = async (query, api)=>{
49
48
  if (err.status === 401) {
50
49
  const url = typeof query === 'string' ? query : query.url;
51
50
  if (!isAuthPath(url)) {
52
- try {
53
- const { post } = getFetchClient();
54
- await post('/admin/logout');
55
- } catch {
56
- // no-op
57
- }
58
- dispatch(logout());
59
- // Notify the React layer so the active tab redirects to /auth/login.
60
- // Without this, only other tabs (via the storage event) would react;
61
- // the tab that originated the failing request would stay put until
62
- // the user clicked something or refreshed.
51
+ // Defer clearing auth state to AuthProvider so unsaved-change guards
52
+ // can run before token removal (which unmounts edit forms).
63
53
  triggerSessionExpired();
64
54
  }
65
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"baseQuery.mjs","sources":["../../../../../admin/src/utils/baseQuery.ts"],"sourcesContent":["import { SerializedError } from '@reduxjs/toolkit';\nimport { BaseQueryFn } from '@reduxjs/toolkit/query';\n\nimport { logout as logoutAction } from '../reducer';\nimport {\n getFetchClient,\n triggerSessionExpired,\n type FetchOptions,\n ApiError,\n isFetchError,\n} from '../utils/getFetchClient';\n\ninterface QueryArguments {\n url: string;\n method?: 'GET' | 'POST' | 'DELETE' | 'PUT';\n data?: unknown;\n config?: FetchOptions;\n}\n\ninterface UnknownApiError {\n name: 'UnknownError';\n message: string;\n details?: unknown;\n status?: number;\n}\n\ntype BaseQueryError = ApiError | UnknownApiError;\n\nconst isAuthPath = (url: string) => /^\\/admin\\/(login|logout|access-token)\\b/.test(url);\n\nconst simpleQuery: BaseQueryFn<\n string | QueryArguments,\n unknown,\n BaseQueryError | SerializedError\n> = async (query, api) => {\n const { signal, dispatch } = api;\n\n const executeQuery = async (queryToExecute: string | QueryArguments) => {\n const { get, post, del, put } = getFetchClient();\n if (typeof queryToExecute === 'string') {\n const result = await get(queryToExecute, { signal });\n return result;\n }\n\n const { url, method = 'GET', data, config } = queryToExecute;\n if (method === 'POST') {\n return post(url, data, { ...config, signal });\n }\n if (method === 'DELETE') {\n return del(url, { ...config, signal });\n }\n if (method === 'PUT') {\n return put(url, data, { ...config, signal });\n }\n return get(url, { ...config, signal });\n };\n\n try {\n const result = await executeQuery(query);\n return { data: result.data };\n } catch (err) {\n // Handle error of type FetchError\n\n if (isFetchError(err)) {\n // If we receive a 401 here, getFetchClient already tried to refresh and failed.\n // Log the user out since their session is no longer valid.\n if (err.status === 401) {\n const url = typeof query === 'string' ? query : query.url;\n\n if (!isAuthPath(url)) {\n try {\n const { post } = getFetchClient();\n await post('/admin/logout');\n } catch {\n // no-op\n }\n\n dispatch(logoutAction());\n // Notify the React layer so the active tab redirects to /auth/login.\n // Without this, only other tabs (via the storage event) would react;\n // the tab that originated the failing request would stay put until\n // the user clicked something or refreshed.\n triggerSessionExpired();\n }\n }\n\n const responseData = err.response?.data;\n\n if (typeof responseData === 'object' && responseData !== null && 'error' in responseData) {\n /**\n * This will most likely be ApiError\n */\n return { data: undefined, error: responseData.error as BaseQueryError };\n } else {\n return {\n data: undefined,\n error: {\n name: 'UnknownError',\n message: err.message,\n details: err.response,\n status: err.status,\n } as UnknownApiError,\n };\n }\n }\n\n const error = err instanceof Error ? err : new Error('Unknown error');\n return {\n data: undefined,\n error: {\n name: error.name,\n message: error.message,\n stack: error.stack,\n } satisfies SerializedError,\n };\n }\n};\n\nconst fetchBaseQuery = () => simpleQuery;\n\nconst isBaseQueryError = (error: BaseQueryError | SerializedError): error is BaseQueryError => {\n return error.name !== undefined;\n};\n\nexport { fetchBaseQuery, isBaseQueryError };\nexport type { BaseQueryError, UnknownApiError, QueryArguments };\n"],"names":["isAuthPath","url","test","simpleQuery","query","api","signal","dispatch","executeQuery","queryToExecute","get","post","del","put","getFetchClient","result","method","data","config","err","isFetchError","status","logoutAction","triggerSessionExpired","responseData","response","undefined","error","name","message","details","Error","stack","fetchBaseQuery","isBaseQueryError"],"mappings":";;;AA4BA,MAAMA,UAAAA,GAAa,CAACC,GAAAA,GAAgB,yCAAA,CAA0CC,IAAI,CAACD,GAAAA,CAAAA;AAEnF,MAAME,WAAAA,GAIF,OAAOC,KAAAA,EAAOC,GAAAA,GAAAA;AAChB,IAAA,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGF,GAAAA;AAE7B,IAAA,MAAMG,eAAe,OAAOC,cAAAA,GAAAA;QAC1B,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,GAAG,EAAE,GAAGC,cAAAA,EAAAA;QAChC,IAAI,OAAOL,mBAAmB,QAAA,EAAU;YACtC,MAAMM,MAAAA,GAAS,MAAML,GAAAA,CAAID,cAAAA,EAAgB;A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","sources":["../../../../../admin/src/utils/baseQuery.ts"],"sourcesContent":["import { SerializedError } from '@reduxjs/toolkit';\nimport { BaseQueryFn } from '@reduxjs/toolkit/query';\n\nimport {\n getFetchClient,\n triggerSessionExpired,\n type FetchOptions,\n ApiError,\n isFetchError,\n} from '../utils/getFetchClient';\n\ninterface QueryArguments {\n url: string;\n method?: 'GET' | 'POST' | 'DELETE' | 'PUT';\n data?: unknown;\n config?: FetchOptions;\n}\n\ninterface UnknownApiError {\n name: 'UnknownError';\n message: string;\n details?: unknown;\n status?: number;\n}\n\ntype BaseQueryError = ApiError | UnknownApiError;\n\nconst isAuthPath = (url: string) => /^\\/admin\\/(login|logout|access-token)\\b/.test(url);\n\nconst simpleQuery: BaseQueryFn<\n string | QueryArguments,\n unknown,\n BaseQueryError | SerializedError\n> = async (query, api) => {\n const { signal } = api;\n\n const executeQuery = async (queryToExecute: string | QueryArguments) => {\n const { get, post, del, put } = getFetchClient();\n if (typeof queryToExecute === 'string') {\n const result = await get(queryToExecute, { signal });\n return result;\n }\n\n const { url, method = 'GET', data, config } = queryToExecute;\n if (method === 'POST') {\n return post(url, data, { ...config, signal });\n }\n if (method === 'DELETE') {\n return del(url, { ...config, signal });\n }\n if (method === 'PUT') {\n return put(url, data, { ...config, signal });\n }\n return get(url, { ...config, signal });\n };\n\n try {\n const result = await executeQuery(query);\n return { data: result.data };\n } catch (err) {\n // Handle error of type FetchError\n\n if (isFetchError(err)) {\n // If we receive a 401 here, getFetchClient already tried to refresh and failed.\n // Log the user out since their session is no longer valid.\n if (err.status === 401) {\n const url = typeof query === 'string' ? query : query.url;\n\n if (!isAuthPath(url)) {\n // Defer clearing auth state to AuthProvider so unsaved-change guards\n // can run before token removal (which unmounts edit forms).\n triggerSessionExpired();\n }\n }\n\n const responseData = err.response?.data;\n\n if (typeof responseData === 'object' && responseData !== null && 'error' in responseData) {\n /**\n * This will most likely be ApiError\n */\n return { data: undefined, error: responseData.error as BaseQueryError };\n } else {\n return {\n data: undefined,\n error: {\n name: 'UnknownError',\n message: err.message,\n details: err.response,\n status: err.status,\n } as UnknownApiError,\n };\n }\n }\n\n const error = err instanceof Error ? err : new Error('Unknown error');\n return {\n data: undefined,\n error: {\n name: error.name,\n message: error.message,\n stack: error.stack,\n } satisfies SerializedError,\n };\n }\n};\n\nconst fetchBaseQuery = () => simpleQuery;\n\nconst isBaseQueryError = (error: BaseQueryError | SerializedError): error is BaseQueryError => {\n return error.name !== undefined;\n};\n\nexport { fetchBaseQuery, isBaseQueryError };\nexport type { BaseQueryError, UnknownApiError, QueryArguments };\n"],"names":["isAuthPath","url","test","simpleQuery","query","api","signal","executeQuery","queryToExecute","get","post","del","put","getFetchClient","result","method","data","config","err","isFetchError","status","triggerSessionExpired","responseData","response","undefined","error","name","message","details","Error","stack","fetchBaseQuery","isBaseQueryError"],"mappings":";;AA2BA,MAAMA,UAAAA,GAAa,CAACC,GAAAA,GAAgB,yCAAA,CAA0CC,IAAI,CAACD,GAAAA,CAAAA;AAEnF,MAAME,WAAAA,GAIF,OAAOC,KAAAA,EAAOC,GAAAA,GAAAA;IAChB,MAAM,EAAEC,MAAM,EAAE,GAAGD,GAAAA;AAEnB,IAAA,MAAME,eAAe,OAAOC,cAAAA,GAAAA;QAC1B,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,GAAG,EAAE,GAAGC,cAAAA,EAAAA;QAChC,IAAI,OAAOL,mBAAmB,QAAA,EAAU;YACtC,MAAMM,MAAAA,GAAS,MAAML,GAAAA,CAAID,cAAAA,EAAgB;AAAEF,gBAAAA;AAAO,aAAA,CAAA;YAClD,OAAOQ,MAAAA;AACT,QAAA;QAEA,MAAM,EAAEb,GAAG,EAAEc,MAAAA,GAAS,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGT,cAAAA;AAC9C,QAAA,IAAIO,WAAW,MAAA,EAAQ;YACrB,OAAOL,IAAAA,CAAKT,KAAKe,IAAAA,EAAM;AAAE,gBAAA,GAAGC,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YACxE,CAAA,MAAO;gBACL,OAAO;oBACLT,IAAAA,EAAMQ,SAAAA;oBACNC,KAAAA,EAAO;wBACLC,IAAAA,EAAM,cAAA;AACNC,wBAAAA,OAAAA,EAAST,IAAIS,OAAO;AACpBC,wBAAAA,OAAAA,EAASV,IAAIK,QAAQ;AACrBH,wBAAAA,MAAAA,EAAQF,IAAIE;AACd;AACF,iBAAA;AACF,YAAA;AACF,QAAA;AAEA,QAAA,MAAMK,KAAAA,GAAQP,GAAAA,YAAeW,KAAAA,GAAQX,GAAAA,GAAM,IAAIW,KAAAA,CAAM,eAAA,CAAA;QACrD,OAAO;YACLb,IAAAA,EAAMQ,SAAAA;YACNC,KAAAA,EAAO;AACLC,gBAAAA,IAAAA,EAAMD,MAAMC,IAAI;AAChBC,gBAAAA,OAAAA,EAASF,MAAME,OAAO;AACtBG,gBAAAA,KAAAA,EAAOL,MAAMK;AACf;AACF,SAAA;AACF,IAAA;AACF,CAAA;AAEA,MAAMC,iBAAiB,IAAM5B;AAE7B,MAAM6B,mBAAmB,CAACP,KAAAA,GAAAA;IACxB,OAAOA,KAAAA,CAAMC,IAAI,KAAKF,SAAAA;AACxB;;;;"}
@@ -24,6 +24,12 @@ const STORAGE_KEYS = {
24
24
  * session expired). The React layer registers a handler that clears local
25
25
  * auth state and navigates to /auth/login.
26
26
  */ let onSessionExpired = null;
27
+ /**
28
+ * A 401 after a failed refresh is delivered twice in the common RTK path
29
+ * (baseQuery, then the store middleware). Concurrent in-flight queries can
30
+ * add more. Fire the React handler once per dead session; re-arm when a new
31
+ * token is stored (refresh or login).
32
+ */ let sessionExpiredNotified = false;
27
33
  /**
28
34
  * Set the callback that will be called when the token is refreshed.
29
35
  * This allows the React layer to update Redux state when a token refresh occurs.
@@ -40,19 +46,39 @@ const STORAGE_KEYS = {
40
46
  };
41
47
  /**
42
48
  * Set the callback that will be called when the active session is no longer
43
- * valid (refresh token rejected by the server, or detected idle on the
44
- * client). This lets the active tab redirect to /auth/login without waiting
45
- * for the next user-initiated request to fail.
49
+ * valid — i.e. the server rejected the refresh token, not merely that the
50
+ * short-lived access token expired. This lets the tab redirect to /auth/login
51
+ * (after any unsaved-changes guard) rather than sitting on a dead session.
46
52
  *
47
53
  * @param callback - Function to call when the session ends, or null to clear
48
54
  */ const setOnSessionExpired = (callback)=>{
49
55
  onSessionExpired = callback;
56
+ if (callback === null) {
57
+ resetSessionExpiredNotification();
58
+ }
59
+ };
60
+ /**
61
+ * Re-arm session-expired notifications after a new access token is stored
62
+ * (silent refresh) or after a successful login.
63
+ */ const resetSessionExpiredNotification = ()=>{
64
+ sessionExpiredNotified = false;
50
65
  };
51
66
  /**
52
67
  * Trigger the registered session-expired callback, if any. Safe to call from
53
- * non-React code (e.g., the RTK Query baseQuery 401 handler).
68
+ * non-React code (e.g., the RTK Query baseQuery 401 handler). Returns `false`
69
+ * when nothing is listening, so callers can fall back to a hard redirect
70
+ * instead of leaving the user on a dead page. Subsequent calls during the same
71
+ * dead session return `true` without invoking the handler again.
54
72
  */ const triggerSessionExpired = ()=>{
55
- onSessionExpired?.();
73
+ if (!onSessionExpired) {
74
+ return false;
75
+ }
76
+ if (sessionExpiredNotified) {
77
+ return true;
78
+ }
79
+ sessionExpiredNotified = true;
80
+ onSessionExpired();
81
+ return true;
56
82
  };
57
83
  /**
58
84
  * Check if the URL is an auth path that should not trigger token refresh.
@@ -69,6 +95,7 @@ const STORAGE_KEYS = {
69
95
  * @param token - The JWT token to store
70
96
  * @internal Exported for testing purposes
71
97
  */ const storeToken = (token)=>{
98
+ resetSessionExpiredNotification();
72
99
  // Check if the original token was stored in localStorage (persist mode)
73
100
  const wasPersistedToLocalStorage = Boolean(localStorage.getItem(STORAGE_KEYS.TOKEN));
74
101
  if (wasPersistedToLocalStorage) {
@@ -101,6 +128,7 @@ const postAccessToken = (backendURL)=>fetch(`${backendURL}/admin/access-token`,
101
128
  }
102
129
  });
103
130
  const adoptSharedAccessToken = (token)=>{
131
+ resetSessionExpiredNotification();
104
132
  if (onTokenUpdate) {
105
133
  onTokenUpdate(token);
106
134
  }
@@ -476,6 +504,7 @@ exports.attemptTokenRefresh = attemptTokenRefresh;
476
504
  exports.getFetchClient = getFetchClient;
477
505
  exports.isFetchError = isFetchError;
478
506
  exports.refreshAccessToken = refreshAccessToken;
507
+ exports.resetSessionExpiredNotification = resetSessionExpiredNotification;
479
508
  exports.setOnSessionExpired = setOnSessionExpired;
480
509
  exports.setOnTokenUpdate = setOnTokenUpdate;
481
510
  exports.storeToken = storeToken;
@@ -1 +1 @@
1
- {"version":3,"file":"getFetchClient.js","sources":["../../../../../admin/src/utils/getFetchClient.ts"],"sourcesContent":["import pipe from 'lodash/fp/pipe';\n// eslint-disable-next-line import/default\nimport qs from 'qs';\n\nimport { AUTH_COOKIE_NAME, getCookieValue, setCookie } from './cookies';\nimport { decodeAccessTokenExpiry } from './jwt';\n\nimport type { errors } from '@strapi/utils';\n\nexport type ApiError =\n | errors.ApplicationError\n | errors.ForbiddenError\n | errors.NotFoundError\n | errors.NotImplementedError\n | errors.PaginationError\n | errors.PayloadTooLargeError\n | errors.PolicyError\n | errors.RateLimitError\n | errors.UnauthorizedError\n | errors.ValidationError\n | errors.YupValidationError;\n\nconst STORAGE_KEYS = {\n TOKEN: 'jwtToken',\n USER: 'userInfo',\n};\n\n/**\n * Module-level promise to ensure only one token refresh happens at a time\n */\nlet refreshPromise: Promise<string | null> | null = null;\n\n/**\n * Callback to notify the app when the token is updated (e.g., to update Redux state)\n */\nlet onTokenUpdate: ((token: string) => void) | null = null;\n\n/**\n * Callback to notify the app when the session has been terminated and the user\n * should be redirected to the login page (e.g., refresh token rejected, idle\n * session expired). The React layer registers a handler that clears local\n * auth state and navigates to /auth/login.\n */\nlet onSessionExpired: (() => void) | null = null;\n\n/**\n * Set the callback that will be called when the token is refreshed.\n * This allows the React layer to update Redux state when a token refresh occurs.\n *\n * @param callback - Function to call with the new token, or null to clear\n * @example\n * // In a React component\n * useEffect(() => {\n * setOnTokenUpdate((token) => dispatch(setToken(token)));\n * return () => setOnTokenUpdate(null);\n * }, [dispatch]);\n */\nconst setOnTokenUpdate = (callback: ((token: string) => void) | null): void => {\n onTokenUpdate = callback;\n};\n\n/**\n * Set the callback that will be called when the active session is no longer\n * valid (refresh token rejected by the server, or detected idle on the\n * client). This lets the active tab redirect to /auth/login without waiting\n * for the next user-initiated request to fail.\n *\n * @param callback - Function to call when the session ends, or null to clear\n */\nconst setOnSessionExpired = (callback: (() => void) | null): void => {\n onSessionExpired = callback;\n};\n\n/**\n * Trigger the registered session-expired callback, if any. Safe to call from\n * non-React code (e.g., the RTK Query baseQuery 401 handler).\n */\nconst triggerSessionExpired = (): void => {\n onSessionExpired?.();\n};\n\n/**\n * Check if the URL is an auth path that should not trigger token refresh.\n * Note: No ^ anchor since the URL may include the baseURL prefix (e.g., \"http://localhost:1337/admin/login\").\n * This differs from baseQuery.ts which uses ^/admin since it receives normalized paths.\n */\nconst isAuthPath = (url: string) => /\\/admin\\/(login|logout|access-token)\\b/.test(url);\n\n/**\n * Store the new token in the appropriate storage (localStorage or cookie)\n * and notify the app to update its state.\n *\n * Uses localStorage if the user selected \"remember me\" during login,\n * otherwise uses cookies for session-based storage.\n *\n * @param token - The JWT token to store\n * @internal Exported for testing purposes\n */\nconst storeToken = (token: string): void => {\n // Check if the original token was stored in localStorage (persist mode)\n const wasPersistedToLocalStorage = Boolean(localStorage.getItem(STORAGE_KEYS.TOKEN));\n\n if (wasPersistedToLocalStorage) {\n localStorage.setItem(STORAGE_KEYS.TOKEN, JSON.stringify(token));\n } else {\n setCookie(AUTH_COOKIE_NAME, token);\n }\n\n // Notify the app to update its state (e.g., Redux)\n if (onTokenUpdate) {\n onTokenUpdate(token);\n }\n};\n\nconst getToken = (): string | null => {\n const fromLocalStorage = localStorage.getItem(STORAGE_KEYS.TOKEN);\n if (fromLocalStorage) {\n return JSON.parse(fromLocalStorage);\n }\n\n const fromCookie = getCookieValue(AUTH_COOKIE_NAME);\n return fromCookie ?? null;\n};\n\nconst ADMIN_REFRESH_LOCK = 'strapi-admin-access-token';\nconst FALLBACK_ADOPT_TIMEOUT_MS = 250;\nconst FALLBACK_ADOPT_POLL_MS = 25;\n\nconst postAccessToken = (backendURL: string) =>\n fetch(`${backendURL}/admin/access-token`, {\n method: 'POST',\n credentials: 'include', // Include cookies for the refresh token\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n });\n\nconst adoptSharedAccessToken = (token: string): string => {\n if (onTokenUpdate) {\n onTokenUpdate(token);\n }\n return token;\n};\n\n/**\n * Another tab may have refreshed already and written a newer access token to the\n * shared localStorage/cookie. Per-tab Redux is not visible here — only shared\n * storage counts.\n */\nconst readValidAccessTokenFromSharedStorage = (staleToken: string | null): string | null => {\n const stored = getToken();\n if (!stored || stored === staleToken) {\n return null;\n }\n\n const expiry = decodeAccessTokenExpiry(stored);\n if (expiry === null || expiry <= Date.now()) {\n return null;\n }\n\n return stored;\n};\n\nconst waitForSharedAccessToken = async (staleToken: string | null): Promise<string | null> => {\n const timeoutAt = Date.now() + FALLBACK_ADOPT_TIMEOUT_MS;\n\n while (Date.now() < timeoutAt) {\n await new Promise((resolve) => {\n setTimeout(resolve, FALLBACK_ADOPT_POLL_MS);\n });\n\n const adopted = readValidAccessTokenFromSharedStorage(staleToken);\n if (adopted) {\n return adoptSharedAccessToken(adopted);\n }\n }\n\n return null;\n};\n\nconst executeRefreshAccessToken = async (\n backendURL: string,\n tokenBeforeRefresh: string | null,\n { allowHttpRetry }: { allowHttpRetry: boolean }\n): Promise<string | null> => {\n const adopted = readValidAccessTokenFromSharedStorage(tokenBeforeRefresh);\n if (adopted) {\n return adoptSharedAccessToken(adopted);\n }\n\n let response = await postAccessToken(backendURL);\n\n if (response.status === 401 && allowHttpRetry) {\n const adoptedAfterFail = readValidAccessTokenFromSharedStorage(tokenBeforeRefresh);\n if (adoptedAfterFail) {\n return adoptSharedAccessToken(adoptedAfterFail);\n }\n\n const adoptedAfterWait = await waitForSharedAccessToken(tokenBeforeRefresh);\n if (adoptedAfterWait) {\n return adoptedAfterWait;\n }\n\n response = await postAccessToken(backendURL);\n }\n\n if (!response.ok) {\n console.warn('[Auth] Token refresh failed with status:', response.status);\n return null;\n }\n\n const result = await response.json();\n const token = result?.data?.token as string | undefined;\n\n if (!token) {\n console.warn('[Auth] Token refresh response missing token');\n return null;\n }\n\n storeToken(token);\n return token;\n};\n\n/**\n * Refresh the access token by calling the /admin/access-token endpoint.\n * This uses a low-level fetch to avoid recursion through the interceptor.\n * Returns the new token on success, or null on failure.\n */\nconst refreshAccessToken = async (\n tokenUsedByFailedRequest?: string | null\n): Promise<string | null> => {\n const backendURL = window.strapi.backendURL;\n const tokenBeforeRefresh = tokenUsedByFailedRequest ?? getToken();\n\n try {\n if (typeof navigator !== 'undefined' && navigator.locks?.request) {\n return await navigator.locks.request(ADMIN_REFRESH_LOCK, () =>\n executeRefreshAccessToken(backendURL, tokenBeforeRefresh, { allowHttpRetry: false })\n );\n }\n\n return await executeRefreshAccessToken(backendURL, tokenBeforeRefresh, {\n allowHttpRetry: true,\n });\n } catch (error) {\n console.error('[Auth] Token refresh error:', error);\n return null;\n }\n};\n\n/**\n * Attempt to refresh the token if not already refreshing.\n * Uses a module-level promise to prevent concurrent refresh requests.\n *\n * @returns The new authentication token\n * @throws {Error} If the token refresh fails (e.g., refresh token expired)\n * @internal Exported for testing purposes\n */\nconst attemptTokenRefresh = async (tokenUsedByFailedRequest?: string | null): Promise<string> => {\n if (!refreshPromise) {\n refreshPromise = refreshAccessToken(tokenUsedByFailedRequest).finally(() => {\n refreshPromise = null;\n });\n }\n\n const newToken = await refreshPromise;\n if (!newToken) {\n const error = new Error('Session expired. Please log in again.');\n error.name = 'TokenRefreshError';\n throw error;\n }\n\n return newToken;\n};\n\ntype FetchResponse<TData = unknown> = {\n data: TData;\n status?: number;\n headers?: Headers;\n};\n\ntype FetchOptions = {\n params?: unknown;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n validateStatus?: ((status: number) => boolean) | null;\n responseType?: 'json' | 'blob' | 'text' | 'arrayBuffer';\n};\n\ntype FetchConfig = {\n signal?: AbortSignal;\n};\n\ninterface ErrorResponse {\n data: {\n data?: unknown;\n error: ApiError & { status?: number };\n };\n}\n\nclass FetchError extends Error {\n public name: string;\n public message: string;\n public response?: ErrorResponse;\n public code?: number;\n public status?: number;\n\n constructor(message: string, response?: ErrorResponse) {\n super(message);\n this.name = 'FetchError';\n this.message = message;\n this.response = response;\n this.code = response?.data?.error?.status;\n this.status = response?.data?.error?.status;\n\n // Ensure correct stack trace in error object\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FetchError);\n }\n }\n}\n\nconst isFetchError = (error: unknown): error is FetchError => {\n return error instanceof FetchError;\n};\n\ntype FetchClient = {\n get: {\n (url: string, config: FetchOptions & { responseType: 'blob' }): Promise<FetchResponse<Blob>>;\n (url: string, config: FetchOptions & { responseType: 'text' }): Promise<FetchResponse<string>>;\n (\n url: string,\n config: FetchOptions & { responseType: 'arrayBuffer' }\n ): Promise<FetchResponse<ArrayBuffer>>;\n <TData = unknown>(url: string, config?: FetchOptions): Promise<FetchResponse<TData>>;\n };\n put: <TData = unknown, TSend = unknown>(\n url: string,\n data?: TSend,\n config?: FetchOptions\n ) => Promise<FetchResponse<TData>>;\n post: <TData = unknown, TSend = unknown>(\n url: string,\n data?: TSend,\n config?: FetchOptions\n ) => Promise<FetchResponse<TData>>;\n del: <TData = unknown>(url: string, config?: FetchOptions) => Promise<FetchResponse<TData>>;\n};\n\n/**\n * @public\n * @param {FetchConfig} [defaultOptions={}] - Fetch Configs.\n * @returns {FetchClient} A fetch client object with methods for making HTTP requests.\n * @description This is an abstraction around the native fetch exposed by a function. It provides a simple interface to handle API calls\n * to the Strapi backend.\n * @example\n * ```tsx\n * import { getFetchClient } from '@strapi/admin/admin';\n *\n * const myFunct = () => {\n * const { get } = getFetchClient();\n * const requestURL = \"/some-endpoint\";\n *\n * const { data } = await get(requestURL);\n *\n * return data;\n * };\n * ```\n */\nconst getFetchClient = (defaultOptions: FetchConfig = {}): FetchClient => {\n const backendURL = window.strapi.backendURL;\n\n /**\n * Create default headers with the current token.\n * This is a function so we can get a fresh token after refresh.\n */\n const getDefaultHeaders = (token = getToken()) => ({\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n });\n\n const isFormDataRequest = (body: unknown) => body instanceof FormData;\n const addPrependingSlash = (url: string) => (url.charAt(0) !== '/' ? `/${url}` : url);\n\n // This regular expression matches a string that starts with either \"http://\" or \"https://\" or any other protocol name in lower case letters, followed by \"://\" and ends with anything else\n const hasProtocol = (url: string) => new RegExp('^(?:[a-z+]+:)?//', 'i').test(url);\n\n // Check if the url has a prepending slash, if not add a slash\n const normalizeUrl = (url: string) => (hasProtocol(url) ? url : addPrependingSlash(url));\n\n // Add a response interceptor to return the response\n const responseInterceptor = async <TData = unknown>(\n response: Response,\n validateStatus?: FetchOptions['validateStatus'],\n responseType: NonNullable<FetchOptions['responseType']> = 'json'\n ): Promise<FetchResponse<TData>> => {\n if (responseType !== 'json') {\n if (!response.ok && !validateStatus?.(response.status)) {\n const fetchError = new FetchError('Server Error');\n fetchError.status = response.status;\n throw fetchError;\n }\n\n let result: Blob | string | ArrayBuffer;\n if (responseType === 'blob') {\n result = await response.blob();\n } else if (responseType === 'text') {\n result = await response.text();\n } else {\n result = await response.arrayBuffer();\n }\n\n return { data: result as TData, status: response.status, headers: response.headers };\n }\n\n if (response.status === 204) {\n return { data: {} as TData, status: response.status };\n }\n\n try {\n const result = await response.json();\n\n if (!response.ok && result.error && !validateStatus?.(response.status)) {\n const fetchError = new FetchError(result.error.message, { data: result });\n fetchError.status = response.status;\n throw fetchError;\n }\n\n if (!response.ok && !validateStatus?.(response.status)) {\n const fetchError = new FetchError('Unknown Server Error');\n fetchError.status = response.status;\n throw fetchError;\n }\n\n return { data: result };\n } catch (error) {\n // An empty 200 body causes `response.json()` to throw a `SyntaxError`. We treat\n // it as success and return an empty payload. We match on `error.name` rather\n // than `instanceof SyntaxError` because constructor identity differs across JS\n // realms — a Response from a different realm (e.g. undici under jsdom in tests,\n // a service worker or iframe in browsers) throws a `SyntaxError` whose\n // constructor is not the same identity as the one this module closes over. Name\n // comparison is realm-agnostic.\n if ((error as Error | null)?.name === 'SyntaxError' && response.ok) {\n return { data: {}, status: response.status } as FetchResponse<TData>;\n } else {\n throw error;\n }\n }\n };\n\n /**\n * Execute a fetch request with automatic token refresh on 401 errors.\n * @param url - The request URL (used to check if it's an auth path)\n * @param executeRequest - Function that performs the fetch (called again on retry with fresh headers)\n */\n const withTokenRefresh = async <TData>(\n url: string,\n executeRequest: () => Promise<FetchResponse<TData>>,\n getRequestToken: () => string | null\n ): Promise<FetchResponse<TData>> => {\n try {\n return await executeRequest();\n } catch (error) {\n // Only attempt refresh for 401 errors on non-auth paths\n if (isFetchError(error) && error.status === 401 && !isAuthPath(url)) {\n try {\n await attemptTokenRefresh(getRequestToken());\n // Retry - executeRequest will call getDefaultHeaders() again, picking up the new token\n return await executeRequest();\n } catch {\n // If refresh fails, throw the original error\n throw error;\n }\n }\n throw error;\n }\n };\n\n const paramsSerializer =\n <Param = unknown>(params?: Param) =>\n (url: string) => {\n if (params) {\n if (typeof params === 'string') {\n return `${url}?${params}`;\n }\n\n /**\n * TODO V6: Encoding should be enabled in this step\n * So the rest of the app doesn't have to worry about it,\n * It's considered a breaking change because it impacts any API request, including the user's custom code\n */\n const serializedParams = qs.stringify(params, { encode: false });\n if (serializedParams) {\n return `${url}?${serializedParams}`;\n }\n return url;\n }\n return url;\n };\n\n const addBaseUrl = (url: Parameters<typeof fetch>[0]) => {\n return `${backendURL}${url}`;\n };\n\n /**\n * We use the factory method because the options\n * are unique to the individual request\n */\n const makeCreateRequestUrl = (options?: FetchOptions) =>\n pipe(normalizeUrl, addBaseUrl, paramsSerializer(options?.params));\n\n const fetchClient: FetchClient = {\n get: async <TData>(url: string, options?: FetchOptions): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n const responseType = options?.responseType ?? 'json';\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const { Authorization } = getDefaultHeaders(requestToken);\n\n // For non-JSON response types, omit content negotiation headers that imply JSON\n const defaultHeaders =\n responseType === 'json' ? getDefaultHeaders(requestToken) : { Authorization };\n\n const headers = new Headers({\n ...defaultHeaders,\n ...options?.headers,\n });\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'GET',\n credentials: 'include',\n headers,\n });\n\n return responseInterceptor<TData>(response, options?.validateStatus, responseType);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n post: async <TData, TSend = unknown>(\n url: string,\n data?: TSend,\n options?: FetchOptions\n ): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const headers = new Headers({\n ...getDefaultHeaders(requestToken),\n ...options?.headers,\n });\n\n /**\n * we have to remove the Content-Type value if it was a formData request\n * the browser will automatically set the header value\n */\n if (isFormDataRequest(data)) {\n headers.delete('Content-Type');\n }\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'POST',\n credentials: 'include',\n headers,\n body: isFormDataRequest(data) ? (data as FormData) : JSON.stringify(data),\n });\n return responseInterceptor<TData>(response, options?.validateStatus);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n put: async <TData, TSend = unknown>(\n url: string,\n data?: TSend,\n options?: FetchOptions\n ): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const headers = new Headers({\n ...getDefaultHeaders(requestToken),\n ...options?.headers,\n });\n\n /**\n * we have to remove the Content-Type value if it was a formData request\n * the browser will automatically set the header value\n */\n if (isFormDataRequest(data)) {\n headers.delete('Content-Type');\n }\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'PUT',\n credentials: 'include',\n headers,\n body: isFormDataRequest(data) ? (data as FormData) : JSON.stringify(data),\n });\n\n return responseInterceptor<TData>(response, options?.validateStatus);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n del: async <TData>(url: string, options?: FetchOptions): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const headers = new Headers({\n ...getDefaultHeaders(requestToken),\n ...options?.headers,\n });\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'DELETE',\n credentials: 'include',\n headers,\n });\n return responseInterceptor<TData>(response, options?.validateStatus);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n };\n\n return fetchClient;\n};\n\nexport {\n getFetchClient,\n isFetchError,\n FetchError,\n attemptTokenRefresh,\n refreshAccessToken,\n storeToken,\n setOnTokenUpdate,\n setOnSessionExpired,\n triggerSessionExpired,\n ADMIN_REFRESH_LOCK,\n};\nexport type { FetchOptions, FetchResponse, FetchConfig, FetchClient, ErrorResponse };\n"],"names":["STORAGE_KEYS","TOKEN","refreshPromise","onTokenUpdate","onSessionExpired","setOnTokenUpdate","callback","setOnSessionExpired","triggerSessionExpired","isAuthPath","url","test","storeToken","token","wasPersistedToLocalStorage","Boolean","localStorage","getItem","setItem","JSON","stringify","setCookie","AUTH_COOKIE_NAME","getToken","fromLocalStorage","parse","fromCookie","getCookieValue","ADMIN_REFRESH_LOCK","FALLBACK_ADOPT_TIMEOUT_MS","FALLBACK_ADOPT_POLL_MS","postAccessToken","backendURL","fetch","method","credentials","headers","Accept","adoptSharedAccessToken","readValidAccessTokenFromSharedStorage","staleToken","stored","expiry","decodeAccessTokenExpiry","Date","now","waitForSharedAccessToken","timeoutAt","Promise","resolve","setTimeout","adopted","executeRefreshAccessToken","tokenBeforeRefresh","allowHttpRetry","response","status","adoptedAfterFail","adoptedAfterWait","ok","console","warn","result","json","data","refreshAccessToken","tokenUsedByFailedRequest","window","strapi","navigator","locks","request","error","attemptTokenRefresh","finally","newToken","Error","name","FetchError","message","code","captureStackTrace","isFetchError","getFetchClient","defaultOptions","getDefaultHeaders","Authorization","isFormDataRequest","body","FormData","addPrependingSlash","charAt","hasProtocol","RegExp","normalizeUrl","responseInterceptor","validateStatus","responseType","fetchError","blob","text","arrayBuffer","withTokenRefresh","executeRequest","getRequestToken","paramsSerializer","params","serializedParams","qs","encode","addBaseUrl","makeCreateRequestUrl","options","pipe","fetchClient","get","createRequestUrl","requestToken","defaultHeaders","Headers","signal","post","delete","put","del"],"mappings":";;;;;;;;;;;;AAsBA,MAAMA,YAAAA,GAAe;IACnBC,KAAAA,EAAO,UAET,CAAA;AAEA;;AAEC,IACD,IAAIC,cAAAA,GAAgD,IAAA;AAEpD;;AAEC,IACD,IAAIC,aAAAA,GAAkD,IAAA;AAEtD;;;;;AAKC,IACD,IAAIC,gBAAAA,GAAwC,IAAA;AAE5C;;;;;;;;;;;IAYA,MAAMC,mBAAmB,CAACC,QAAAA,GAAAA;IACxBH,aAAAA,GAAgBG,QAAAA;AAClB;AAEA;;;;;;;IAQA,MAAMC,sBAAsB,CAACD,QAAAA,GAAAA;IAC3BF,gBAAAA,GAAmBE,QAAAA;AACrB;AAEA;;;AAGC,UACKE,qBAAAA,GAAwB,IAAA;AAC5BJ,IAAAA,gBAAAA,IAAAA;AACF;AAEA;;;;AAIC,IACD,MAAMK,UAAAA,GAAa,CAACC,GAAAA,GAAgB,wCAAA,CAAyCC,IAAI,CAACD,GAAAA,CAAAA;AAElF;;;;;;;;;IAUA,MAAME,aAAa,CAACC,KAAAA,GAAAA;;AAElB,IAAA,MAAMC,6BAA6BC,OAAAA,CAAQC,YAAAA,CAAaC,OAAO,CAACjB,aAAaC,KAAK,CAAA,CAAA;AAElF,IAAA,IAAIa,0BAAAA,EAA4B;AA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IAEA,OAAOH,WAAAA;AACT;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"getFetchClient.js","sources":["../../../../../admin/src/utils/getFetchClient.ts"],"sourcesContent":["import pipe from 'lodash/fp/pipe';\n// eslint-disable-next-line import/default\nimport qs from 'qs';\n\nimport { AUTH_COOKIE_NAME, getCookieValue, setCookie } from './cookies';\nimport { decodeAccessTokenExpiry } from './jwt';\n\nimport type { errors } from '@strapi/utils';\n\nexport type ApiError =\n | errors.ApplicationError\n | errors.ForbiddenError\n | errors.NotFoundError\n | errors.NotImplementedError\n | errors.PaginationError\n | errors.PayloadTooLargeError\n | errors.PolicyError\n | errors.RateLimitError\n | errors.UnauthorizedError\n | errors.ValidationError\n | errors.YupValidationError;\n\nconst STORAGE_KEYS = {\n TOKEN: 'jwtToken',\n USER: 'userInfo',\n};\n\n/**\n * Module-level promise to ensure only one token refresh happens at a time\n */\nlet refreshPromise: Promise<string | null> | null = null;\n\n/**\n * Callback to notify the app when the token is updated (e.g., to update Redux state)\n */\nlet onTokenUpdate: ((token: string) => void) | null = null;\n\n/**\n * Callback to notify the app when the session has been terminated and the user\n * should be redirected to the login page (e.g., refresh token rejected, idle\n * session expired). The React layer registers a handler that clears local\n * auth state and navigates to /auth/login.\n */\nlet onSessionExpired: (() => void) | null = null;\n\n/**\n * A 401 after a failed refresh is delivered twice in the common RTK path\n * (baseQuery, then the store middleware). Concurrent in-flight queries can\n * add more. Fire the React handler once per dead session; re-arm when a new\n * token is stored (refresh or login).\n */\nlet sessionExpiredNotified = false;\n\n/**\n * Set the callback that will be called when the token is refreshed.\n * This allows the React layer to update Redux state when a token refresh occurs.\n *\n * @param callback - Function to call with the new token, or null to clear\n * @example\n * // In a React component\n * useEffect(() => {\n * setOnTokenUpdate((token) => dispatch(setToken(token)));\n * return () => setOnTokenUpdate(null);\n * }, [dispatch]);\n */\nconst setOnTokenUpdate = (callback: ((token: string) => void) | null): void => {\n onTokenUpdate = callback;\n};\n\n/**\n * Set the callback that will be called when the active session is no longer\n * valid — i.e. the server rejected the refresh token, not merely that the\n * short-lived access token expired. This lets the tab redirect to /auth/login\n * (after any unsaved-changes guard) rather than sitting on a dead session.\n *\n * @param callback - Function to call when the session ends, or null to clear\n */\nconst setOnSessionExpired = (callback: (() => void) | null): void => {\n onSessionExpired = callback;\n if (callback === null) {\n resetSessionExpiredNotification();\n }\n};\n\n/**\n * Re-arm session-expired notifications after a new access token is stored\n * (silent refresh) or after a successful login.\n */\nconst resetSessionExpiredNotification = (): void => {\n sessionExpiredNotified = false;\n};\n\n/**\n * Trigger the registered session-expired callback, if any. Safe to call from\n * non-React code (e.g., the RTK Query baseQuery 401 handler). Returns `false`\n * when nothing is listening, so callers can fall back to a hard redirect\n * instead of leaving the user on a dead page. Subsequent calls during the same\n * dead session return `true` without invoking the handler again.\n */\nconst triggerSessionExpired = (): boolean => {\n if (!onSessionExpired) {\n return false;\n }\n\n if (sessionExpiredNotified) {\n return true;\n }\n\n sessionExpiredNotified = true;\n onSessionExpired();\n return true;\n};\n\n/**\n * Check if the URL is an auth path that should not trigger token refresh.\n * Note: No ^ anchor since the URL may include the baseURL prefix (e.g., \"http://localhost:1337/admin/login\").\n * This differs from baseQuery.ts which uses ^/admin since it receives normalized paths.\n */\nconst isAuthPath = (url: string) => /\\/admin\\/(login|logout|access-token)\\b/.test(url);\n\n/**\n * Store the new token in the appropriate storage (localStorage or cookie)\n * and notify the app to update its state.\n *\n * Uses localStorage if the user selected \"remember me\" during login,\n * otherwise uses cookies for session-based storage.\n *\n * @param token - The JWT token to store\n * @internal Exported for testing purposes\n */\nconst storeToken = (token: string): void => {\n resetSessionExpiredNotification();\n\n // Check if the original token was stored in localStorage (persist mode)\n const wasPersistedToLocalStorage = Boolean(localStorage.getItem(STORAGE_KEYS.TOKEN));\n\n if (wasPersistedToLocalStorage) {\n localStorage.setItem(STORAGE_KEYS.TOKEN, JSON.stringify(token));\n } else {\n setCookie(AUTH_COOKIE_NAME, token);\n }\n\n // Notify the app to update its state (e.g., Redux)\n if (onTokenUpdate) {\n onTokenUpdate(token);\n }\n};\n\nconst getToken = (): string | null => {\n const fromLocalStorage = localStorage.getItem(STORAGE_KEYS.TOKEN);\n if (fromLocalStorage) {\n return JSON.parse(fromLocalStorage);\n }\n\n const fromCookie = getCookieValue(AUTH_COOKIE_NAME);\n return fromCookie ?? null;\n};\n\nconst ADMIN_REFRESH_LOCK = 'strapi-admin-access-token';\nconst FALLBACK_ADOPT_TIMEOUT_MS = 250;\nconst FALLBACK_ADOPT_POLL_MS = 25;\n\nconst postAccessToken = (backendURL: string) =>\n fetch(`${backendURL}/admin/access-token`, {\n method: 'POST',\n credentials: 'include', // Include cookies for the refresh token\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n });\n\nconst adoptSharedAccessToken = (token: string): string => {\n resetSessionExpiredNotification();\n\n if (onTokenUpdate) {\n onTokenUpdate(token);\n }\n return token;\n};\n\n/**\n * Another tab may have refreshed already and written a newer access token to the\n * shared localStorage/cookie. Per-tab Redux is not visible here — only shared\n * storage counts.\n */\nconst readValidAccessTokenFromSharedStorage = (staleToken: string | null): string | null => {\n const stored = getToken();\n if (!stored || stored === staleToken) {\n return null;\n }\n\n const expiry = decodeAccessTokenExpiry(stored);\n if (expiry === null || expiry <= Date.now()) {\n return null;\n }\n\n return stored;\n};\n\nconst waitForSharedAccessToken = async (staleToken: string | null): Promise<string | null> => {\n const timeoutAt = Date.now() + FALLBACK_ADOPT_TIMEOUT_MS;\n\n while (Date.now() < timeoutAt) {\n await new Promise((resolve) => {\n setTimeout(resolve, FALLBACK_ADOPT_POLL_MS);\n });\n\n const adopted = readValidAccessTokenFromSharedStorage(staleToken);\n if (adopted) {\n return adoptSharedAccessToken(adopted);\n }\n }\n\n return null;\n};\n\nconst executeRefreshAccessToken = async (\n backendURL: string,\n tokenBeforeRefresh: string | null,\n { allowHttpRetry }: { allowHttpRetry: boolean }\n): Promise<string | null> => {\n const adopted = readValidAccessTokenFromSharedStorage(tokenBeforeRefresh);\n if (adopted) {\n return adoptSharedAccessToken(adopted);\n }\n\n let response = await postAccessToken(backendURL);\n\n if (response.status === 401 && allowHttpRetry) {\n const adoptedAfterFail = readValidAccessTokenFromSharedStorage(tokenBeforeRefresh);\n if (adoptedAfterFail) {\n return adoptSharedAccessToken(adoptedAfterFail);\n }\n\n const adoptedAfterWait = await waitForSharedAccessToken(tokenBeforeRefresh);\n if (adoptedAfterWait) {\n return adoptedAfterWait;\n }\n\n response = await postAccessToken(backendURL);\n }\n\n if (!response.ok) {\n console.warn('[Auth] Token refresh failed with status:', response.status);\n return null;\n }\n\n const result = await response.json();\n const token = result?.data?.token as string | undefined;\n\n if (!token) {\n console.warn('[Auth] Token refresh response missing token');\n return null;\n }\n\n storeToken(token);\n return token;\n};\n\n/**\n * Refresh the access token by calling the /admin/access-token endpoint.\n * This uses a low-level fetch to avoid recursion through the interceptor.\n * Returns the new token on success, or null on failure.\n */\nconst refreshAccessToken = async (\n tokenUsedByFailedRequest?: string | null\n): Promise<string | null> => {\n const backendURL = window.strapi.backendURL;\n const tokenBeforeRefresh = tokenUsedByFailedRequest ?? getToken();\n\n try {\n if (typeof navigator !== 'undefined' && navigator.locks?.request) {\n return await navigator.locks.request(ADMIN_REFRESH_LOCK, () =>\n executeRefreshAccessToken(backendURL, tokenBeforeRefresh, { allowHttpRetry: false })\n );\n }\n\n return await executeRefreshAccessToken(backendURL, tokenBeforeRefresh, {\n allowHttpRetry: true,\n });\n } catch (error) {\n console.error('[Auth] Token refresh error:', error);\n return null;\n }\n};\n\n/**\n * Attempt to refresh the token if not already refreshing.\n * Uses a module-level promise to prevent concurrent refresh requests.\n *\n * @returns The new authentication token\n * @throws {Error} If the token refresh fails (e.g., refresh token expired)\n * @internal Exported for testing purposes\n */\nconst attemptTokenRefresh = async (tokenUsedByFailedRequest?: string | null): Promise<string> => {\n if (!refreshPromise) {\n refreshPromise = refreshAccessToken(tokenUsedByFailedRequest).finally(() => {\n refreshPromise = null;\n });\n }\n\n const newToken = await refreshPromise;\n if (!newToken) {\n const error = new Error('Session expired. Please log in again.');\n error.name = 'TokenRefreshError';\n throw error;\n }\n\n return newToken;\n};\n\ntype FetchResponse<TData = unknown> = {\n data: TData;\n status?: number;\n headers?: Headers;\n};\n\ntype FetchOptions = {\n params?: unknown;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n validateStatus?: ((status: number) => boolean) | null;\n responseType?: 'json' | 'blob' | 'text' | 'arrayBuffer';\n};\n\ntype FetchConfig = {\n signal?: AbortSignal;\n};\n\ninterface ErrorResponse {\n data: {\n data?: unknown;\n error: ApiError & { status?: number };\n };\n}\n\nclass FetchError extends Error {\n public name: string;\n public message: string;\n public response?: ErrorResponse;\n public code?: number;\n public status?: number;\n\n constructor(message: string, response?: ErrorResponse) {\n super(message);\n this.name = 'FetchError';\n this.message = message;\n this.response = response;\n this.code = response?.data?.error?.status;\n this.status = response?.data?.error?.status;\n\n // Ensure correct stack trace in error object\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FetchError);\n }\n }\n}\n\nconst isFetchError = (error: unknown): error is FetchError => {\n return error instanceof FetchError;\n};\n\ntype FetchClient = {\n get: {\n (url: string, config: FetchOptions & { responseType: 'blob' }): Promise<FetchResponse<Blob>>;\n (url: string, config: FetchOptions & { responseType: 'text' }): Promise<FetchResponse<string>>;\n (\n url: string,\n config: FetchOptions & { responseType: 'arrayBuffer' }\n ): Promise<FetchResponse<ArrayBuffer>>;\n <TData = unknown>(url: string, config?: FetchOptions): Promise<FetchResponse<TData>>;\n };\n put: <TData = unknown, TSend = unknown>(\n url: string,\n data?: TSend,\n config?: FetchOptions\n ) => Promise<FetchResponse<TData>>;\n post: <TData = unknown, TSend = unknown>(\n url: string,\n data?: TSend,\n config?: FetchOptions\n ) => Promise<FetchResponse<TData>>;\n del: <TData = unknown>(url: string, config?: FetchOptions) => Promise<FetchResponse<TData>>;\n};\n\n/**\n * @public\n * @param {FetchConfig} [defaultOptions={}] - Fetch Configs.\n * @returns {FetchClient} A fetch client object with methods for making HTTP requests.\n * @description This is an abstraction around the native fetch exposed by a function. It provides a simple interface to handle API calls\n * to the Strapi backend.\n * @example\n * ```tsx\n * import { getFetchClient } from '@strapi/admin/admin';\n *\n * const myFunct = () => {\n * const { get } = getFetchClient();\n * const requestURL = \"/some-endpoint\";\n *\n * const { data } = await get(requestURL);\n *\n * return data;\n * };\n * ```\n */\nconst getFetchClient = (defaultOptions: FetchConfig = {}): FetchClient => {\n const backendURL = window.strapi.backendURL;\n\n /**\n * Create default headers with the current token.\n * This is a function so we can get a fresh token after refresh.\n */\n const getDefaultHeaders = (token = getToken()) => ({\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n });\n\n const isFormDataRequest = (body: unknown) => body instanceof FormData;\n const addPrependingSlash = (url: string) => (url.charAt(0) !== '/' ? `/${url}` : url);\n\n // This regular expression matches a string that starts with either \"http://\" or \"https://\" or any other protocol name in lower case letters, followed by \"://\" and ends with anything else\n const hasProtocol = (url: string) => new RegExp('^(?:[a-z+]+:)?//', 'i').test(url);\n\n // Check if the url has a prepending slash, if not add a slash\n const normalizeUrl = (url: string) => (hasProtocol(url) ? url : addPrependingSlash(url));\n\n // Add a response interceptor to return the response\n const responseInterceptor = async <TData = unknown>(\n response: Response,\n validateStatus?: FetchOptions['validateStatus'],\n responseType: NonNullable<FetchOptions['responseType']> = 'json'\n ): Promise<FetchResponse<TData>> => {\n if (responseType !== 'json') {\n if (!response.ok && !validateStatus?.(response.status)) {\n const fetchError = new FetchError('Server Error');\n fetchError.status = response.status;\n throw fetchError;\n }\n\n let result: Blob | string | ArrayBuffer;\n if (responseType === 'blob') {\n result = await response.blob();\n } else if (responseType === 'text') {\n result = await response.text();\n } else {\n result = await response.arrayBuffer();\n }\n\n return { data: result as TData, status: response.status, headers: response.headers };\n }\n\n if (response.status === 204) {\n return { data: {} as TData, status: response.status };\n }\n\n try {\n const result = await response.json();\n\n if (!response.ok && result.error && !validateStatus?.(response.status)) {\n const fetchError = new FetchError(result.error.message, { data: result });\n fetchError.status = response.status;\n throw fetchError;\n }\n\n if (!response.ok && !validateStatus?.(response.status)) {\n const fetchError = new FetchError('Unknown Server Error');\n fetchError.status = response.status;\n throw fetchError;\n }\n\n return { data: result };\n } catch (error) {\n // An empty 200 body causes `response.json()` to throw a `SyntaxError`. We treat\n // it as success and return an empty payload. We match on `error.name` rather\n // than `instanceof SyntaxError` because constructor identity differs across JS\n // realms — a Response from a different realm (e.g. undici under jsdom in tests,\n // a service worker or iframe in browsers) throws a `SyntaxError` whose\n // constructor is not the same identity as the one this module closes over. Name\n // comparison is realm-agnostic.\n if ((error as Error | null)?.name === 'SyntaxError' && response.ok) {\n return { data: {}, status: response.status } as FetchResponse<TData>;\n } else {\n throw error;\n }\n }\n };\n\n /**\n * Execute a fetch request with automatic token refresh on 401 errors.\n * @param url - The request URL (used to check if it's an auth path)\n * @param executeRequest - Function that performs the fetch (called again on retry with fresh headers)\n */\n const withTokenRefresh = async <TData>(\n url: string,\n executeRequest: () => Promise<FetchResponse<TData>>,\n getRequestToken: () => string | null\n ): Promise<FetchResponse<TData>> => {\n try {\n return await executeRequest();\n } catch (error) {\n // Only attempt refresh for 401 errors on non-auth paths\n if (isFetchError(error) && error.status === 401 && !isAuthPath(url)) {\n try {\n await attemptTokenRefresh(getRequestToken());\n // Retry - executeRequest will call getDefaultHeaders() again, picking up the new token\n return await executeRequest();\n } catch {\n // If refresh fails, throw the original error\n throw error;\n }\n }\n throw error;\n }\n };\n\n const paramsSerializer =\n <Param = unknown>(params?: Param) =>\n (url: string) => {\n if (params) {\n if (typeof params === 'string') {\n return `${url}?${params}`;\n }\n\n /**\n * TODO V6: Encoding should be enabled in this step\n * So the rest of the app doesn't have to worry about it,\n * It's considered a breaking change because it impacts any API request, including the user's custom code\n */\n const serializedParams = qs.stringify(params, { encode: false });\n if (serializedParams) {\n return `${url}?${serializedParams}`;\n }\n return url;\n }\n return url;\n };\n\n const addBaseUrl = (url: Parameters<typeof fetch>[0]) => {\n return `${backendURL}${url}`;\n };\n\n /**\n * We use the factory method because the options\n * are unique to the individual request\n */\n const makeCreateRequestUrl = (options?: FetchOptions) =>\n pipe(normalizeUrl, addBaseUrl, paramsSerializer(options?.params));\n\n const fetchClient: FetchClient = {\n get: async <TData>(url: string, options?: FetchOptions): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n const responseType = options?.responseType ?? 'json';\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const { Authorization } = getDefaultHeaders(requestToken);\n\n // For non-JSON response types, omit content negotiation headers that imply JSON\n const defaultHeaders =\n responseType === 'json' ? getDefaultHeaders(requestToken) : { Authorization };\n\n const headers = new Headers({\n ...defaultHeaders,\n ...options?.headers,\n });\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'GET',\n credentials: 'include',\n headers,\n });\n\n return responseInterceptor<TData>(response, options?.validateStatus, responseType);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n post: async <TData, TSend = unknown>(\n url: string,\n data?: TSend,\n options?: FetchOptions\n ): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const headers = new Headers({\n ...getDefaultHeaders(requestToken),\n ...options?.headers,\n });\n\n /**\n * we have to remove the Content-Type value if it was a formData request\n * the browser will automatically set the header value\n */\n if (isFormDataRequest(data)) {\n headers.delete('Content-Type');\n }\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'POST',\n credentials: 'include',\n headers,\n body: isFormDataRequest(data) ? (data as FormData) : JSON.stringify(data),\n });\n return responseInterceptor<TData>(response, options?.validateStatus);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n put: async <TData, TSend = unknown>(\n url: string,\n data?: TSend,\n options?: FetchOptions\n ): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const headers = new Headers({\n ...getDefaultHeaders(requestToken),\n ...options?.headers,\n });\n\n /**\n * we have to remove the Content-Type value if it was a formData request\n * the browser will automatically set the header value\n */\n if (isFormDataRequest(data)) {\n headers.delete('Content-Type');\n }\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'PUT',\n credentials: 'include',\n headers,\n body: isFormDataRequest(data) ? (data as FormData) : JSON.stringify(data),\n });\n\n return responseInterceptor<TData>(response, options?.validateStatus);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n del: async <TData>(url: string, options?: FetchOptions): Promise<FetchResponse<TData>> => {\n const createRequestUrl = makeCreateRequestUrl(options);\n let requestToken: string | null = null;\n\n const executeRequest = async () => {\n requestToken = getToken();\n const headers = new Headers({\n ...getDefaultHeaders(requestToken),\n ...options?.headers,\n });\n\n const response = await fetch(createRequestUrl(url), {\n signal: options?.signal ?? defaultOptions.signal,\n method: 'DELETE',\n credentials: 'include',\n headers,\n });\n return responseInterceptor<TData>(response, options?.validateStatus);\n };\n\n return withTokenRefresh(url, executeRequest, () => requestToken);\n },\n };\n\n return fetchClient;\n};\n\nexport {\n getFetchClient,\n isFetchError,\n FetchError,\n attemptTokenRefresh,\n refreshAccessToken,\n storeToken,\n setOnTokenUpdate,\n setOnSessionExpired,\n triggerSessionExpired,\n resetSessionExpiredNotification,\n ADMIN_REFRESH_LOCK,\n};\nexport type { FetchOptions, FetchResponse, FetchConfig, FetchClient, ErrorResponse };\n"],"names":["STORAGE_KEYS","TOKEN","refreshPromise","onTokenUpdate","onSessionExpired","sessionExpiredNotified","setOnTokenUpdate","callback","setOnSessionExpired","resetSessionExpiredNotification","triggerSessionExpired","isAuthPath","url","test","storeToken","token","wasPersistedToLocalStorage","Boolean","localStorage","getItem","setItem","JSON","stringify","setCookie","AUTH_COOKIE_NAME","getToken","fromLocalStorage","parse","fromCookie","getCookieValue","ADMIN_REFRESH_LOCK","FALLBACK_ADOPT_TIMEOUT_MS","FALLBACK_ADOPT_POLL_MS","postAccessToken","backendURL","fetch","method","credentials","headers","Accept","adoptSharedAccessToken","readValidAccessTokenFromSharedStorage","staleToken","stored","expiry","decodeAccessTokenExpiry","Date","now","waitForSharedAccessToken","timeoutAt","Promise","resolve","setTimeout","adopted","executeRefreshAccessToken","tokenBeforeRefresh","allowHttpRetry","response","status","adoptedAfterFail","adoptedAfterWait","ok","console","warn","result","json","data","refreshAccessToken","tokenUsedByFailedRequest","window","strapi","navigator","locks","request","error","attemptTokenRefresh","finally","newToken","Error","name","FetchError","message","code","captureStackTrace","isFetchError","getFetchClient","defaultOptions","getDefaultHeaders","Authorization","isFormDataRequest","body","FormData","addPrependingSlash","charAt","hasProtocol","RegExp","normalizeUrl","responseInterceptor","validateStatus","responseType","fetchError","blob","text","arrayBuffer","withTokenRefresh","executeRequest","getRequestToken","paramsSerializer","params","serializedParams","qs","encode","addBaseUrl","makeCreateRequestUrl","options","pipe","fetchClient","get","createRequestUrl","requestToken","defaultHeaders","Headers","signal","post","delete","put","del"],"mappings":";;;;;;;;;;;;AAsBA,MAAMA,YAAAA,GAAe;IACnBC,KAAAA,EAAO,UAET,CAAA;AAEA;;AAEC,IACD,IAAIC,cAAAA,GAAgD,IAAA;AAEpD;;AAEC,IACD,IAAIC,aAAAA,GAAkD,IAAA;AAEtD;;;;;AAKC,IACD,IAAIC,gBAAAA,GAAwC,IAAA;AAE5C;;;;;AAKC,IACD,IAAIC,sBAAAA,GAAyB,KAAA;AAE7B;;;;;;;;;;;IAYA,MAAMC,mBAAmB,CAACC,QAAAA,GAAAA;IACxBJ,aAAAA,GAAgBI,QAAAA;AAClB;AAEA;;;;;;;IAQA,MAAMC,sBAAsB,CAACD,QAAAA,GAAAA;IAC3BH,gBAAAA,GAAmBG,QAAAA;AACnB,IAAA,IAAIA,aAAa,IAAA,EAAM;A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