conexys-elements 1.1.2 → 1.1.23

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 (254) hide show
  1. package/README.md +462 -125
  2. package/dist/Auth.d.ts +0 -0
  3. package/dist/Auth.d.ts.map +0 -0
  4. package/dist/ThemeContext.d.ts +0 -0
  5. package/dist/ThemeContext.d.ts.map +0 -0
  6. package/dist/components/AppDataSettings.d.ts +0 -0
  7. package/dist/components/AppDataSettings.d.ts.map +0 -0
  8. package/dist/components/AppDataSettingsHTML.d.ts +0 -0
  9. package/dist/components/AppDataSettingsHTML.d.ts.map +1 -1
  10. package/dist/components/AppError.d.ts +0 -0
  11. package/dist/components/AppError.d.ts.map +0 -0
  12. package/dist/components/AppFormFields.d.ts +1 -1
  13. package/dist/components/AppFormFields.d.ts.map +1 -1
  14. package/dist/components/AppFormFieldsFromConfig.d.ts +0 -0
  15. package/dist/components/AppFormFieldsFromConfig.d.ts.map +0 -0
  16. package/dist/components/AppFormFieldsNoUser.d.ts +0 -0
  17. package/dist/components/AppFormFieldsNoUser.d.ts.map +1 -1
  18. package/dist/components/AppFormFieldsTable.d.ts +0 -0
  19. package/dist/components/AppFormFieldsTable.d.ts.map +1 -1
  20. package/dist/components/AppHeaderPage.d.ts +0 -0
  21. package/dist/components/AppHeaderPage.d.ts.map +1 -1
  22. package/dist/components/AppHeaderPage404.d.ts +0 -0
  23. package/dist/components/AppHeaderPage404.d.ts.map +0 -0
  24. package/dist/components/AppSetHeaderTitle.d.ts +0 -0
  25. package/dist/components/AppSetHeaderTitle.d.ts.map +0 -0
  26. package/dist/components/BackendStatus/BackendOfflinePage.d.ts +0 -0
  27. package/dist/components/BackendStatus/BackendOfflinePage.d.ts.map +0 -0
  28. package/dist/components/BackendStatus/BackendStatusProvider.d.ts +0 -0
  29. package/dist/components/BackendStatus/BackendStatusProvider.d.ts.map +0 -0
  30. package/dist/components/BackendStatus/index.d.ts +0 -0
  31. package/dist/components/BackendStatus/index.d.ts.map +0 -0
  32. package/dist/components/ErrorBoundary.d.ts +0 -0
  33. package/dist/components/ErrorBoundary.d.ts.map +0 -0
  34. package/dist/components/NotFound.d.ts +0 -0
  35. package/dist/components/NotFound.d.ts.map +0 -0
  36. package/dist/components/PermissionGate.d.ts +0 -0
  37. package/dist/components/PermissionGate.d.ts.map +0 -0
  38. package/dist/components/Uservalidationerror.d.ts +0 -0
  39. package/dist/components/Uservalidationerror.d.ts.map +0 -0
  40. package/dist/components/dialog/AppDialogModal.d.ts +0 -0
  41. package/dist/components/dialog/AppDialogModal.d.ts.map +0 -0
  42. package/dist/components/form/RenderForm.d.ts +0 -0
  43. package/dist/components/form/RenderForm.d.ts.map +0 -0
  44. package/dist/components/form/components/Button.d.ts +0 -0
  45. package/dist/components/form/components/Button.d.ts.map +0 -0
  46. package/dist/components/form/components/Checkbox.d.ts +0 -0
  47. package/dist/components/form/components/Checkbox.d.ts.map +0 -0
  48. package/dist/components/form/components/FormLogin.d.ts +0 -0
  49. package/dist/components/form/components/FormLogin.d.ts.map +0 -0
  50. package/dist/components/form/components/Heading.d.ts +0 -0
  51. package/dist/components/form/components/Heading.d.ts.map +0 -0
  52. package/dist/components/form/components/Image.d.ts +0 -0
  53. package/dist/components/form/components/Image.d.ts.map +0 -0
  54. package/dist/components/form/components/Info.d.ts +0 -0
  55. package/dist/components/form/components/Info.d.ts.map +1 -1
  56. package/dist/components/form/components/InputFile.d.ts +0 -0
  57. package/dist/components/form/components/InputFile.d.ts.map +0 -0
  58. package/dist/components/form/components/InputPassword.d.ts +0 -0
  59. package/dist/components/form/components/InputPassword.d.ts.map +0 -0
  60. package/dist/components/form/components/InputText.d.ts +0 -0
  61. package/dist/components/form/components/InputText.d.ts.map +1 -1
  62. package/dist/components/form/components/InputWYSIWYG.d.ts +0 -0
  63. package/dist/components/form/components/InputWYSIWYG.d.ts.map +1 -1
  64. package/dist/components/form/components/Radiobutton.d.ts +0 -0
  65. package/dist/components/form/components/Radiobutton.d.ts.map +0 -0
  66. package/dist/components/form/components/Select.d.ts +0 -0
  67. package/dist/components/form/components/Select.d.ts.map +0 -0
  68. package/dist/components/form/components/Switch.d.ts +0 -0
  69. package/dist/components/form/components/Switch.d.ts.map +0 -0
  70. package/dist/components/form/components/Text.d.ts +0 -0
  71. package/dist/components/form/components/Text.d.ts.map +0 -0
  72. package/dist/components/form/components/index.d.ts +0 -0
  73. package/dist/components/form/components/index.d.ts.map +0 -0
  74. package/dist/components/form/components/validation/Validation.d.ts +4 -1
  75. package/dist/components/form/components/validation/Validation.d.ts.map +1 -1
  76. package/dist/components/index.d.ts +0 -0
  77. package/dist/components/index.d.ts.map +0 -0
  78. package/dist/components/login/LanguageSet.d.ts +0 -0
  79. package/dist/components/login/LanguageSet.d.ts.map +1 -1
  80. package/dist/components/theme/Card.d.ts +0 -0
  81. package/dist/components/theme/Card.d.ts.map +0 -0
  82. package/dist/components/theme/CardDashboard.d.ts +0 -0
  83. package/dist/components/theme/CardDashboard.d.ts.map +0 -0
  84. package/dist/components/theme/CardUser.d.ts +0 -0
  85. package/dist/components/theme/CardUser.d.ts.map +0 -0
  86. package/dist/components/theme/Loading.d.ts +0 -0
  87. package/dist/components/theme/Loading.d.ts.map +0 -0
  88. package/dist/components/theme/MailTemplateWidget.d.ts +0 -0
  89. package/dist/components/theme/MailTemplateWidget.d.ts.map +1 -1
  90. package/dist/components/theme/Mailbox.d.ts +0 -0
  91. package/dist/components/theme/Mailbox.d.ts.map +1 -1
  92. package/dist/components/theme/MessagesBlock.d.ts +0 -0
  93. package/dist/components/theme/MessagesBlock.d.ts.map +0 -0
  94. package/dist/components/theme/Timeline.d.ts +0 -0
  95. package/dist/components/theme/Timeline.d.ts.map +0 -0
  96. package/dist/components/theme/UserWidget.d.ts +0 -0
  97. package/dist/components/theme/UserWidget.d.ts.map +1 -1
  98. package/dist/components/theme/index.d.ts +0 -0
  99. package/dist/components/theme/index.d.ts.map +0 -0
  100. package/dist/config/ConexysConfig.d.ts +0 -0
  101. package/dist/config/ConexysConfig.d.ts.map +0 -0
  102. package/dist/constants/global.d.ts +0 -0
  103. package/dist/constants/global.d.ts.map +1 -1
  104. package/dist/context/PermissionContext.d.ts +0 -0
  105. package/dist/context/PermissionContext.d.ts.map +0 -0
  106. package/dist/hooks/FormHooksNormal.d.ts +1 -1
  107. package/dist/hooks/FormHooksNormal.d.ts.map +1 -1
  108. package/dist/hooks/FormHooksNormalGetPost.d.ts +0 -0
  109. package/dist/hooks/FormHooksNormalGetPost.d.ts.map +1 -1
  110. package/dist/hooks/FormHooksNormalMulti.d.ts +0 -0
  111. package/dist/hooks/FormHooksNormalMulti.d.ts.map +0 -0
  112. package/dist/hooks/FormHooksNormalNoUser.d.ts +0 -0
  113. package/dist/hooks/FormHooksNormalNoUser.d.ts.map +1 -1
  114. package/dist/hooks/FormHooksUpload.d.ts +0 -0
  115. package/dist/hooks/FormHooksUpload.d.ts.map +1 -1
  116. package/dist/hooks/FormHooksUploadPatch.d.ts +0 -0
  117. package/dist/hooks/FormHooksUploadPatch.d.ts.map +1 -1
  118. package/dist/hooks/MRT_Localization.d.ts +0 -0
  119. package/dist/hooks/MRT_Localization.d.ts.map +0 -0
  120. package/dist/hooks/useFingerprintJS.d.ts +0 -0
  121. package/dist/hooks/useFingerprintJS.d.ts.map +0 -0
  122. package/dist/hooks/useLanguageSync.d.ts +0 -0
  123. package/dist/hooks/useLanguageSync.d.ts.map +0 -0
  124. package/dist/hooks/usePermission.d.ts +0 -0
  125. package/dist/hooks/usePermission.d.ts.map +0 -0
  126. package/dist/hooks/useSocket.d.ts +0 -0
  127. package/dist/hooks/useSocket.d.ts.map +1 -1
  128. package/dist/hooks/useZoomPrevention.d.ts +0 -0
  129. package/dist/hooks/useZoomPrevention.d.ts.map +0 -0
  130. package/dist/index.css +0 -0
  131. package/dist/index.css.map +1 -1
  132. package/dist/index.d.ts +1 -0
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.esm.css +0 -0
  135. package/dist/index.esm.css.map +1 -1
  136. package/dist/index.esm.js +3285 -273
  137. package/dist/index.esm.js.map +1 -1
  138. package/dist/index.js +3285 -272
  139. package/dist/index.js.map +1 -1
  140. package/dist/services/deleteFormService.d.ts +0 -0
  141. package/dist/services/deleteFormService.d.ts.map +1 -1
  142. package/dist/services/deleteService.d.ts +0 -0
  143. package/dist/services/deleteService.d.ts.map +1 -1
  144. package/dist/services/deleteServiceExtended.d.ts +0 -0
  145. package/dist/services/deleteServiceExtended.d.ts.map +0 -0
  146. package/dist/services/getService.d.ts +0 -0
  147. package/dist/services/getService.d.ts.map +1 -1
  148. package/dist/services/getServiceExtended.d.ts +0 -0
  149. package/dist/services/getServiceExtended.d.ts.map +1 -1
  150. package/dist/services/patchFormService.d.ts +0 -0
  151. package/dist/services/patchFormService.d.ts.map +1 -1
  152. package/dist/services/patchService.d.ts +0 -0
  153. package/dist/services/patchService.d.ts.map +1 -1
  154. package/dist/services/patchServiceExtended.d.ts +0 -0
  155. package/dist/services/patchServiceExtended.d.ts.map +0 -0
  156. package/dist/services/postFormService.d.ts +0 -0
  157. package/dist/services/postFormService.d.ts.map +1 -1
  158. package/dist/services/postFormServiceGetPost.d.ts +0 -0
  159. package/dist/services/postFormServiceGetPost.d.ts.map +1 -1
  160. package/dist/services/postService.d.ts +0 -0
  161. package/dist/services/postService.d.ts.map +1 -1
  162. package/dist/services/postServiceExtended.d.ts +0 -0
  163. package/dist/services/postServiceExtended.d.ts.map +1 -1
  164. package/dist/services/restoreFormService.d.ts +0 -0
  165. package/dist/services/restoreFormService.d.ts.map +1 -1
  166. package/dist/shared/baseFingerprintService.d.ts +0 -0
  167. package/dist/shared/baseFingerprintService.d.ts.map +0 -0
  168. package/dist/shared/crudtable/ActionButtons.d.ts +0 -0
  169. package/dist/shared/crudtable/ActionButtons.d.ts.map +0 -0
  170. package/dist/shared/crudtable/Table.d.ts +0 -0
  171. package/dist/shared/crudtable/Table.d.ts.map +0 -0
  172. package/dist/shared/crudtable/useTableData.d.ts +0 -0
  173. package/dist/shared/crudtable/useTableData.d.ts.map +0 -0
  174. package/dist/shared/crudtable/useTableDataInstall.d.ts +0 -0
  175. package/dist/shared/crudtable/useTableDataInstall.d.ts.map +0 -0
  176. package/dist/shared/sharedComponentsAPI.d.ts +0 -0
  177. package/dist/shared/sharedComponentsAPI.d.ts.map +0 -0
  178. package/dist/shared/sharedServicesAPI.d.ts +0 -0
  179. package/dist/shared/sharedServicesAPI.d.ts.map +1 -1
  180. package/dist/types/auth.types.d.ts +1 -1
  181. package/dist/types/auth.types.d.ts.map +1 -1
  182. package/dist/types/common/form.types.d.ts +0 -0
  183. package/dist/types/common/form.types.d.ts.map +0 -0
  184. package/dist/types/common/index.d.ts +0 -0
  185. package/dist/types/common/index.d.ts.map +0 -0
  186. package/dist/types/common/props.types.d.ts +0 -0
  187. package/dist/types/common/props.types.d.ts.map +0 -0
  188. package/dist/types/common/request.types.d.ts +1 -0
  189. package/dist/types/common/request.types.d.ts.map +1 -1
  190. package/dist/types/common/service.types.d.ts +0 -0
  191. package/dist/types/common/service.types.d.ts.map +0 -0
  192. package/dist/types/common/user.types.d.ts +0 -0
  193. package/dist/types/common/user.types.d.ts.map +0 -0
  194. package/dist/types/components/appFormFields.types.d.ts +1 -0
  195. package/dist/types/components/appFormFields.types.d.ts.map +1 -1
  196. package/dist/types/components/appFormFieldsFromConfig.types.d.ts +0 -0
  197. package/dist/types/components/appFormFieldsFromConfig.types.d.ts.map +0 -0
  198. package/dist/types/components/appFormFieldsNoUser.types.d.ts +0 -0
  199. package/dist/types/components/appFormFieldsNoUser.types.d.ts.map +0 -0
  200. package/dist/types/components/appFormFieldsTable.types.d.ts +0 -0
  201. package/dist/types/components/appFormFieldsTable.types.d.ts.map +0 -0
  202. package/dist/types/components/backendStatus.types.d.ts +0 -0
  203. package/dist/types/components/backendStatus.types.d.ts.map +0 -0
  204. package/dist/types/components/components.types.d.ts +0 -0
  205. package/dist/types/components/components.types.d.ts.map +0 -0
  206. package/dist/types/components/dialog.types.d.ts +0 -0
  207. package/dist/types/components/dialog.types.d.ts.map +0 -0
  208. package/dist/types/components/form.types.d.ts +16 -0
  209. package/dist/types/components/form.types.d.ts.map +1 -1
  210. package/dist/types/components/login.types.d.ts +0 -0
  211. package/dist/types/components/login.types.d.ts.map +0 -0
  212. package/dist/types/components/pages.types.d.ts +0 -0
  213. package/dist/types/components/pages.types.d.ts.map +0 -0
  214. package/dist/types/components/theme.types.d.ts +0 -0
  215. package/dist/types/components/theme.types.d.ts.map +0 -0
  216. package/dist/types/hooks/formHooksNormal.types.d.ts +0 -0
  217. package/dist/types/hooks/formHooksNormal.types.d.ts.map +0 -0
  218. package/dist/types/hooks/formHooksNormalGetPost.types.d.ts +0 -0
  219. package/dist/types/hooks/formHooksNormalGetPost.types.d.ts.map +0 -0
  220. package/dist/types/hooks/formHooksNormalMulti.types.d.ts +0 -0
  221. package/dist/types/hooks/formHooksNormalMulti.types.d.ts.map +0 -0
  222. package/dist/types/hooks/formHooksNormalNoUser.types.d.ts +0 -0
  223. package/dist/types/hooks/formHooksNormalNoUser.types.d.ts.map +0 -0
  224. package/dist/types/hooks/formHooksUpload.types.d.ts +0 -0
  225. package/dist/types/hooks/formHooksUpload.types.d.ts.map +0 -0
  226. package/dist/types/hooks/mrt_Localization.types.d.ts +0 -0
  227. package/dist/types/hooks/mrt_Localization.types.d.ts.map +0 -0
  228. package/dist/types/permission.types.d.ts +0 -0
  229. package/dist/types/permission.types.d.ts.map +0 -0
  230. package/dist/types/services/postFormService.types.d.ts +0 -0
  231. package/dist/types/services/postFormService.types.d.ts.map +0 -0
  232. package/dist/types/services/postFormServiceGetPost.types.d.ts +0 -0
  233. package/dist/types/services/postFormServiceGetPost.types.d.ts.map +0 -0
  234. package/dist/types/services/postServiceExtended.types.d.ts +0 -0
  235. package/dist/types/services/postServiceExtended.types.d.ts.map +0 -0
  236. package/dist/types/shared/crudtable.types.d.ts +0 -0
  237. package/dist/types/shared/crudtable.types.d.ts.map +0 -0
  238. package/dist/types/themecontext.types.d.ts +0 -0
  239. package/dist/types/themecontext.types.d.ts.map +0 -0
  240. package/dist/types/utilities/generateRandomPassword.types.d.ts +0 -0
  241. package/dist/types/utilities/generateRandomPassword.types.d.ts.map +0 -0
  242. package/dist/utilities/GenerateRandomPassword.d.ts +0 -0
  243. package/dist/utilities/GenerateRandomPassword.d.ts.map +0 -0
  244. package/dist/utilities/authStorage.d.ts +9 -5
  245. package/dist/utilities/authStorage.d.ts.map +1 -1
  246. package/dist/utilities/authStorage2.d.ts +20 -0
  247. package/dist/utilities/authStorage2.d.ts.map +1 -0
  248. package/dist/utilities/checkAuth.d.ts +0 -0
  249. package/dist/utilities/checkAuth.d.ts.map +1 -1
  250. package/dist/utilities/logConsole.d.ts +0 -0
  251. package/dist/utilities/logConsole.d.ts.map +0 -0
  252. package/dist/utilities/sanitizeHtml.d.ts +2 -0
  253. package/dist/utilities/sanitizeHtml.d.ts.map +1 -0
  254. package/package.json +83 -82
package/dist/index.js CHANGED
@@ -73,7 +73,30 @@ function _interopNamespaceDefault(e) {
73
73
 
74
74
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
75
75
 
76
- const Url = window.restAPI || '';
76
+ const REST_API_KEY = 'restAPI';
77
+ function resolveRestAPI() {
78
+ let value;
79
+ if (typeof window !== 'undefined') {
80
+ const existing = window[REST_API_KEY];
81
+ if (typeof existing === 'string' && existing.length > 0) {
82
+ value = existing;
83
+ } else {
84
+ value = '';
85
+ }
86
+ try {
87
+ Object.defineProperty(window, REST_API_KEY, {
88
+ value,
89
+ writable: false,
90
+ configurable: false,
91
+ enumerable: true
92
+ });
93
+ } catch {}
94
+ } else {
95
+ value = '';
96
+ }
97
+ return value;
98
+ }
99
+ const Url = resolveRestAPI();
77
100
 
78
101
  const logConsole = (configLogs, type, message, ...args) => {
79
102
  if (!configLogs) return;
@@ -116,6 +139,159 @@ const logConsole = (configLogs, type, message, ...args) => {
116
139
  }
117
140
  };
118
141
 
142
+ const config$4 = {
143
+ headers: {
144
+ 'Content-Type': 'application/json'
145
+ }
146
+ };
147
+ const TYPE_SESSION_CACHE_KEY = 'cx_type_session';
148
+ const COOKIE_AUTH_MARKER = 'cookie';
149
+ let USE_COOKIES_FOR_AUTH = false;
150
+ let SESSION_EXPIRATION = 365;
151
+ let isConfigInitialized = false;
152
+ let initPromise = null;
153
+ let isFetching = false;
154
+ const getCachedTypeSession = () => {
155
+ try {
156
+ return localStorage.getItem(TYPE_SESSION_CACHE_KEY);
157
+ } catch {
158
+ return null;
159
+ }
160
+ };
161
+ const resetAuthConfig = () => {
162
+ initPromise = null;
163
+ isConfigInitialized = false;
164
+ isFetching = false;
165
+ };
166
+ const setCachedTypeSession = value => {
167
+ try {
168
+ localStorage.setItem(TYPE_SESSION_CACHE_KEY, value);
169
+ } catch {}
170
+ };
171
+ const fetchTypeSession = async configLogs => {
172
+ const baseURL = Url + 'getsettings';
173
+ try {
174
+ await serviceData(baseURL, {
175
+ keys: 'type_session'
176
+ }, config$4, value => {
177
+ const resolved = value && typeof value === 'string' ? value : 'localstorage';
178
+ USE_COOKIES_FOR_AUTH = resolved === 'cookie';
179
+ setCachedTypeSession(resolved);
180
+ }, configLogs);
181
+ } catch (error) {
182
+ logConsole(configLogs, 'error', 'Error loading authentication configuration:', error);
183
+ }
184
+ };
185
+ const initializeAuthConfig = configLogs => {
186
+ if (isConfigInitialized) return Promise.resolve();
187
+ if (initPromise) return initPromise;
188
+ initPromise = (async () => {
189
+ if (isConfigInitialized) return;
190
+ const cached = getCachedTypeSession();
191
+ if (cached !== null) {
192
+ USE_COOKIES_FOR_AUTH = cached === 'cookie';
193
+ isConfigInitialized = true;
194
+ return;
195
+ }
196
+ if (isFetching) return;
197
+ isFetching = true;
198
+ try {
199
+ await fetchTypeSession(configLogs);
200
+ isConfigInitialized = true;
201
+ } finally {
202
+ isFetching = false;
203
+ initPromise = null;
204
+ }
205
+ })();
206
+ return initPromise;
207
+ };
208
+ const refreshTypeSessionFromDB = async configLogs => {
209
+ if (initPromise && !isFetching) {
210
+ await initPromise;
211
+ } else if (isFetching) {
212
+ if (initPromise) await initPromise;
213
+ }
214
+ if (isFetching) {
215
+ if (initPromise) await initPromise;
216
+ return;
217
+ }
218
+ isFetching = true;
219
+ initPromise = (async () => {
220
+ try {
221
+ await fetchTypeSession(configLogs);
222
+ isConfigInitialized = true;
223
+ } finally {
224
+ isFetching = false;
225
+ initPromise = null;
226
+ }
227
+ })();
228
+ await initPromise;
229
+ };
230
+ const authStorage = {
231
+ initialize(configLogs) {
232
+ return initializeAuthConfig(configLogs);
233
+ },
234
+ getSessionTypeValue(_configLogs) {
235
+ return 'cookie';
236
+ },
237
+ async setAuthToken(_token, _configLogs) {
238
+ localStorage.removeItem('cxauthxc');
239
+ this.deleteCookie('cxauthxc');
240
+ },
241
+ getAuthToken(_configLogs) {
242
+ return COOKIE_AUTH_MARKER;
243
+ },
244
+ hasActiveSession(_configLogs) {
245
+ const sessionId = this.getCookie('cx_session');
246
+ const csrfToken = this.getCookie('csrf_token');
247
+ return sessionId !== null && sessionId !== '' && csrfToken !== null && csrfToken !== '';
248
+ },
249
+ getCsrfToken() {
250
+ return this.getCookie('csrf_token');
251
+ },
252
+ async setSessionId(sessionId, _configLogs) {
253
+ this.setCookie('cx_session', sessionId, SESSION_EXPIRATION);
254
+ localStorage.removeItem('cx_session');
255
+ },
256
+ getSessionId(_configLogs) {
257
+ return this.getCookie('cx_session');
258
+ },
259
+ refreshTypeSession(configLogs) {
260
+ return refreshTypeSessionFromDB(configLogs);
261
+ },
262
+ async removeAuthData(configLogs) {
263
+ this.deleteCookie('cxauthxc');
264
+ this.deleteCookie('cx_session');
265
+ this.deleteCookie('csrf_token');
266
+ localStorage.removeItem('cxauthxc');
267
+ localStorage.removeItem('cx_session');
268
+ try {
269
+ localStorage.removeItem(TYPE_SESSION_CACHE_KEY);
270
+ } catch {}
271
+ resetAuthConfig();
272
+ },
273
+ setCookie(name, value, days) {
274
+ const date = new Date();
275
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
276
+ const expires = `expires=${date.toUTCString()}`;
277
+ const secure = window.location.protocol === 'https:' ? ';Secure' : '';
278
+ document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict${secure}`;
279
+ },
280
+ getCookie(name) {
281
+ const nameEQ = `${name}=`;
282
+ const ca = document.cookie.split(';');
283
+ for (let i = 0; i < ca.length; i++) {
284
+ let c = ca[i];
285
+ while (c.charAt(0) === ' ') c = c.substring(1, c.length);
286
+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
287
+ }
288
+ return null;
289
+ },
290
+ deleteCookie(name) {
291
+ document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;`;
292
+ }
293
+ };
294
+
119
295
  const postservice = async (datauser, configLogs) => {
120
296
  const postURL = Url + datauser.postServerURL;
121
297
  const {
@@ -124,19 +300,25 @@ const postservice = async (datauser, configLogs) => {
124
300
  cxauthxc,
125
301
  ...requestData
126
302
  } = datauser;
303
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
127
304
  let config;
128
305
  if (authorization === true || authorization === 'true') {
129
306
  config = {
307
+ withCredentials: true,
130
308
  headers: {
131
309
  Authorization: `Bearer ${cxauthxc}`,
310
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
132
311
  'X-Session-ID': datauser.sessionID || '',
133
312
  'X-Fingerprint': datauser.fingerprint || '',
313
+ 'X-Session-Type': xSessionType,
134
314
  'Content-Type': 'application/json'
135
315
  }
136
316
  };
137
317
  } else {
138
318
  config = {
319
+ withCredentials: true,
139
320
  headers: {
321
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
140
322
  'Content-Type': 'application/json'
141
323
  }
142
324
  };
@@ -164,22 +346,27 @@ const deleteservice = async (datauser, configLogs) => {
164
346
  cxauthxc,
165
347
  ...requestData
166
348
  } = datauser;
349
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
167
350
  let headers;
168
351
  if (authorization === true || authorization === 'true') {
169
352
  headers = {
170
353
  Authorization: `Bearer ${cxauthxc}`,
354
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
171
355
  'X-Session-ID': datauser.sessionID || '',
172
356
  'X-Fingerprint': datauser.fingerprint || '',
357
+ 'X-Session-Type': xSessionType,
173
358
  'Content-Type': 'application/json'
174
359
  };
175
360
  } else {
176
361
  headers = {
362
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
177
363
  'Content-Type': 'application/json'
178
364
  };
179
365
  }
180
366
  logConsole(configLogs, 'debug', '[Payload] ', requestData);
181
367
  try {
182
368
  const response = await axios.delete(deleteURL, {
369
+ withCredentials: true,
183
370
  headers,
184
371
  data: requestData
185
372
  });
@@ -194,6 +381,7 @@ const deleteservice = async (datauser, configLogs) => {
194
381
 
195
382
  const getservice = async (datauser, configLogs) => {
196
383
  const getURL = Url + datauser.postServerURL;
384
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
197
385
  const {
198
386
  authorization,
199
387
  postServerURL,
@@ -205,15 +393,18 @@ const getservice = async (datauser, configLogs) => {
205
393
  let config;
206
394
  if (authorization === true || authorization === 'true') {
207
395
  config = {
396
+ withCredentials: true,
208
397
  headers: {
209
398
  Authorization: `Bearer ${cxauthxc}`,
210
399
  'X-Session-ID': sessionID || '',
211
- 'X-Fingerprint': fingerprint || ''
400
+ 'X-Fingerprint': fingerprint || '',
401
+ 'X-Session-Type': xSessionType
212
402
  },
213
403
  params: requestData
214
404
  };
215
405
  } else {
216
406
  config = {
407
+ withCredentials: true,
217
408
  params: requestData
218
409
  };
219
410
  }
@@ -255,101 +446,6 @@ const getOrSetFingerprint = async (fpHash = '', configLogs) => {
255
446
  return await loadFingerprint(configLogs);
256
447
  };
257
448
 
258
- const config$4 = {
259
- headers: {
260
- 'Content-Type': 'application/json'
261
- }
262
- };
263
- let USE_COOKIES_FOR_AUTH = false;
264
- let SESSION_EXPIRATION = 365;
265
- let isConfigInitialized = false;
266
- let initPromise = null;
267
- const initializeAuthConfig = configLogs => {
268
- if (initPromise) return initPromise;
269
- initPromise = (async () => {
270
- if (isConfigInitialized) return;
271
- const baseURL = Url + 'getsettings';
272
- try {
273
- await serviceData(baseURL, {
274
- keys: 'type_session'
275
- }, config$4, value => {
276
- USE_COOKIES_FOR_AUTH = value === 'cookie';
277
- isConfigInitialized = true;
278
- }, configLogs);
279
- } catch (error) {
280
- logConsole(configLogs, 'error', 'Error loading authentication configuration:', error);
281
- } finally {
282
- isConfigInitialized = true;
283
- }
284
- })();
285
- return initPromise;
286
- };
287
- const authStorage = {
288
- initialize(configLogs) {
289
- return initializeAuthConfig(configLogs);
290
- },
291
- setAuthToken(token, configLogs) {
292
- initializeAuthConfig(configLogs);
293
- if (USE_COOKIES_FOR_AUTH) {
294
- this.setCookie('cxauthxc', token, SESSION_EXPIRATION);
295
- } else {
296
- localStorage.setItem('cxauthxc', token);
297
- }
298
- },
299
- getAuthToken(configLogs) {
300
- initializeAuthConfig(configLogs);
301
- if (USE_COOKIES_FOR_AUTH) {
302
- return this.getCookie('cxauthxc');
303
- }
304
- return localStorage.getItem('cxauthxc');
305
- },
306
- setSessionId(sessionId, configLogs) {
307
- initializeAuthConfig(configLogs);
308
- if (USE_COOKIES_FOR_AUTH) {
309
- this.setCookie('cx_session', sessionId, SESSION_EXPIRATION);
310
- } else {
311
- localStorage.setItem('cx_session', sessionId);
312
- }
313
- },
314
- getSessionId(configLogs) {
315
- initializeAuthConfig(configLogs);
316
- if (USE_COOKIES_FOR_AUTH) {
317
- return this.getCookie('cx_session');
318
- }
319
- return localStorage.getItem('cx_session');
320
- },
321
- removeAuthData(configLogs) {
322
- initializeAuthConfig(configLogs);
323
- if (USE_COOKIES_FOR_AUTH) {
324
- this.deleteCookie('cxauthxc');
325
- this.deleteCookie('cx_session');
326
- } else {
327
- localStorage.removeItem('cxauthxc');
328
- localStorage.removeItem('cx_session');
329
- }
330
- },
331
- setCookie(name, value, days) {
332
- const date = new Date();
333
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
334
- const expires = `expires=${date.toUTCString()}`;
335
- const secure = window.location.protocol === 'https:' ? ';Secure' : '';
336
- document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict${secure}`;
337
- },
338
- getCookie(name) {
339
- const nameEQ = `${name}=`;
340
- const ca = document.cookie.split(';');
341
- for (let i = 0; i < ca.length; i++) {
342
- let c = ca[i];
343
- while (c.charAt(0) === ' ') c = c.substring(1, c.length);
344
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
345
- }
346
- return null;
347
- },
348
- deleteCookie(name) {
349
- document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;`;
350
- }
351
- };
352
-
353
449
  const handleError$3 = (err, t, configLogs, setIsError, setMessageerror) => {
354
450
  let errorMessage;
355
451
  if (!err?.response) {
@@ -377,7 +473,15 @@ const servicePostBasic = async (fpHash = '', sessionID, baseURL, config, setData
377
473
  };
378
474
  logConsole(configLogs, 'debug', '[Payload] ', key);
379
475
  try {
380
- const response = await axios.post(baseURL, key, config);
476
+ const response = await axios.post(baseURL, key, {
477
+ ...config,
478
+ withCredentials: true,
479
+ headers: {
480
+ ...(config?.headers || {}),
481
+ 'X-Session-Type': authStorage.getSessionTypeValue(configLogs),
482
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
483
+ }
484
+ });
381
485
  logConsole(configLogs, 'info', '[Request] ', baseURL);
382
486
  logConsole(configLogs, 'data', '', response.data);
383
487
  setData(response.data);
@@ -389,7 +493,15 @@ const servicePostBasic = async (fpHash = '', sessionID, baseURL, config, setData
389
493
  const serviceData = async (baseURL, key, config, setData, configLogs) => {
390
494
  logConsole(configLogs, 'debug', '[Payload] ', key);
391
495
  try {
392
- const response = await axios.post(baseURL, key, config);
496
+ const response = await axios.post(baseURL, key, {
497
+ ...config,
498
+ withCredentials: true,
499
+ headers: {
500
+ ...(config?.headers || {}),
501
+ 'X-Session-Type': authStorage.getSessionTypeValue(configLogs),
502
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
503
+ }
504
+ });
393
505
  logConsole(configLogs, 'info', '[Request] ', baseURL);
394
506
  logConsole(configLogs, 'data', '', response.data);
395
507
  const responseData = response.data;
@@ -427,7 +539,14 @@ const servicePost = async (fpHash = '', sessionID, id, permission, postURL, conf
427
539
  } else {
428
540
  logConsole(configLogs, 'debug', '[Payload] ', key);
429
541
  try {
430
- const response = await axios.post(postURL1, key, config);
542
+ const response = await axios.post(postURL1, key, {
543
+ ...config,
544
+ withCredentials: true,
545
+ headers: {
546
+ ...(config?.headers || {}),
547
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
548
+ }
549
+ });
431
550
  logConsole(configLogs, 'info', '[Request] ', postURL1);
432
551
  logConsole(configLogs, 'data', '', response.data);
433
552
  setPost(response.data);
@@ -510,8 +629,16 @@ const servicePostData = async (fpHash = '', sessionID, id, permission, postURL,
510
629
  } else {
511
630
  logConsole(configLogs, 'debug', '[Payload] ', key);
512
631
  try {
513
- const response = await axios.post(postURL1, key, config);
632
+ const response = await axios.post(postURL1, key, {
633
+ ...config,
634
+ withCredentials: true,
635
+ headers: {
636
+ ...(config?.headers || {}),
637
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
638
+ }
639
+ });
514
640
  logConsole(configLogs, 'info', '[Request] ', postURL1);
641
+ logConsole(configLogs, 'data', '', response.data);
515
642
  setPost(response.data);
516
643
  } catch (error) {
517
644
  logConsole(configLogs, 'error', '', error);
@@ -545,11 +672,6 @@ const serviceLogout = async (fpHash = '', sessionID, cxauthxc, t, setAuthTokens,
545
672
  const userLanguage = localStorage.getItem('userLanguage');
546
673
  const displaymode = localStorage.getItem('displaymode');
547
674
  const displayzoom = localStorage.getItem('displayzoom');
548
- localStorage.clear();
549
- authStorage.removeAuthData(configLogs);
550
- if (userLanguage) localStorage.setItem('userLanguage', userLanguage);
551
- if (displaymode) localStorage.setItem('displaymode', displaymode);
552
- if (displayzoom) localStorage.setItem('displayzoom', displayzoom);
553
675
  await postService.postservice({
554
676
  sessionID,
555
677
  cxauthxc,
@@ -557,6 +679,10 @@ const serviceLogout = async (fpHash = '', sessionID, cxauthxc, t, setAuthTokens,
557
679
  authorization: true,
558
680
  fingerprint: visitorIdHash
559
681
  }, configLogs);
682
+ authStorage.removeAuthData(configLogs);
683
+ if (userLanguage) localStorage.setItem('userLanguage', userLanguage);
684
+ if (displaymode) localStorage.setItem('displaymode', displaymode);
685
+ if (displayzoom) localStorage.setItem('displayzoom', displayzoom);
560
686
  setAuthTokens('');
561
687
  } catch (err) {
562
688
  const errorMessage = handleError$3(err, t, configLogs);
@@ -586,119 +712,2785 @@ const serviceFavorites = async (type = '', fpHash = '', sessionID, postURL, cxau
586
712
  } else {
587
713
  unreadcount = await postService.postservice(requestData, configLogs);
588
714
  }
589
- if (unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount)) {
590
- setPost(unreadcount.data);
715
+ if (unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount)) {
716
+ setPost(unreadcount.data);
717
+ } else {
718
+ setPost(unreadcount);
719
+ }
720
+ logConsole(configLogs, 'data', '', unreadcount);
721
+ const favoriteValue = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
722
+ if (type === 'get' && favoriteValue === true) {
723
+ setColor('#ffcd38');
724
+ } else if (type === 'set') {
725
+ setColor('#ffcd38');
726
+ localStorage.setItem('favoritessynch01', 'true');
727
+ localStorage.setItem('favoritessynch02', 'true');
728
+ window.dispatchEvent(new Event('favorites'));
729
+ } else if (type === 'del') {
730
+ setColor('');
731
+ localStorage.setItem('favoritessynch01', 'true');
732
+ localStorage.setItem('favoritessynch02', 'true');
733
+ window.dispatchEvent(new Event('favorites'));
734
+ }
735
+ setIsError(false);
736
+ } catch (err) {
737
+ setError(true);
738
+ handleError$3(err, t, configLogs, setIsError, setMessageerror);
739
+ } finally {
740
+ setLoading(false);
741
+ }
742
+ };
743
+ const serviceGetFavorites = async (fpHash = '', sessionID, postURL, cxauthxc, t, setPost, setIsError, setError, setMessageerror, setLoading, configLogs, ...rest) => {
744
+ const visitorIdHash = await getOrSetFingerprint(fpHash);
745
+ try {
746
+ const requestData = {
747
+ ...rest[0],
748
+ sessionID,
749
+ cxauthxc,
750
+ postServerURL: postURL,
751
+ authorization: true,
752
+ fingerprint: visitorIdHash
753
+ };
754
+ const unreadcount = await getservice(requestData, configLogs);
755
+ const responseData = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
756
+ setPost(responseData);
757
+ localStorage.setItem('favoritessynch03', JSON.stringify(responseData));
758
+ logConsole(configLogs, 'data', '', unreadcount);
759
+ setIsError(false);
760
+ } catch (err) {
761
+ setError(true);
762
+ handleError$3(err, t, configLogs, setIsError, setMessageerror);
763
+ } finally {
764
+ setLoading(false);
765
+ }
766
+ };
767
+
768
+ const defaultConfig$3 = {
769
+ enableLogs: false,
770
+ enableLogsError: false,
771
+ enableLogsWarning: false,
772
+ enableLogsInfo: false,
773
+ enableLogsData: false,
774
+ enableLogsDebug: false,
775
+ developmentMode: false
776
+ };
777
+ const ConexysConfigContext = /*#__PURE__*/React.createContext(defaultConfig$3);
778
+ const ConexysConfigProvider = ({
779
+ children,
780
+ config = {}
781
+ }) => {
782
+ const mergedConfig = {
783
+ ...defaultConfig$3,
784
+ ...config
785
+ };
786
+ return /*#__PURE__*/React.createElement(ConexysConfigContext.Provider, {
787
+ value: mergedConfig
788
+ }, children);
789
+ };
790
+ const useConexysConfig = () => {
791
+ return React.useContext(ConexysConfigContext);
792
+ };
793
+ const isDevelopmentMode = config => {
794
+ return config.developmentMode;
795
+ };
796
+
797
+ const config$3 = {
798
+ headers: {
799
+ 'Content-Type': 'application/json'
800
+ }
801
+ };
802
+ function AppDataSettings({
803
+ keys
804
+ }) {
805
+ const configLogs = useConexysConfig();
806
+ const postURL = Url + 'getsettings';
807
+ const [post, setPost] = React.useState(null);
808
+ const [error, setError] = React.useState(false);
809
+ const hasFetched = React.useRef(false);
810
+ const fetchData = React.useCallback(async () => {
811
+ if (hasFetched.current) return;
812
+ hasFetched.current = true;
813
+ try {
814
+ await serviceData(postURL, {
815
+ keys: keys
816
+ }, config$3, setPost, configLogs);
817
+ } catch (err) {
818
+ setError(true);
819
+ logConsole(configLogs, 'error', 'Error fetching data:', err);
820
+ console.error('Error fetching data:', err);
821
+ }
822
+ }, []);
823
+ React.useEffect(() => {
824
+ fetchData();
825
+ }, [fetchData]);
826
+ if (!post) return null;
827
+ return /*#__PURE__*/React.createElement(React.Fragment, null, error ? /*#__PURE__*/React.createElement("div", null, "Error loading data") : post);
828
+ }
829
+
830
+ /*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */
831
+
832
+ function _arrayLikeToArray(r, a) {
833
+ (null == a || a > r.length) && (a = r.length);
834
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
835
+ return n;
836
+ }
837
+ function _arrayWithHoles(r) {
838
+ if (Array.isArray(r)) return r;
839
+ }
840
+ function _iterableToArrayLimit(r, l) {
841
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
842
+ if (null != t) {
843
+ var e,
844
+ n,
845
+ i,
846
+ u,
847
+ a = [],
848
+ f = true,
849
+ o = false;
850
+ try {
851
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
852
+ } catch (r) {
853
+ o = true, n = r;
854
+ } finally {
855
+ try {
856
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
857
+ } finally {
858
+ if (o) throw n;
859
+ }
860
+ }
861
+ return a;
862
+ }
863
+ }
864
+ function _nonIterableRest() {
865
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
866
+ }
867
+ function _slicedToArray(r, e) {
868
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
869
+ }
870
+ function _unsupportedIterableToArray(r, a) {
871
+ if (r) {
872
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
873
+ var t = {}.toString.call(r).slice(8, -1);
874
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
875
+ }
876
+ }
877
+
878
+ const entries = Object.entries,
879
+ setPrototypeOf = Object.setPrototypeOf,
880
+ isFrozen = Object.isFrozen,
881
+ getPrototypeOf = Object.getPrototypeOf,
882
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
883
+ let freeze = Object.freeze,
884
+ seal = Object.seal,
885
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
886
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
887
+ apply = _ref.apply,
888
+ construct = _ref.construct;
889
+ if (!freeze) {
890
+ freeze = function freeze(x) {
891
+ return x;
892
+ };
893
+ }
894
+ if (!seal) {
895
+ seal = function seal(x) {
896
+ return x;
897
+ };
898
+ }
899
+ if (!apply) {
900
+ apply = function apply(func, thisArg) {
901
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
902
+ args[_key - 2] = arguments[_key];
903
+ }
904
+ return func.apply(thisArg, args);
905
+ };
906
+ }
907
+ if (!construct) {
908
+ construct = function construct(Func) {
909
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
910
+ args[_key2 - 1] = arguments[_key2];
911
+ }
912
+ return new Func(...args);
913
+ };
914
+ }
915
+ const arrayForEach = unapply(Array.prototype.forEach);
916
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
917
+ const arrayPop = unapply(Array.prototype.pop);
918
+ const arrayPush = unapply(Array.prototype.push);
919
+ const arraySplice = unapply(Array.prototype.splice);
920
+ const arrayIsArray = Array.isArray;
921
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
922
+ const stringToString = unapply(String.prototype.toString);
923
+ const stringMatch = unapply(String.prototype.match);
924
+ const stringReplace = unapply(String.prototype.replace);
925
+ const stringIndexOf = unapply(String.prototype.indexOf);
926
+ const stringTrim = unapply(String.prototype.trim);
927
+ const numberToString = unapply(Number.prototype.toString);
928
+ const booleanToString = unapply(Boolean.prototype.toString);
929
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
930
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
931
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
932
+ const objectToString = unapply(Object.prototype.toString);
933
+ const regExpTest = unapply(RegExp.prototype.test);
934
+ const typeErrorCreate = unconstruct(TypeError);
935
+ /**
936
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
937
+ *
938
+ * @param func - The function to be wrapped and called.
939
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
940
+ */
941
+ function unapply(func) {
942
+ return function (thisArg) {
943
+ if (thisArg instanceof RegExp) {
944
+ thisArg.lastIndex = 0;
945
+ }
946
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
947
+ args[_key3 - 1] = arguments[_key3];
948
+ }
949
+ return apply(func, thisArg, args);
950
+ };
951
+ }
952
+ /**
953
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
954
+ *
955
+ * @param func - The constructor function to be wrapped and called.
956
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
957
+ */
958
+ function unconstruct(Func) {
959
+ return function () {
960
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
961
+ args[_key4] = arguments[_key4];
962
+ }
963
+ return construct(Func, args);
964
+ };
965
+ }
966
+ /**
967
+ * Add properties to a lookup table
968
+ *
969
+ * @param set - The set to which elements will be added.
970
+ * @param array - The array containing elements to be added to the set.
971
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
972
+ * @returns The modified set with added elements.
973
+ */
974
+ function addToSet(set, array) {
975
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
976
+ if (setPrototypeOf) {
977
+ // Make 'in' and truthy checks like Boolean(set.constructor)
978
+ // independent of any properties defined on Object.prototype.
979
+ // Prevent prototype setters from intercepting set as a this value.
980
+ setPrototypeOf(set, null);
981
+ }
982
+ if (!arrayIsArray(array)) {
983
+ return set;
984
+ }
985
+ let l = array.length;
986
+ while (l--) {
987
+ let element = array[l];
988
+ if (typeof element === 'string') {
989
+ const lcElement = transformCaseFunc(element);
990
+ if (lcElement !== element) {
991
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
992
+ if (!isFrozen(array)) {
993
+ array[l] = lcElement;
994
+ }
995
+ element = lcElement;
996
+ }
997
+ }
998
+ set[element] = true;
999
+ }
1000
+ return set;
1001
+ }
1002
+ /**
1003
+ * Clean up an array to harden against CSPP
1004
+ *
1005
+ * @param array - The array to be cleaned.
1006
+ * @returns The cleaned version of the array
1007
+ */
1008
+ function cleanArray(array) {
1009
+ for (let index = 0; index < array.length; index++) {
1010
+ const isPropertyExist = objectHasOwnProperty(array, index);
1011
+ if (!isPropertyExist) {
1012
+ array[index] = null;
1013
+ }
1014
+ }
1015
+ return array;
1016
+ }
1017
+ /**
1018
+ * Shallow clone an object
1019
+ *
1020
+ * @param object - The object to be cloned.
1021
+ * @returns A new object that copies the original.
1022
+ */
1023
+ function clone(object) {
1024
+ const newObject = create(null);
1025
+ for (const _ref2 of entries(object)) {
1026
+ var _ref3 = _slicedToArray(_ref2, 2);
1027
+ const property = _ref3[0];
1028
+ const value = _ref3[1];
1029
+ const isPropertyExist = objectHasOwnProperty(object, property);
1030
+ if (isPropertyExist) {
1031
+ if (arrayIsArray(value)) {
1032
+ newObject[property] = cleanArray(value);
1033
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
1034
+ newObject[property] = clone(value);
1035
+ } else {
1036
+ newObject[property] = value;
1037
+ }
1038
+ }
1039
+ }
1040
+ return newObject;
1041
+ }
1042
+ /**
1043
+ * Convert non-node values into strings without depending on direct property access.
1044
+ *
1045
+ * @param value - The value to stringify.
1046
+ * @returns A string representation of the provided value.
1047
+ */
1048
+ function stringifyValue(value) {
1049
+ switch (typeof value) {
1050
+ case 'string':
1051
+ {
1052
+ return value;
1053
+ }
1054
+ case 'number':
1055
+ {
1056
+ return numberToString(value);
1057
+ }
1058
+ case 'boolean':
1059
+ {
1060
+ return booleanToString(value);
1061
+ }
1062
+ case 'bigint':
1063
+ {
1064
+ return bigintToString ? bigintToString(value) : '0';
1065
+ }
1066
+ case 'symbol':
1067
+ {
1068
+ return symbolToString ? symbolToString(value) : 'Symbol()';
1069
+ }
1070
+ case 'undefined':
1071
+ {
1072
+ return objectToString(value);
1073
+ }
1074
+ case 'function':
1075
+ case 'object':
1076
+ {
1077
+ if (value === null) {
1078
+ return objectToString(value);
1079
+ }
1080
+ const valueAsRecord = value;
1081
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
1082
+ if (typeof valueToString === 'function') {
1083
+ const stringified = valueToString(valueAsRecord);
1084
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
1085
+ }
1086
+ return objectToString(value);
1087
+ }
1088
+ default:
1089
+ {
1090
+ return objectToString(value);
1091
+ }
1092
+ }
1093
+ }
1094
+ /**
1095
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
1096
+ *
1097
+ * @param object - The object to look up the getter function in its prototype chain.
1098
+ * @param prop - The property name for which to find the getter function.
1099
+ * @returns The getter function found in the prototype chain or a fallback function.
1100
+ */
1101
+ function lookupGetter(object, prop) {
1102
+ while (object !== null) {
1103
+ const desc = getOwnPropertyDescriptor(object, prop);
1104
+ if (desc) {
1105
+ if (desc.get) {
1106
+ return unapply(desc.get);
1107
+ }
1108
+ if (typeof desc.value === 'function') {
1109
+ return unapply(desc.value);
1110
+ }
1111
+ }
1112
+ object = getPrototypeOf(object);
1113
+ }
1114
+ function fallbackValue() {
1115
+ return null;
1116
+ }
1117
+ return fallbackValue;
1118
+ }
1119
+ function isRegex(value) {
1120
+ try {
1121
+ regExpTest(value, '');
1122
+ return true;
1123
+ } catch (_unused) {
1124
+ return false;
1125
+ }
1126
+ }
1127
+
1128
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
1129
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
1130
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
1131
+ // List of SVG elements that are disallowed by default.
1132
+ // We still need to know them so that we can do namespace
1133
+ // checks properly in case one wants to add them to
1134
+ // allow-list.
1135
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
1136
+ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
1137
+ // Similarly to SVG, we want to know all MathML elements,
1138
+ // even those that we disallow by default.
1139
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
1140
+ const text = freeze(['#text']);
1141
+
1142
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);
1143
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dominant-baseline', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'pointer-events', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-orientation', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'vector-effect', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
1144
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
1145
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
1146
+
1147
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
1148
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
1149
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
1150
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
1151
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
1152
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
1153
+ );
1154
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
1155
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
1156
+ );
1157
+ const DOCTYPE_NAME = seal(/^html$/i);
1158
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1159
+ // Markup-significant character probes used by _sanitizeElements.
1160
+ // Shared module-level instances are safe despite the sticky /g flags:
1161
+ // unapply() resets lastIndex for RegExp receivers before every call.
1162
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
1163
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
1164
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
1165
+ const SELF_CLOSING_TAG = seal(/\/>/i);
1166
+
1167
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
1168
+ const NODE_TYPE = {
1169
+ element: 1,
1170
+ attribute: 2,
1171
+ text: 3,
1172
+ cdataSection: 4,
1173
+ entityReference: 5,
1174
+ // Deprecated
1175
+ entityNode: 6,
1176
+ // Deprecated
1177
+ processingInstruction: 7,
1178
+ comment: 8,
1179
+ document: 9,
1180
+ documentType: 10,
1181
+ documentFragment: 11,
1182
+ notation: 12 // Deprecated
1183
+ };
1184
+ /* HTML-namespace elements whose child text nodes are serialized *literally*
1185
+ (unescaped) by the HTML fragment-serialization algorithm. Two reparse-mXSS
1186
+ shapes ride on that literal serialization:
1187
+ (a) an element child - a tree the HTML parser can never build, but the DOM
1188
+ API and an XML/XHTML parse can - after which a `</tag>`-bearing text
1189
+ sibling breaks the element open on reparse; and
1190
+ (b) text-only content that already carries the element's OWN end tag, e.g.
1191
+ `<style>...</style><img onerror=x>` built as a node, which the literal
1192
+ serializer emits verbatim for the HTML parser to re-open.
1193
+ Shape (a) is handled by the firstElementChild branch in _isUnsafeNode; shape
1194
+ (b) by the LITERAL_TEXT_CLOSE probe. Both read textContent (the raw-serialized
1195
+ form for these elements) rather than innerHTML, because an XML/XHTML working
1196
+ document serializes innerHTML with `<` escaped, which silently blinds the
1197
+ innerHTML-based probes (rule 1's second probe and FALLBACK_TAG_CLOSE) there.
1198
+ `script` is never allow-listed, but is kept here so the guard matches the
1199
+ serializer's own literal-text list exactly. */
1200
+ const LITERAL_TEXT_ELEMENT_NAMES = ['style', 'script', 'xmp', 'iframe', 'noembed', 'noframes', 'plaintext', 'noscript'];
1201
+ const LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
1202
+ /* Per-element end-tag matcher. On an HTML reparse the ONLY token that
1203
+ terminates a literal-text element's raw content is its own end tag; a foreign
1204
+ literal-text close (e.g. `</xmp>` sitting inside `<style>`) does not break
1205
+ out, so matching is per-element, not a shared alternation. The lookahead
1206
+ requires an HTML tag-name terminator (whitespace, `/` or `>`) so a longer
1207
+ name such as `</styles` is not mistaken for `</style`. */
1208
+ const LITERAL_TEXT_CLOSE = function () {
1209
+ const map = {};
1210
+ arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, name => {
1211
+ map[name] = seal(new RegExp('</' + name + '(?=[\\t\\n\\f\\r />])', 'i'));
1212
+ });
1213
+ return freeze(map);
1214
+ }();
1215
+ const getGlobal = function getGlobal() {
1216
+ return typeof window === 'undefined' ? null : window;
1217
+ };
1218
+ /**
1219
+ * Creates a no-op policy for internal use only.
1220
+ * Don't export this function outside this module!
1221
+ * @param trustedTypes The policy factory.
1222
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
1223
+ * @return The policy created (or null, if Trusted Types
1224
+ * are not supported or creating the policy failed).
1225
+ */
1226
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
1227
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
1228
+ return null;
1229
+ }
1230
+ // Allow the callers to control the unique policy name
1231
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
1232
+ // Policy creation with duplicate names throws in Trusted Types.
1233
+ let suffix = null;
1234
+ const ATTR_NAME = 'data-tt-policy-suffix';
1235
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
1236
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
1237
+ }
1238
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
1239
+ try {
1240
+ return trustedTypes.createPolicy(policyName, {
1241
+ createHTML(html) {
1242
+ return html;
1243
+ },
1244
+ createScriptURL(scriptUrl) {
1245
+ return scriptUrl;
1246
+ }
1247
+ });
1248
+ } catch (_) {
1249
+ // Policy creation failed (most likely another DOMPurify script has
1250
+ // already run). Skip creating the policy, as this will only cause errors
1251
+ // if TT are enforced.
1252
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
1253
+ return null;
1254
+ }
1255
+ };
1256
+ const _createHooksMap = function _createHooksMap() {
1257
+ return {
1258
+ afterSanitizeAttributes: [],
1259
+ afterSanitizeElements: [],
1260
+ afterSanitizeShadowDOM: [],
1261
+ beforeSanitizeAttributes: [],
1262
+ beforeSanitizeElements: [],
1263
+ beforeSanitizeShadowDOM: [],
1264
+ uponSanitizeAttribute: [],
1265
+ uponSanitizeElement: [],
1266
+ uponSanitizeShadowNode: []
1267
+ };
1268
+ };
1269
+ /**
1270
+ * Resolve a set-valued configuration option: a fresh set built from
1271
+ * cfg[key] when it is an own array property (seeded with a clone of
1272
+ * options.base when given, case-normalized via options.transform),
1273
+ * the fallback set otherwise.
1274
+ *
1275
+ * @param cfg the cloned, prototype-free configuration object
1276
+ * @param key the configuration property to read
1277
+ * @param fallback the set to use when the option is absent or not an array
1278
+ * @param options transform and optional base set to merge into
1279
+ * @returns the resolved set
1280
+ */
1281
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
1282
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
1283
+ };
1284
+ /**
1285
+ * Resolve an object-valued configuration option: a prototype-free clone
1286
+ * of cfg[key] when it is an own, truthy object property, else a fresh
1287
+ * fallback built by makeFallback (fresh on every parse, so a previous
1288
+ * parse can never leak state into the next one).
1289
+ *
1290
+ * @param cfg the cloned, prototype-free configuration object
1291
+ * @param key the configuration property to read
1292
+ * @param makeFallback builds the fallback value when the option is absent
1293
+ * @returns the resolved object
1294
+ */
1295
+ const _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {
1296
+ const value = objectHasOwnProperty(cfg, key) ? cfg[key] : undefined;
1297
+ return value && typeof value === 'object' ? clone(value) : makeFallback();
1298
+ };
1299
+ function createDOMPurify() {
1300
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
1301
+ const DOMPurify = root => createDOMPurify(root);
1302
+ DOMPurify.version = '3.4.14';
1303
+ DOMPurify.removed = [];
1304
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1305
+ // Not running in a browser, provide a factory function
1306
+ // so that you can pass your own Window
1307
+ DOMPurify.isSupported = false;
1308
+ return DOMPurify;
1309
+ }
1310
+ let document = window.document;
1311
+ const originalDocument = document;
1312
+ const currentScript = originalDocument.currentScript;
1313
+ window.DocumentFragment;
1314
+ const HTMLTemplateElement = window.HTMLTemplateElement,
1315
+ Node = window.Node,
1316
+ Element = window.Element,
1317
+ NodeFilter = window.NodeFilter,
1318
+ _window$NamedNodeMap = window.NamedNodeMap;
1319
+ _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
1320
+ window.HTMLFormElement;
1321
+ const DOMParser = window.DOMParser,
1322
+ trustedTypes = window.trustedTypes;
1323
+ const ElementPrototype = Element.prototype;
1324
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
1325
+ const remove = lookupGetter(ElementPrototype, 'remove');
1326
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
1327
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
1328
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
1329
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
1330
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
1331
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
1332
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
1333
+ const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, 'ownerDocument') : null;
1334
+ /* Clobber-safe nodeType / nodeName reads through the cached Node.prototype
1335
+ getters, with a direct-property fallback for environments that lack
1336
+ Node.prototype. Sites that need a different fallback (e.g. _isClobbered
1337
+ returns early on a null name) intentionally keep their own reads. */
1338
+ const _readNodeType = function _readNodeType(node) {
1339
+ return getNodeType ? getNodeType(node) : node.nodeType;
1340
+ };
1341
+ const _readNodeName = function _readNodeName(node) {
1342
+ return getNodeName ? getNodeName(node) : node.nodeName;
1343
+ };
1344
+ // As per issue #47, the web-components registry is inherited by a
1345
+ // new document created via createHTMLDocument. As per the spec
1346
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
1347
+ // a new empty registry is used when creating a template contents owner
1348
+ // document, so we use that as our parent document to ensure nothing
1349
+ // is inherited.
1350
+ if (typeof HTMLTemplateElement === 'function') {
1351
+ const template = document.createElement('template');
1352
+ if (template.content && template.content.ownerDocument) {
1353
+ document = template.content.ownerDocument;
1354
+ }
1355
+ }
1356
+ let trustedTypesPolicy;
1357
+ let emptyHTML = '';
1358
+ // The instance's own internal Trusted Types policy. Unlike a caller-supplied
1359
+ // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
1360
+ // on duplicate policy names — and is the only policy allowed to persist
1361
+ // across configurations and survive `clearConfig()`.
1362
+ let defaultTrustedTypesPolicy;
1363
+ let defaultTrustedTypesPolicyResolved = false;
1364
+ // Tracks whether we are already inside a call to the configured Trusted Types
1365
+ // policy (`createHTML` or `createScriptURL`). If a supplied policy callback
1366
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
1367
+ // re-enter the policy and recurse until the stack overflows. We detect that
1368
+ // re-entry and throw a clear, actionable error instead. The guard is shared
1369
+ // across both callbacks, because either one re-entering `sanitize` triggers
1370
+ // the same unbounded recursion.
1371
+ let IN_TRUSTED_TYPES_POLICY = 0;
1372
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
1373
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
1374
+ throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted ' + 'Types" section of the README.');
1375
+ }
1376
+ };
1377
+ const _createTrustedHTML = function _createTrustedHTML(html) {
1378
+ _assertNotInTrustedTypesPolicy();
1379
+ IN_TRUSTED_TYPES_POLICY++;
1380
+ try {
1381
+ return trustedTypesPolicy.createHTML(html);
1382
+ } finally {
1383
+ IN_TRUSTED_TYPES_POLICY--;
1384
+ }
1385
+ };
1386
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
1387
+ _assertNotInTrustedTypesPolicy();
1388
+ IN_TRUSTED_TYPES_POLICY++;
1389
+ try {
1390
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
1391
+ } finally {
1392
+ IN_TRUSTED_TYPES_POLICY--;
1393
+ }
1394
+ };
1395
+ // Lazily resolve (and cache) the instance's internal default policy.
1396
+ // Resolution is attempted at most once: a successful `createPolicy` cannot be
1397
+ // repeated (Trusted Types throws on duplicate names), and a failed or
1398
+ // unsupported attempt must not be retried on every parse.
1399
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
1400
+ if (!defaultTrustedTypesPolicyResolved) {
1401
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1402
+ defaultTrustedTypesPolicyResolved = true;
1403
+ }
1404
+ return defaultTrustedTypesPolicy;
1405
+ };
1406
+ const _document = document,
1407
+ implementation = _document.implementation,
1408
+ createNodeIterator = _document.createNodeIterator,
1409
+ createDocumentFragment = _document.createDocumentFragment,
1410
+ getElementsByTagName = _document.getElementsByTagName;
1411
+ const importNode = originalDocument.importNode;
1412
+ let hooks = _createHooksMap();
1413
+ /**
1414
+ * Expose whether this browser supports running the full DOMPurify.
1415
+ */
1416
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
1417
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
1418
+ ERB_EXPR$1 = ERB_EXPR,
1419
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
1420
+ DATA_ATTR$1 = DATA_ATTR,
1421
+ ARIA_ATTR$1 = ARIA_ATTR,
1422
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
1423
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
1424
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
1425
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
1426
+ /**
1427
+ * We consider the elements and attributes below to be safe. Ideally
1428
+ * don't add any new ones but feel free to remove unwanted ones.
1429
+ */
1430
+ /* allowed element names */
1431
+ let ALLOWED_TAGS = null;
1432
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
1433
+ /* Allowed attribute names */
1434
+ let ALLOWED_ATTR = null;
1435
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
1436
+ /*
1437
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
1438
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
1439
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
1440
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
1441
+ */
1442
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
1443
+ tagNameCheck: {
1444
+ writable: true,
1445
+ configurable: false,
1446
+ enumerable: true,
1447
+ value: null
1448
+ },
1449
+ attributeNameCheck: {
1450
+ writable: true,
1451
+ configurable: false,
1452
+ enumerable: true,
1453
+ value: null
1454
+ },
1455
+ allowCustomizedBuiltInElements: {
1456
+ writable: true,
1457
+ configurable: false,
1458
+ enumerable: true,
1459
+ value: false
1460
+ }
1461
+ }));
1462
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
1463
+ let FORBID_TAGS = null;
1464
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
1465
+ let FORBID_ATTR = null;
1466
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
1467
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
1468
+ tagCheck: {
1469
+ writable: true,
1470
+ configurable: false,
1471
+ enumerable: true,
1472
+ value: null
1473
+ },
1474
+ attributeCheck: {
1475
+ writable: true,
1476
+ configurable: false,
1477
+ enumerable: true,
1478
+ value: null
1479
+ }
1480
+ }));
1481
+ /* Decide if ARIA attributes are okay */
1482
+ let ALLOW_ARIA_ATTR = true;
1483
+ /* Decide if custom data attributes are okay */
1484
+ let ALLOW_DATA_ATTR = true;
1485
+ /* Decide if unknown protocols are okay */
1486
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1487
+ /* Decide if self-closing tags in attributes are allowed.
1488
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
1489
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1490
+ /* Output should be safe for common template engines.
1491
+ * This means, DOMPurify removes data attributes, mustaches and ERB
1492
+ */
1493
+ let SAFE_FOR_TEMPLATES = false;
1494
+ /* Output should be safe even for XML used within HTML and alike.
1495
+ * This means, DOMPurify removes comments when containing risky content.
1496
+ */
1497
+ let SAFE_FOR_XML = true;
1498
+ /* Decide if document with <html>... should be returned */
1499
+ let WHOLE_DOCUMENT = false;
1500
+ /* Track whether config is already set on this instance of DOMPurify. */
1501
+ let SET_CONFIG = false;
1502
+ /* Pristine allowlist bindings captured at setConfig() time. On the
1503
+ * persistent-config path sanitize() restores the sets from these before
1504
+ * the per-walk hook clone-guard, so a hook's in-call widening cannot
1505
+ * carry across calls. Null until setConfig() is called; reset by
1506
+ * clearConfig(). */
1507
+ let SET_CONFIG_ALLOWED_TAGS = null;
1508
+ let SET_CONFIG_ALLOWED_ATTR = null;
1509
+ /* Decide if all elements (e.g. style, script) must be children of
1510
+ * document.body. By default, browsers might move them to document.head */
1511
+ let FORCE_BODY = false;
1512
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
1513
+ * string (or a TrustedHTML object if Trusted Types are supported).
1514
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
1515
+ */
1516
+ let RETURN_DOM = false;
1517
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
1518
+ * string (or a TrustedHTML object if Trusted Types are supported) */
1519
+ let RETURN_DOM_FRAGMENT = false;
1520
+ /* Try to return a Trusted Type object instead of a string, return a string in
1521
+ * case Trusted Types are not supported */
1522
+ let RETURN_TRUSTED_TYPE = false;
1523
+ /* Output should be free from DOM clobbering attacks?
1524
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
1525
+ */
1526
+ let SANITIZE_DOM = true;
1527
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
1528
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
1529
+ *
1530
+ * HTML/DOM spec rules that enable DOM Clobbering:
1531
+ * - Named Access on Window (§7.3.3)
1532
+ * - DOM Tree Accessors (§3.1.5)
1533
+ * - Form Element Parent-Child Relations (§4.10.3)
1534
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
1535
+ * - HTMLCollection (§4.2.10.2)
1536
+ *
1537
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
1538
+ * with a constant string, i.e., `user-content-`
1539
+ */
1540
+ let SANITIZE_NAMED_PROPS = false;
1541
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
1542
+ /* Keep element content when removing element? */
1543
+ let KEEP_CONTENT = true;
1544
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
1545
+ * of importing it into a new Document and returning a sanitized copy */
1546
+ let IN_PLACE = false;
1547
+ /* Allow usage of profiles like html, svg and mathMl */
1548
+ let USE_PROFILES = {};
1549
+ /* Tags to ignore content of when KEEP_CONTENT is true */
1550
+ let FORBID_CONTENTS = null;
1551
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
1552
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
1553
+ // the UA (customizable <select>) — including any on* handlers — and the
1554
+ // engine re-mirrors synchronously whenever a removal changes which
1555
+ // option/selectedcontent is current, even inside DOMPurify's inert
1556
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
1557
+ // mirror target ahead of the walk, which the engine refills, looping
1558
+ // forever (DoS) and amplifying output. Dropping its content on removal
1559
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
1560
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
1561
+ 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
1562
+ /* Tags that are safe for data: URIs */
1563
+ let DATA_URI_TAGS = null;
1564
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
1565
+ /* Attributes safe for values like "javascript:" */
1566
+ let URI_SAFE_ATTRIBUTES = null;
1567
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
1568
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1569
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1570
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1571
+ /* Document namespace */
1572
+ let NAMESPACE = HTML_NAMESPACE;
1573
+ let IS_EMPTY_INPUT = false;
1574
+ /* Allowed XHTML+XML namespaces */
1575
+ let ALLOWED_NAMESPACES = null;
1576
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1577
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
1578
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1579
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
1580
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1581
+ // Certain elements are allowed in both SVG and HTML
1582
+ // namespace. We need to specify them explicitly
1583
+ // so that they don't get erroneously deleted from
1584
+ // HTML namespace.
1585
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1586
+ /* Parsing of strict XHTML documents */
1587
+ let PARSER_MEDIA_TYPE = null;
1588
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1589
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1590
+ let transformCaseFunc = null;
1591
+ /* Keep a reference to config to pass to hooks */
1592
+ let CONFIG = null;
1593
+ /* Ideally, do not touch anything below this line */
1594
+ /* ______________________________________________ */
1595
+ const formElement = document.createElement('form');
1596
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1597
+ return testValue instanceof RegExp || testValue instanceof Function;
1598
+ };
1599
+ /**
1600
+ * _parseConfig
1601
+ *
1602
+ * @param cfg optional config literal
1603
+ */
1604
+ // eslint-disable-next-line complexity
1605
+ const _parseConfig = function _parseConfig() {
1606
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1607
+ if (CONFIG && CONFIG === cfg) {
1608
+ return;
1609
+ }
1610
+ /* Shield configuration object from tampering */
1611
+ if (!cfg || typeof cfg !== 'object') {
1612
+ cfg = {};
1613
+ }
1614
+ /* Shield configuration object from prototype pollution */
1615
+ cfg = clone(cfg);
1616
+ PARSER_MEDIA_TYPE =
1617
+ // eslint-disable-next-line unicorn/prefer-includes
1618
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1619
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1620
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1621
+ /* Set configuration parameters */
1622
+ ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
1623
+ transform: transformCaseFunc
1624
+ });
1625
+ ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
1626
+ transform: transformCaseFunc
1627
+ });
1628
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
1629
+ transform: stringToString
1630
+ });
1631
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
1632
+ transform: transformCaseFunc,
1633
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1634
+ });
1635
+ DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
1636
+ transform: transformCaseFunc,
1637
+ base: DEFAULT_DATA_URI_TAGS
1638
+ });
1639
+ FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
1640
+ transform: transformCaseFunc
1641
+ });
1642
+ FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
1643
+ transform: transformCaseFunc
1644
+ });
1645
+ FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
1646
+ transform: transformCaseFunc
1647
+ });
1648
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1649
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1650
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1651
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1652
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1653
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1654
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
1655
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1656
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1657
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1658
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1659
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1660
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1661
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1662
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1663
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
1664
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
1665
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
1666
+ MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, 'MATHML_TEXT_INTEGRATION_POINTS', () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS) // Default built-in map
1667
+ );
1668
+ HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, 'HTML_INTEGRATION_POINTS', () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS) // Default built-in map
1669
+ );
1670
+ const customElementHandling = _resolveObjectOption(cfg, 'CUSTOM_ELEMENT_HANDLING', () => create(null));
1671
+ CUSTOM_ELEMENT_HANDLING = create(null);
1672
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
1673
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
1674
+ }
1675
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
1676
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
1677
+ }
1678
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
1679
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
1680
+ }
1681
+ seal(CUSTOM_ELEMENT_HANDLING);
1682
+ if (SAFE_FOR_TEMPLATES) {
1683
+ ALLOW_DATA_ATTR = false;
1684
+ }
1685
+ if (RETURN_DOM_FRAGMENT) {
1686
+ RETURN_DOM = true;
1687
+ }
1688
+ /* Parse profile info */
1689
+ if (USE_PROFILES) {
1690
+ ALLOWED_TAGS = addToSet({}, text);
1691
+ ALLOWED_ATTR = create(null);
1692
+ if (USE_PROFILES.html === true) {
1693
+ addToSet(ALLOWED_TAGS, html$1);
1694
+ addToSet(ALLOWED_ATTR, html);
1695
+ }
1696
+ if (USE_PROFILES.svg === true) {
1697
+ addToSet(ALLOWED_TAGS, svg$1);
1698
+ addToSet(ALLOWED_ATTR, svg);
1699
+ addToSet(ALLOWED_ATTR, xml);
1700
+ }
1701
+ if (USE_PROFILES.svgFilters === true) {
1702
+ addToSet(ALLOWED_TAGS, svgFilters);
1703
+ addToSet(ALLOWED_ATTR, svg);
1704
+ addToSet(ALLOWED_ATTR, xml);
1705
+ }
1706
+ if (USE_PROFILES.mathMl === true) {
1707
+ addToSet(ALLOWED_TAGS, mathMl$1);
1708
+ addToSet(ALLOWED_ATTR, mathMl);
1709
+ addToSet(ALLOWED_ATTR, xml);
1710
+ }
1711
+ }
1712
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
1713
+ * leaking across calls when switching from function to array config */
1714
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
1715
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
1716
+ /* Merge configuration parameters */
1717
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
1718
+ if (typeof cfg.ADD_TAGS === 'function') {
1719
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
1720
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
1721
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1722
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
1723
+ }
1724
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1725
+ }
1726
+ }
1727
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
1728
+ if (typeof cfg.ADD_ATTR === 'function') {
1729
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
1730
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
1731
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1732
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
1733
+ }
1734
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1735
+ }
1736
+ }
1737
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
1738
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1739
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1740
+ }
1741
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
1742
+ }
1743
+ /* Add #text in case KEEP_CONTENT is set to true */
1744
+ if (KEEP_CONTENT) {
1745
+ ALLOWED_TAGS['#text'] = true;
1746
+ }
1747
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1748
+ if (WHOLE_DOCUMENT) {
1749
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1750
+ }
1751
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1752
+ if (ALLOWED_TAGS.table) {
1753
+ addToSet(ALLOWED_TAGS, ['tbody']);
1754
+ delete FORBID_TAGS.tbody;
1755
+ }
1756
+ // Re-derive the active Trusted Types policy from this configuration on
1757
+ // every parse. The active policy must never be sticky closure state that
1758
+ // outlives the config that set it: a caller-supplied policy left in place
1759
+ // after `clearConfig()` — or after a later call that supplied none, or
1760
+ // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
1761
+ // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
1762
+ // See GHSA-vxr8-fq34-vvx9.
1763
+ if (cfg.TRUSTED_TYPES_POLICY) {
1764
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1765
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1766
+ }
1767
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1768
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1769
+ }
1770
+ // A caller-supplied policy applies to this configuration only.
1771
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1772
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1773
+ // Sign local variables required by `sanitize`. If the supplied policy's
1774
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
1775
+ // throws via the re-entrancy guard. Restore the previous policy first so
1776
+ // the instance is not left in a poisoned state. See #1422.
1777
+ try {
1778
+ emptyHTML = _createTrustedHTML('');
1779
+ } catch (error) {
1780
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1781
+ throw error;
1782
+ }
1783
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1784
+ // Explicit opt-out for this call: perform no Trusted Types signing and
1785
+ // create nothing (so a strict `trusted-types` CSP that disallows a
1786
+ // `dompurify` policy can still call `sanitize` from inside its own
1787
+ // policy — see #1422). Resetting to `undefined` rather than a sticky
1788
+ // `null` also drops any previously retained caller policy, so it cannot
1789
+ // resurface on a later call, while still allowing the next config-less
1790
+ // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
1791
+ trustedTypesPolicy = undefined;
1792
+ emptyHTML = '';
1793
+ } else {
1794
+ // No policy supplied: keep the currently active policy if one is set — a
1795
+ // previously supplied policy is intentionally sticky across config-less
1796
+ // calls — otherwise fall back to the instance's own internal policy,
1797
+ // created at most once. (A policy supplied for a *single* call still
1798
+ // lingers by design; what must not linger is a policy whose configuration
1799
+ // has been torn down via `clearConfig()`, which restores the default.)
1800
+ if (trustedTypesPolicy === undefined) {
1801
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1802
+ }
1803
+ // Sign internal variables only when a policy is active. A falsy policy
1804
+ // (Trusted Types unsupported, creation failed, or an explicit opt-out)
1805
+ // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
1806
+ // a non-policy and throw. See #1422.
1807
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
1808
+ emptyHTML = _createTrustedHTML('');
1809
+ }
1810
+ }
1811
+ // Prevent further manipulation of configuration.
1812
+ // Not available in IE8, Safari 5, etc.
1813
+ if (freeze) {
1814
+ freeze(cfg);
1815
+ }
1816
+ CONFIG = cfg;
1817
+ };
1818
+ /* Keep track of all possible SVG and MathML tags
1819
+ * so that we can perform the namespace checks
1820
+ * correctly. */
1821
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1822
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1823
+ /**
1824
+ * Namespace rules for an element in the SVG namespace.
1825
+ *
1826
+ * @param tagName the element's lowercase tag name
1827
+ * @param parent the (possibly simulated) parent node
1828
+ * @param parentTagName the parent's lowercase tag name
1829
+ * @returns true if a spec-compliant parser could produce this element
1830
+ */
1831
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
1832
+ // The only way to switch from HTML namespace to SVG
1833
+ // is via <svg>. If it happens via any other tag, then
1834
+ // it should be killed.
1835
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1836
+ return tagName === 'svg';
1837
+ }
1838
+ // The only way to switch from MathML to SVG is via <svg>
1839
+ // if the parent is either <annotation-xml> or a MathML
1840
+ // text integration point.
1841
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1842
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1843
+ }
1844
+ // We only allow elements that are defined in SVG
1845
+ // spec. All others are disallowed in SVG namespace.
1846
+ return Boolean(ALL_SVG_TAGS[tagName]);
1847
+ };
1848
+ /**
1849
+ * Namespace rules for an element in the MathML namespace.
1850
+ *
1851
+ * @param tagName the element's lowercase tag name
1852
+ * @param parent the (possibly simulated) parent node
1853
+ * @param parentTagName the parent's lowercase tag name
1854
+ * @returns true if a spec-compliant parser could produce this element
1855
+ */
1856
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
1857
+ // The only way to switch from HTML namespace to MathML
1858
+ // is via <math>. If it happens via any other tag, then
1859
+ // it should be killed.
1860
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1861
+ return tagName === 'math';
1862
+ }
1863
+ // The only way to switch from SVG to MathML is via
1864
+ // <math> and HTML integration points
1865
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1866
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1867
+ }
1868
+ // We only allow elements that are defined in MathML
1869
+ // spec. All others are disallowed in MathML namespace.
1870
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1871
+ };
1872
+ /**
1873
+ * Namespace rules for an element in the HTML namespace.
1874
+ *
1875
+ * @param tagName the element's lowercase tag name
1876
+ * @param parent the (possibly simulated) parent node
1877
+ * @param parentTagName the parent's lowercase tag name
1878
+ * @returns true if a spec-compliant parser could produce this element
1879
+ */
1880
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1881
+ // The only way to switch from SVG to HTML is via
1882
+ // HTML integration points, and from MathML to HTML
1883
+ // is via MathML text integration points
1884
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1885
+ return false;
1886
+ }
1887
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1888
+ return false;
1889
+ }
1890
+ // We disallow tags that are specific for MathML
1891
+ // or SVG and should never appear in HTML namespace
1892
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1893
+ };
1894
+ /**
1895
+ * @param element a DOM element whose namespace is being checked
1896
+ * @returns Return false if the element has a
1897
+ * namespace that a spec-compliant parser would never
1898
+ * return. Return true otherwise.
1899
+ */
1900
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1901
+ let parent = getParentNode(element);
1902
+ // In JSDOM, if we're inside shadow DOM, then parentNode
1903
+ // can be null. We just simulate parent in this case.
1904
+ if (!parent || !parent.tagName) {
1905
+ parent = {
1906
+ namespaceURI: NAMESPACE,
1907
+ tagName: 'template'
1908
+ };
1909
+ }
1910
+ const tagName = stringToLowerCase(element.tagName);
1911
+ const parentTagName = stringToLowerCase(parent.tagName);
1912
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1913
+ return false;
1914
+ }
1915
+ if (element.namespaceURI === SVG_NAMESPACE) {
1916
+ return _checkSvgNamespace(tagName, parent, parentTagName);
1917
+ }
1918
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1919
+ return _checkMathMlNamespace(tagName, parent, parentTagName);
1920
+ }
1921
+ if (element.namespaceURI === HTML_NAMESPACE) {
1922
+ return _checkHtmlNamespace(tagName, parent, parentTagName);
1923
+ }
1924
+ // For XHTML and XML documents that support custom namespaces
1925
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1926
+ return true;
1927
+ }
1928
+ // The code should never reach this place (this means
1929
+ // that the element somehow got namespace that is not
1930
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1931
+ // Return false just in case.
1932
+ return false;
1933
+ };
1934
+ /**
1935
+ * _forceRemove
1936
+ *
1937
+ * @param node a DOM node
1938
+ */
1939
+ const _forceRemove = function _forceRemove(node) {
1940
+ arrayPush(DOMPurify.removed, {
1941
+ element: node
1942
+ });
1943
+ try {
1944
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
1945
+ getParentNode(node).removeChild(node);
1946
+ } catch (_) {
1947
+ /* The normal detach failed — this is reached for a parentless node
1948
+ (getParentNode() is null, so .removeChild throws). Element.prototype
1949
+ .remove() is itself a spec no-op on a parentless node, so a recorded
1950
+ "removal" would otherwise hand the caller back an intact,
1951
+ payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
1952
+ the style-with-element-child rule decided to kill). Fail closed by
1953
+ throwing — exactly as a clobbered root does at the IN_PLACE entry —
1954
+ rather than trying to "neutralize" the node via its own methods.
1955
+ Neutralizing would mean calling getAttributeNames()/removeAttribute()
1956
+ on the node, both of which a <form> root can clobber via a named child
1957
+ (and _isClobbered does not even probe getAttributeNames), so the
1958
+ neutralize step could itself be silently defeated, leaving the payload
1959
+ intact. A throw touches only the cached, clobber-safe remove() and
1960
+ getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
1961
+ to every root-kill reason. REPORT-3.
1962
+ This lives inside the catch, so it never fires for a normally-removed
1963
+ in-tree node: those have a parent, removeChild() succeeds, and the
1964
+ catch is not entered. Only a kept (parentless) root reaches here. */
1965
+ remove(node);
1966
+ if (!getParentNode(node)) {
1967
+ throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
1968
+ }
1969
+ }
1970
+ };
1971
+ /**
1972
+ * _stripAttributeNode
1973
+ *
1974
+ * Remove a single Attr node case/namespace-exactly on an attribute-teardown
1975
+ * path. Name-based removeAttribute() ASCII-lowercases its lookup key for an
1976
+ * HTML element in an HTML document and so silently misses a case-preserved
1977
+ * handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect
1978
+ * _removeAttribute() was fixed for, which a name-based call would reintroduce
1979
+ * on these IN_PLACE teardown paths. Unlike _removeAttribute this does not
1980
+ * record into DOMPurify.removed: the neutralize passes intentionally do not
1981
+ * book-keep. A clobbered/detached node falls back to best-effort name-based
1982
+ * removal.
1983
+ *
1984
+ * @param element the element to strip the attribute from
1985
+ * @param attribute the Attr node to remove
1986
+ * @param name the attribute's name, for the fallback path
1987
+ */
1988
+ const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
1989
+ try {
1990
+ element.removeAttributeNode(attribute);
1991
+ } catch (_) {
1992
+ try {
1993
+ element.removeAttribute(name);
1994
+ } catch (_) {}
1995
+ }
1996
+ };
1997
+ /**
1998
+ * _neutralizeRoot
1999
+ *
2000
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
2001
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
2002
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
2003
+ * parentless guard throws, or any other re-entrant engine mutation — would
2004
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
2005
+ * after the abort point still carrying its handlers. There is no safe way
2006
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
2007
+ * remove every child and every attribute, then let the caller's catch see
2008
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
2009
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
2010
+ *
2011
+ * @param root the in-place root to empty
2012
+ */
2013
+ const _neutralizeRoot = function _neutralizeRoot(root) {
2014
+ /* Strip every disallowed attribute (on* handlers included) off the whole
2015
+ subtree BEFORE detaching anything. Detaching first would hand back
2016
+ handler-bearing originals (e.g. an already-loading `<img onerror>`)
2017
+ whose queued resource event still fires in page scope after we throw.
2018
+ Clobber-safe reads; a doomed clobbered node's own attributes are
2019
+ irrelevant while its non-clobbered descendants are reached and scrubbed. */
2020
+ _neutralizeSubtree(root);
2021
+ const childNodes = getChildNodes(root);
2022
+ if (childNodes) {
2023
+ const snapshot = [];
2024
+ arrayForEach(childNodes, child => {
2025
+ arrayPush(snapshot, child);
2026
+ });
2027
+ arrayForEach(snapshot, child => {
2028
+ try {
2029
+ remove(child);
2030
+ } catch (_) {
2031
+ /* Best-effort teardown; a still-attached child is handled below */
2032
+ }
2033
+ });
2034
+ }
2035
+ const attributes = getAttributes(root);
2036
+ if (attributes) {
2037
+ for (let i = attributes.length - 1; i >= 0; --i) {
2038
+ const attribute = attributes[i];
2039
+ const name = attribute && attribute.name;
2040
+ if (typeof name === 'string') {
2041
+ _stripAttributeNode(root, attribute, name);
2042
+ }
2043
+ }
2044
+ }
2045
+ };
2046
+ /**
2047
+ * _removeAttribute
2048
+ *
2049
+ * Name-based getAttributeNode()/removeAttribute() ASCII-lowercase their
2050
+ * lookup key for HTML elements in an HTML document, so they silently miss an
2051
+ * attribute whose stored qualified name still contains uppercase ASCII
2052
+ * letters. That happens when the node came from a case-preserving source
2053
+ * (an XML/XHTML document imported via importNode(), or createAttributeNS()),
2054
+ * where e.g. `ONERROR` survives the walk: the policy check lowercases to
2055
+ * `onerror` and rejects it, but `removeAttribute('ONERROR')` looks up
2056
+ * `onerror` and finds nothing. Remove the exact Attr node instead, which is
2057
+ * case- and namespace-exact, and fall back to name-based removal only when
2058
+ * the caller could not supply the node.
2059
+ *
2060
+ * @param name an Attribute name
2061
+ * @param element a DOM node
2062
+ * @param attr the exact Attr node to remove, when the caller has it
2063
+ */
2064
+ const _removeAttribute = function _removeAttribute(name, element, attr) {
2065
+ if (!attr) {
2066
+ try {
2067
+ attr = element.getAttributeNode(name);
2068
+ } catch (_) {
2069
+ attr = null;
2070
+ }
2071
+ }
2072
+ arrayPush(DOMPurify.removed, {
2073
+ attribute: attr || null,
2074
+ from: element
2075
+ });
2076
+ try {
2077
+ if (attr) {
2078
+ element.removeAttributeNode(attr);
2079
+ } else {
2080
+ element.removeAttribute(name);
2081
+ }
2082
+ } catch (_) {
2083
+ /* Clobbered or already-detached node - best-effort fall back to a
2084
+ name-based removal so the "is" handling below still runs. */
2085
+ try {
2086
+ element.removeAttribute(name);
2087
+ } catch (_) {}
2088
+ }
2089
+ // We void attribute values for unremovable "is" attributes
2090
+ if (name === 'is') {
2091
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
2092
+ try {
2093
+ _forceRemove(element);
2094
+ } catch (_) {}
2095
+ } else {
2096
+ try {
2097
+ element.setAttribute(name, '');
2098
+ } catch (_) {}
2099
+ }
2100
+ }
2101
+ };
2102
+ /**
2103
+ * _stripDisallowedAttributes
2104
+ *
2105
+ * Removes every attribute the active configuration does not allow from a
2106
+ * single element, using the same allowlist as the main attribute pass (so
2107
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
2108
+ * neutralise nodes that are being discarded from an in-place tree.
2109
+ *
2110
+ * @param element the element to strip
2111
+ */
2112
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
2113
+ const attributes = getAttributes(element);
2114
+ if (!attributes) {
2115
+ return;
2116
+ }
2117
+ for (let i = attributes.length - 1; i >= 0; --i) {
2118
+ const attribute = attributes[i];
2119
+ const name = attribute && attribute.name;
2120
+ if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
2121
+ continue;
2122
+ }
2123
+ _stripAttributeNode(element, attribute, name);
2124
+ }
2125
+ };
2126
+ /**
2127
+ * _neutralizeSubtree
2128
+ *
2129
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
2130
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
2131
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
2132
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
2133
+ * those dropped nodes are detached from the caller's LIVE tree but a
2134
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
2135
+ * loading) keeps its queued resource event, which fires in page scope after
2136
+ * sanitize returns. This walks a removed subtree and strips every attribute
2137
+ * the active configuration does not allow — so `on*` handlers are cancelled
2138
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
2139
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
2140
+ * queued event can fire. Hook-free by design: these nodes leave the output,
2141
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
2142
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
2143
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
2144
+ * the `<img>`, are reached and scrubbed).
2145
+ *
2146
+ * @param root the root of a removed subtree to neutralise
2147
+ */
2148
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
2149
+ const stack = [root];
2150
+ while (stack.length > 0) {
2151
+ const node = stack.pop();
2152
+ const nodeType = _readNodeType(node);
2153
+ if (nodeType === NODE_TYPE.element) {
2154
+ _stripDisallowedAttributes(node);
2155
+ }
2156
+ const childNodes = getChildNodes(node);
2157
+ if (childNodes) {
2158
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2159
+ stack.push(childNodes[i]);
2160
+ }
2161
+ }
2162
+ }
2163
+ };
2164
+ /**
2165
+ * _neutralizePatchLinkage
2166
+ *
2167
+ * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
2168
+ * hardening, https://github.com/WICG/declarative-partial-updates).
2169
+ *
2170
+ * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
2171
+ * markers (PIs / markup comments) node-by-node, in document order, AS it
2172
+ * reaches each node. On a live in-place root that leaves a window: from the
2173
+ * moment the root is connected until the walk arrives at a given node, that
2174
+ * node's linkage is live. A patch applied on connection/stream can fire as
2175
+ * a microtask during the walk and inject or teleport an unsanitized DOM
2176
+ * range into a region the iterator has already passed and will not revisit,
2177
+ * so the post-return "tree is sanitized" contract is violated. Sweep the
2178
+ * whole tree once up front and sever every linkage before the walk begins,
2179
+ * closing that window.
2180
+ *
2181
+ * This CANNOT undo a patch that already fired before sanitize ran — that is
2182
+ * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
2183
+ * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
2184
+ * to group with the rest of the declarative-partial-updates handling and
2185
+ * stay overridable, consistent with the codebase.
2186
+ *
2187
+ * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
2188
+ * clobbered root cannot defeat the sweep of its non-clobbered descendants.
2189
+ *
2190
+ * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
2191
+ * .html Q1): this mirrors the existing policy of keeping `for` on
2192
+ * <label>/<output>. If the shipping feature can drive a patch through a
2193
+ * surviving `for`-on-label/output + `id` pair, this pre-pass and the
2194
+ * attribute check at _isBasicCustomElement's caller must additionally drop
2195
+ * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
2196
+ *
2197
+ * @param root the in-place root to sweep
2198
+ */
2199
+ /**
2200
+ * Central policy for declarative-partial-updates patch-linkage attributes,
2201
+ * shared by the _neutralizePatchLinkage pre-pass and _isValidAttribute so
2202
+ * the two sites cannot drift: `patchsrc` always links, `for` links
2203
+ * everywhere except on <label>/<output>, and the whole policy is gated on
2204
+ * SAFE_FOR_XML (see the rationale block in _isValidAttribute).
2205
+ *
2206
+ * @param lcName the transformCaseFunc'd attribute name
2207
+ * @param lcTag the transformCaseFunc'd tag name of the carrying element
2208
+ * @return true if the attribute is patch linkage and must be dropped
2209
+ */
2210
+ const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
2211
+ if (!SAFE_FOR_XML) {
2212
+ return false;
2213
+ }
2214
+ if (lcName === 'patchsrc') {
2215
+ return true;
2216
+ }
2217
+ return lcName === 'for' && lcTag !== 'label' && lcTag !== 'output';
2218
+ };
2219
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
2220
+ if (!SAFE_FOR_XML) {
2221
+ return;
2222
+ }
2223
+ const stack = [root];
2224
+ while (stack.length > 0) {
2225
+ const node = stack.pop();
2226
+ const nodeType = _readNodeType(node);
2227
+ /* Remove range markers (the target side of a patch linkage): every
2228
+ processing instruction, and any markup-bearing comment. */
2229
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
2230
+ try {
2231
+ remove(node);
2232
+ } catch (_) {
2233
+ /* Best-effort */
2234
+ }
2235
+ continue;
2236
+ }
2237
+ /* Strip patch-source attributes (the source side) off elements. */
2238
+ if (nodeType === NODE_TYPE.element) {
2239
+ const element = node;
2240
+ const lcTag = transformCaseFunc(_readNodeName(node));
2241
+ try {
2242
+ if (element.hasAttribute && element.hasAttribute('patchsrc')) {
2243
+ element.removeAttribute('patchsrc');
2244
+ }
2245
+ if (element.hasAttribute && element.hasAttribute('for') && _isPatchLinkageAttribute('for', lcTag)) {
2246
+ element.removeAttribute('for');
2247
+ }
2248
+ } catch (_) {
2249
+ /* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */
2250
+ }
2251
+ }
2252
+ const childNodes = getChildNodes(node);
2253
+ if (childNodes) {
2254
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2255
+ stack.push(childNodes[i]);
2256
+ }
2257
+ }
2258
+ }
2259
+ };
2260
+ /**
2261
+ * _initDocument
2262
+ *
2263
+ * @param dirty - a string of dirty markup
2264
+ * @return a DOM, filled with the dirty markup
2265
+ */
2266
+ const _initDocument = function _initDocument(dirty) {
2267
+ /* Create a HTML document */
2268
+ let doc = null;
2269
+ let leadingWhitespace = null;
2270
+ if (FORCE_BODY) {
2271
+ dirty = '<remove></remove>' + dirty;
2272
+ } else {
2273
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
2274
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
2275
+ leadingWhitespace = matches && matches[0];
2276
+ }
2277
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
2278
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
2279
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
2280
+ }
2281
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
2282
+ /*
2283
+ * Use the DOMParser API by default, fallback later if needs be
2284
+ * DOMParser not work for svg when has multiple root element.
2285
+ */
2286
+ if (NAMESPACE === HTML_NAMESPACE) {
2287
+ try {
2288
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
2289
+ } catch (_) {}
2290
+ }
2291
+ /* Use createHTMLDocument in case DOMParser is not available */
2292
+ if (!doc || !doc.documentElement) {
2293
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
2294
+ try {
2295
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
2296
+ } catch (_) {
2297
+ // Syntax error if dirtyPayload is invalid xml
2298
+ }
2299
+ }
2300
+ const body = doc.body || doc.documentElement;
2301
+ if (dirty && leadingWhitespace) {
2302
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
2303
+ }
2304
+ /* Work on whole document or just its body */
2305
+ if (NAMESPACE === HTML_NAMESPACE) {
2306
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
2307
+ }
2308
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
2309
+ };
2310
+ /**
2311
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
2312
+ *
2313
+ * @param root The root element or node to start traversing on.
2314
+ * @return The created NodeIterator
2315
+ */
2316
+ const _createNodeIterator = function _createNodeIterator(root) {
2317
+ /* Read ownerDocument through the cached Node.prototype getter, never the
2318
+ direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a
2319
+ clobbering child (<input name="ownerDocument"> or a form-associated
2320
+ external input) shadows the prototype getter and makes a direct read
2321
+ return that <input>. createNodeIterator.call(<input>, ...) then throws
2322
+ "Illegal invocation", and on the IN_PLACE path that throw lands before
2323
+ the walk's fail-closed barrier - leaving the caller's live tree, with
2324
+ any already-armed handler in it, un-neutralized. The cached getter
2325
+ returns the real Document regardless of the clobber. */
2326
+ const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
2327
+ return createNodeIterator.call(doc || root, root,
2328
+ // eslint-disable-next-line no-bitwise
2329
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
2330
+ };
2331
+ /**
2332
+ * Replace template expression syntax (mustache, ERB, template
2333
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
2334
+ * sites. Order matters: mustache, then ERB, then template literal.
2335
+ *
2336
+ * @param value the string to scrub
2337
+ * @returns the scrubbed string
2338
+ */
2339
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
2340
+ value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
2341
+ value = stringReplace(value, ERB_EXPR$1, ' ');
2342
+ value = stringReplace(value, TMPLIT_EXPR$1, ' ');
2343
+ return value;
2344
+ };
2345
+ /**
2346
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
2347
+ * character data of an element subtree. Used as the final safety net for
2348
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
2349
+ * which only form after text-node normalization (e.g. fragments split across
2350
+ * stripped elements) cannot survive into a template-evaluating framework.
2351
+ *
2352
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
2353
+ * in place rather than round-tripping through innerHTML. This preserves
2354
+ * descendant node references (important for IN_PLACE callers), avoids a
2355
+ * serialize/reparse cycle, and reads literal character data — which means
2356
+ * `<%...%>` in text content matches the ERB regex against its real bytes
2357
+ * instead of the HTML-entity-escaped form innerHTML would produce.
2358
+ *
2359
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
2360
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
2361
+ *
2362
+ * @param node The root element whose character data should be scrubbed.
2363
+ */
2364
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
2365
+ var _node$querySelectorAl;
2366
+ node.normalize();
2367
+ /* Clobber-safe ownerDocument read, same reasoning as _createNodeIterator:
2368
+ under SAFE_FOR_TEMPLATES this runs on the live IN_PLACE root, which may
2369
+ carry a form-named-getter override of ownerDocument. */
2370
+ const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
2371
+ const walker = createNodeIterator.call(doc || node, node,
2372
+ // eslint-disable-next-line no-bitwise
2373
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
2374
+ let currentNode = walker.nextNode();
2375
+ while (currentNode) {
2376
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
2377
+ currentNode = walker.nextNode();
2378
+ }
2379
+ // NodeIterator does not descend into <template>.content per the DOM spec,
2380
+ // so we must explicitly recurse into each template's content fragment,
2381
+ // mirroring the approach used by _sanitizeShadowDOM.
2382
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
2383
+ if (templates) {
2384
+ arrayForEach(templates, tmpl => {
2385
+ if (_isDocumentFragment(tmpl.content)) {
2386
+ _scrubTemplateExpressions2(tmpl.content);
2387
+ }
2388
+ });
2389
+ }
2390
+ };
2391
+ /**
2392
+ * _isClobbered
2393
+ *
2394
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
2395
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
2396
+ * `name` attribute matching a prototype property shadows that property
2397
+ * on direct reads. We use this check at the IN_PLACE entry-point and
2398
+ * during attribute sanitization to refuse clobbered forms.
2399
+ *
2400
+ * @param element element to check for clobbering attacks
2401
+ * @return true if clobbered, false if safe
2402
+ */
2403
+ const _isClobbered = function _isClobbered(element) {
2404
+ // Realm-independent tag-name probe. If we can't determine the tag
2405
+ // name at all, we can't reason about clobbering — return false
2406
+ // (the caller's other defences still apply).
2407
+ const realTagName = getNodeName ? getNodeName(element) : null;
2408
+ if (typeof realTagName !== 'string') {
2409
+ return false;
2410
+ }
2411
+ if (transformCaseFunc(realTagName) !== 'form') {
2412
+ return false;
2413
+ }
2414
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
2415
+ // Realm-safe NamedNodeMap detection: equality against the cached
2416
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
2417
+ // makes the direct read diverge from the cached read; a clean form
2418
+ // (same-realm OR foreign-realm) has both reads pointing at the same
2419
+ // canonical NamedNodeMap.
2420
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
2421
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
2422
+ // returns the integer 1 for any Element regardless of realm; direct
2423
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
2424
+ // the named child element. Cheap addition — nodeType is read from
2425
+ // an internal slot, no serialization cost — and removes a residual
2426
+ // clobbering surface used by several mXSS / PI / comment branches
2427
+ // in _sanitizeElements that compare currentNode.nodeType directly.
2428
+ element.nodeType !== getNodeType(element) ||
2429
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
2430
+ // "childNodes" shadows the prototype getter. Direct reads of
2431
+ // form.childNodes from a clobbered form return the named child
2432
+ // instead of the real NodeList, so any walk that reads it directly
2433
+ // skips the form's real children. Compare the direct read to the
2434
+ // cached Node.prototype getter — when the form's named-property
2435
+ // getter intercepts the read, the two values differ and we flag
2436
+ // the form. This catches every clobbering child type (input,
2437
+ // select, etc.) regardless of whether the named child happens to
2438
+ // carry a numeric .length, which a typeof-based probe would miss
2439
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
2440
+ element.childNodes !== getChildNodes(element);
2441
+ };
2442
+ /**
2443
+ * Checks whether the given value is a DocumentFragment from any realm.
2444
+ *
2445
+ * The realm-independent replacement reads `nodeType` through the cached
2446
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
2447
+ * constant (11). nodeType is a numeric value resolved from the node's
2448
+ * internal slot, identical across realms for the same kind of node.
2449
+ *
2450
+ * @param value object to check
2451
+ * @return true if value is a DocumentFragment-shaped node from any realm
2452
+ */
2453
+ const _isDocumentFragment = function _isDocumentFragment(value) {
2454
+ if (!getNodeType || typeof value !== 'object' || value === null) {
2455
+ return false;
2456
+ }
2457
+ try {
2458
+ return getNodeType(value) === NODE_TYPE.documentFragment;
2459
+ } catch (_) {
2460
+ return false;
2461
+ }
2462
+ };
2463
+ /**
2464
+ * Checks whether the given object is a DOM node, including nodes that
2465
+ * originate from a different window/realm (e.g. an iframe's
2466
+ * contentDocument). The previous `value instanceof Node` check was
2467
+ * realm-bound: nodes from a different window failed it, causing
2468
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
2469
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
2470
+ *
2471
+ * @param value object to check whether it's a DOM node
2472
+ * @return true if value is a DOM node from any realm
2473
+ */
2474
+ const _isNode = function _isNode(value) {
2475
+ if (!getNodeType || typeof value !== 'object' || value === null) {
2476
+ return false;
2477
+ }
2478
+ try {
2479
+ return typeof getNodeType(value) === 'number';
2480
+ } catch (_) {
2481
+ return false;
2482
+ }
2483
+ };
2484
+ function _executeHooks(hooks, currentNode, data) {
2485
+ if (hooks.length === 0) {
2486
+ return;
2487
+ }
2488
+ arrayForEach(hooks, hook => {
2489
+ hook.call(DOMPurify, currentNode, data, CONFIG);
2490
+ });
2491
+ }
2492
+ /**
2493
+ * Structural-threat checks that condemn a node regardless of the
2494
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
2495
+ * processing instructions, markup-bearing comments. Pure predicate;
2496
+ * the caller removes. Check order is load-bearing.
2497
+ *
2498
+ * @param currentNode the node to inspect
2499
+ * @param tagName the node's transformCaseFunc'd tag name
2500
+ * @return true if the node must be removed
2501
+ */
2502
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
2503
+ /* Detect mXSS attempts abusing namespace confusion */
2504
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
2505
+ return true;
2506
+ }
2507
+ /* Remove rawtext/literal-text elements whose literal serialization
2508
+ re-opens markup on an HTML reparse - shapes (a) and (b) documented at
2509
+ LITERAL_TEXT_ELEMENTS. Both are invisible to rule 1 above (which
2510
+ self-disables once there is an element child, and whose second probe
2511
+ reads the innerHTML an XML/XHTML document serializes escaped), which
2512
+ is why both probes here read textContent instead. Previously only
2513
+ `style`-with-element-child was covered; every element in
2514
+ LITERAL_TEXT_ELEMENTS shares this literal serialization and is
2515
+ equally affected. */
2516
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === 'string' && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) {
2517
+ return true;
2518
+ }
2519
+ /* Remove any occurrence of processing instructions */
2520
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
2521
+ return true;
2522
+ }
2523
+ /* Remove any kind of possibly harmful comments */
2524
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
2525
+ return true;
2526
+ }
2527
+ return false;
2528
+ };
2529
+ /**
2530
+ * Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate
2531
+ * function, per the validation in _parseConfig) against a name.
2532
+ * Additional arguments are forwarded to predicate functions - the
2533
+ * attributeNameCheck predicate receives the tag name as its second
2534
+ * argument. A null/absent check never matches.
2535
+ *
2536
+ * @param check the configured tagNameCheck / attributeNameCheck value
2537
+ * @param name the name to test
2538
+ * @param args extra arguments forwarded to a predicate function
2539
+ * @return true if the check matches the name
2540
+ */
2541
+ const _matchesNameCheck = function _matchesNameCheck(check, name) {
2542
+ if (check instanceof RegExp) {
2543
+ return regExpTest(check, name);
2544
+ }
2545
+ if (check instanceof Function) {
2546
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2547
+ args[_key - 2] = arguments[_key];
2548
+ }
2549
+ return Boolean(check(name, ...args));
2550
+ }
2551
+ return false;
2552
+ };
2553
+ /**
2554
+ * Handle a node whose tag is forbidden or not allowlisted: keep
2555
+ * allowed custom elements (false return exits _sanitizeElements
2556
+ * early - the namespace and fallback-tag removal checks are
2557
+ * intentionally skipped for kept custom elements), else hoist
2558
+ * content per KEEP_CONTENT and remove.
2559
+ *
2560
+ * A kept custom element is the ONLY case in which this function
2561
+ * returns false, so the caller uses that return value to run the
2562
+ * afterSanitizeElements hook on the kept element and keep the
2563
+ * element-hook lifecycle consistent with normal allowlisted
2564
+ * elements (GHSA-c2j3-45gr-mqc4).
2565
+ *
2566
+ * @param currentNode the disallowed node
2567
+ * @param tagName the node's transformCaseFunc'd tag name
2568
+ * @return true if the node was removed, false if kept
2569
+ */
2570
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
2571
+ /* Check if we have a custom element to handle */
2572
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2573
+ return false;
2574
+ }
2575
+ /* Keep content except for bad-listed elements.
2576
+ Use the cached prototype getters exclusively — the previous code
2577
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
2578
+ fallbacks, but the cached getters always return the canonical
2579
+ value (or null for a real parent-less node), so the fallback
2580
+ path was dead in safe cases and a clobbering surface in unsafe
2581
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
2582
+ parentNode)` check already gates correctly. */
2583
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2584
+ const parentNode = getParentNode(currentNode);
2585
+ const childNodes = getChildNodes(currentNode);
2586
+ if (childNodes && parentNode) {
2587
+ const childCount = childNodes.length;
2588
+ /* Hoist by moving each child up one level rather than deep-cloning
2589
+ it. Moving transfers every descendant exactly once, so a chain of
2590
+ nested disallowed elements costs O(n) instead of the O(n^2) that
2591
+ re-cloning the shrinking subtree at each level produced; it also
2592
+ empties the removed original, so `DOMPurify.removed` no longer
2593
+ pins whole subtrees. Moving preserves the in-place guarantee too:
2594
+ an original carrying already-queued resource events (`<img
2595
+ onerror>`, `<video>`/`<audio>` error, lazy/`onload`, …) is
2596
+ relocated and sanitised rather than left detached but still armed.
2597
+ The sole case that must clone is removing the walk root itself.
2598
+ The result is serialised from the root's subtree, so a restrictive
2599
+ ALLOWED_TAGS that strips the root (`body` on the string path) must
2600
+ leave the content inside it, which only cloning does. In IN_PLACE
2601
+ the root is pre-validated as an allowed tag and so is never removed
2602
+ here, so that path always takes the move branch.
2603
+ `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
2604
+ valid whether we move (drops the trailing entry) or clone (leaves
2605
+ the list intact). */
2606
+ for (let i = childCount - 1; i >= 0; --i) {
2607
+ const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
2608
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
2609
+ }
2610
+ }
2611
+ }
2612
+ _forceRemove(currentNode);
2613
+ return true;
2614
+ };
2615
+ /**
2616
+ * Fork a hook-mutable allowlist off its shared binding the first time a
2617
+ * (possibly lazily-installed) uponSanitize* hook is about to see it, so the
2618
+ * hook cannot widen the per-instance default or the setConfig binding by
2619
+ * reference and leak past the call. Returns the set unchanged once it is
2620
+ * already call-local, so repeated calls across elements are idempotent.
2621
+ *
2622
+ * @param hookList the uponSanitize* hook array for this event
2623
+ * @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
2624
+ * @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
2625
+ * @param setConfigSet the captured setConfig() binding, or null
2626
+ * @return a call-local clone if a hook is present and set is still shared,
2627
+ * else set unchanged
2628
+ */
2629
+ const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
2630
+ if (hookList.length === 0) {
2631
+ return set;
2632
+ }
2633
+ return set === defaultSet || set === setConfigSet ? clone(set) : set;
2634
+ };
2635
+ /**
2636
+ * Shared guard for a node that a hook has detached from the walk tree,
2637
+ * used after each element-hook site in _sanitizeElements. Detaching is a
2638
+ * long-standing user pattern (issue #469; draw.io-style foreignObject
2639
+ * filtering). Per the cached, unclobberable parentNode getter the node is
2640
+ * genuinely out of the tree, so it can reach neither the serialized
2641
+ * output nor an IN_PLACE live tree; treat it as removed and stop
2642
+ * processing it. Without this guard, the unsafe-node / namespace checks
2643
+ * would call _forceRemove on a parentless node and hit the REPORT-3
2644
+ * fail-closed throw — which exists for nodes DOMPurify wants gone but
2645
+ * *cannot* detach (clobbered / parentless roots), the opposite of a node
2646
+ * that is already safely gone. The walk root is exempt: a detached
2647
+ * IN_PLACE root is legitimate input and must still be fully sanitized,
2648
+ * and a kill-decision on it must keep hitting the REPORT-3 throw.
2649
+ *
2650
+ * Nodes detached by hooks stay the hook's responsibility for placement:
2651
+ * they are not recorded in DOMPurify.removed, so the post-walk IN_PLACE
2652
+ * pass (which iterates DOMPurify.removed) does not reach them. But a
2653
+ * hook-detached subtree can still hold a queued resource-event handler -
2654
+ * e.g. an <img onload> that began loading when the caller built the live
2655
+ * tree - which fires in page scope after sanitize returns even though the
2656
+ * handler never reached the returned tree. That is the audit-5 F1 hazard,
2657
+ * and the documented node.remove() hook pattern walks straight into it.
2658
+ * So on the IN_PLACE path we neutralize the detached subtree inline,
2659
+ * stripping its non-allow-listed attributes before returning, exactly as
2660
+ * the post-walk pass does for _forceRemove'd subtrees.
2661
+ *
2662
+ * @param currentNode the node a hook may have detached
2663
+ * @param root the current walk root
2664
+ * @return true if the node is detached and now handled, false otherwise
2665
+ */
2666
+ const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
2667
+ if (currentNode === root || getParentNode(currentNode) !== null) {
2668
+ return false;
2669
+ }
2670
+ if (IN_PLACE) {
2671
+ _neutralizeSubtree(currentNode);
2672
+ }
2673
+ return true;
2674
+ };
2675
+ /**
2676
+ * _sanitizeElements
2677
+ *
2678
+ * @protect nodeName
2679
+ * @protect textContent
2680
+ * @protect removeChild
2681
+ * @param currentNode to check for permission to exist
2682
+ * @return true if node was killed, false if left alive
2683
+ */
2684
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
2685
+ /* Execute a hook if present */
2686
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2687
+ /* A hook may have detached the node - treat it as removed (see
2688
+ _handleHookDetachedNode for the full rationale). */
2689
+ if (_handleHookDetachedNode(currentNode, root)) {
2690
+ return true;
2691
+ }
2692
+ /* Check if element is clobbered or can clobber */
2693
+ if (_isClobbered(currentNode)) {
2694
+ _forceRemove(currentNode);
2695
+ return true;
2696
+ }
2697
+ /* Now let's check the element's type and name */
2698
+ const tagName = transformCaseFunc(_readNodeName(currentNode));
2699
+ /* Close the pre-walk clone-guard's timing gap: an uponSanitizeElement
2700
+ hook may have been installed after that guard sampled the hook arrays
2701
+ (e.g. lazily from beforeSanitizeElements), leaving ALLOWED_TAGS still
2702
+ aliasing a shared binding that a widening hook would mutate by
2703
+ reference. Fork it before exposing it to the hook. */
2704
+ ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
2705
+ /* Execute a hook if present */
2706
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
2707
+ tagName,
2708
+ allowedTags: ALLOWED_TAGS
2709
+ });
2710
+ /* The uponSanitizeElement hook may have detached the node, exactly as
2711
+ above (see _handleHookDetachedNode for the full rationale). */
2712
+ if (_handleHookDetachedNode(currentNode, root)) {
2713
+ return true;
2714
+ }
2715
+ /* Remove mXSS vectors, processing instructions and risky comments */
2716
+ if (_isUnsafeNode(currentNode, tagName)) {
2717
+ _forceRemove(currentNode);
2718
+ return true;
2719
+ }
2720
+ /* Remove element if anything forbids its presence */
2721
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
2722
+ const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
2723
+ /* A false return means the node is a custom element kept via
2724
+ CUSTOM_ELEMENT_HANDLING - the only keep path through
2725
+ _sanitizeDisallowedNode. Run afterSanitizeElements on it so the
2726
+ element-hook lifecycle matches normal allowlisted elements: a
2727
+ security policy applied in this hook (e.g. stripping an attribute
2728
+ from every surviving element) must not silently skip kept custom
2729
+ elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element
2730
+ tail below - the hook runs, then the walker's subsequent
2731
+ _sanitizeAttributes pass sanitizes the element's attributes. The
2732
+ deliberately skipped namespace and fallback-tag removal checks stay
2733
+ skipped; they are removal decisions, not the hook contract. */
2734
+ if (removed === false) {
2735
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2736
+ }
2737
+ return removed;
2738
+ }
2739
+ /* Check whether element has a valid namespace.
2740
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
2741
+ nodeType getter rather than `instanceof Element`, which is realm-
2742
+ bound and short-circuits to false for any node minted in a different
2743
+ realm — letting a foreign-realm element with a forbidden namespace
2744
+ slip past the namespace check entirely. */
2745
+ const nt = _readNodeType(currentNode);
2746
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
2747
+ _forceRemove(currentNode);
2748
+ return true;
2749
+ }
2750
+ /* Make sure that older browsers don't get fallback-tag mXSS */
2751
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
2752
+ _forceRemove(currentNode);
2753
+ return true;
2754
+ }
2755
+ /* Sanitize element content to be template-safe */
2756
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2757
+ /* Get the element's text content */
2758
+ const content = _stripTemplateExpressions(currentNode.textContent);
2759
+ if (currentNode.textContent !== content) {
2760
+ arrayPush(DOMPurify.removed, {
2761
+ element: currentNode.cloneNode()
2762
+ });
2763
+ currentNode.textContent = content;
2764
+ }
2765
+ }
2766
+ /* Execute a hook if present */
2767
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2768
+ return false;
2769
+ };
2770
+ /**
2771
+ * _isValidAttribute
2772
+ *
2773
+ * @param lcTag Lowercase tag name of containing element.
2774
+ * @param lcName Lowercase attribute name.
2775
+ * @param value Attribute value.
2776
+ * @return Returns true if `value` is valid, otherwise false.
2777
+ */
2778
+ // eslint-disable-next-line complexity
2779
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
2780
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
2781
+ if (FORBID_ATTR[lcName]) {
2782
+ return false;
2783
+ }
2784
+ /* Reject declarative-partial-updates patch-linkage attributes
2785
+ (https://github.com/WICG/declarative-partial-updates).
2786
+ Empirical note (Chrome 150, verified — see
2787
+ test/declarative-patch-probe-v3.html): expansion is NOT applied after
2788
+ sanitization. For the string path it fires during sanitize()'s own
2789
+ parse, so the walk sees and sanitizes the fully materialized expanded
2790
+ tree — teleports into MathML/SVG integration points included; a
2791
+ weaponized `<template for>`->`<img onerror>` comes back with the handler
2792
+ stripped. For the IN_PLACE path it fires on connection, before the walk.
2793
+ Either way DOMPurify is NOT blind to the patch.
2794
+ This removal is therefore defense-in-depth rather than the sole barrier:
2795
+ it prevents live linkage from surviving into the OUTPUT and re-expanding
2796
+ in the caller's context, and keeps behaviour deterministic if a future
2797
+ engine defers expansion. `for` is legitimate only on <label>/<output>;
2798
+ anywhere else (notably <template for>) it links the element to a patch
2799
+ target and teleports or removes an arbitrary DOM range by id/marker name.
2800
+ `patchsrc` fetches remote markup and is treated as a script-loading
2801
+ mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the
2802
+ other structural-threat checks and stays overridable, consistent with
2803
+ the rest of the codebase. PI range markers are already removed by
2804
+ _isUnsafeNode. */
2805
+ if (_isPatchLinkageAttribute(lcName, lcTag)) {
2806
+ return false;
2807
+ }
2808
+ /* Make sure attribute cannot clobber */
2809
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
2810
+ return false;
2811
+ }
2812
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
2813
+ /* Allow valid data-* attributes: At least one character after "-"
2814
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
2815
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
2816
+ We don't need to check the value; it's always URI safe. */
2817
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) {
2818
+ return true;
2819
+ }
2820
+ /* Allow valid aria-* attributes, the value is always URI safe */
2821
+ if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) {
2822
+ return true;
2823
+ }
2824
+ /* A name outside the allowlist is acceptable on custom-element terms
2825
+ only. The value checks below are intentionally skipped in that case:
2826
+ if the user supplied a tagNameCheck we also allow derived custom
2827
+ elements using the same test, and attributes passing the configured
2828
+ attributeNameCheck are allowed as custom elements define these at
2829
+ their own discretion. */
2830
+ if (!nameIsPermitted) {
2831
+ return (
2832
+ // Condition a) covers a basically valid custom element tag name whose
2833
+ // tag passes the configured tagNameCheck and whose attribute name
2834
+ // passes the configured attributeNameCheck ...
2835
+ _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) ||
2836
+ // Condition b) covers an `is` attribute whose value passes the
2837
+ // configured tagNameCheck while customized built-in elements are
2838
+ // allowed.
2839
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)
2840
+ );
2841
+ }
2842
+ /* Check value is safe. First, is attr inert? If so, is safe */
2843
+ if (URI_SAFE_ATTRIBUTES[lcName]) {
2844
+ return true;
2845
+ }
2846
+ /* Check no script, data or unknown possibly unsafe URI
2847
+ unless we know URI values are safe for that attribute */
2848
+ if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) {
2849
+ return true;
2850
+ }
2851
+ /* Keep image data URIs alive if src/xlink:href is allowed */
2852
+ /* Further prevent gadget XSS for dynamically built script tags */
2853
+ if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) {
2854
+ return true;
2855
+ }
2856
+ /* Allow unknown protocols: This provides support for links that
2857
+ are handled by protocol handlers which may be unknown ahead of
2858
+ time, e.g. fb:, spotify: */
2859
+ if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) {
2860
+ return true;
2861
+ }
2862
+ /* Only an empty (binary) value remains safe at this point;
2863
+ anything else is presumed unsafe, do not add it back */
2864
+ return !value;
2865
+ };
2866
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
2867
+ * never be treated as basic custom elements even when a permissive
2868
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
2869
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
2870
+ /**
2871
+ * _isBasicCustomElement
2872
+ * checks if at least one dash is included in tagName, and it's not the first char
2873
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
2874
+ *
2875
+ * @param tagName name of the tag of the node to sanitize
2876
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
2877
+ */
2878
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
2879
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
2880
+ };
2881
+ /**
2882
+ * Wrap an attribute value in the matching Trusted Types object when
2883
+ * the active policy requires it. Namespaced attributes pass through
2884
+ * unchanged (no TT support yet, see
2885
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
2886
+ *
2887
+ * @param lcTag lowercase tag name of the containing element
2888
+ * @param lcName lowercase attribute name
2889
+ * @param namespaceURI the attribute's namespace, if any
2890
+ * @param value the attribute value to wrap
2891
+ * @return the value, wrapped when Trusted Types demand it
2892
+ */
2893
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
2894
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
2895
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2896
+ case 'TrustedHTML':
2897
+ {
2898
+ return _createTrustedHTML(value);
2899
+ }
2900
+ case 'TrustedScriptURL':
2901
+ {
2902
+ return _createTrustedScriptURL(value);
2903
+ }
2904
+ }
2905
+ }
2906
+ return value;
2907
+ };
2908
+ /**
2909
+ * Write a modified attribute value back onto the element. On
2910
+ * success, re-probe for clobbering introduced by the new value and
2911
+ * remove the element when found; otherwise pop the removal entry
2912
+ * recorded by the earlier _removeAttribute (long-standing pairing
2913
+ * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
2914
+ * failure, remove the attribute instead.
2915
+ *
2916
+ * @param currentNode the element carrying the attribute
2917
+ * @param name the attribute name as present on the element
2918
+ * @param namespaceURI the attribute's namespace, if any
2919
+ * @param value the new attribute value
2920
+ */
2921
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2922
+ try {
2923
+ if (namespaceURI) {
2924
+ currentNode.setAttributeNS(namespaceURI, name, value);
2925
+ } else {
2926
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
2927
+ currentNode.setAttribute(name, value);
2928
+ }
2929
+ if (_isClobbered(currentNode)) {
2930
+ _forceRemove(currentNode);
2931
+ } else {
2932
+ arrayPop(DOMPurify.removed);
2933
+ }
2934
+ } catch (_) {
2935
+ _removeAttribute(name, currentNode);
2936
+ }
2937
+ };
2938
+ /**
2939
+ * _sanitizeAttributes
2940
+ *
2941
+ * @protect attributes
2942
+ * @protect nodeName
2943
+ * @protect removeAttribute
2944
+ * @protect setAttribute
2945
+ *
2946
+ * @param currentNode to sanitize
2947
+ */
2948
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
2949
+ /* Execute a hook if present */
2950
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2951
+ const attributes = currentNode.attributes;
2952
+ /* Check if we have attributes; if not we might have a text node */
2953
+ if (!attributes || _isClobbered(currentNode)) {
2954
+ return;
2955
+ }
2956
+ /* Same lazy-install guard as uponSanitizeElement (see there): fork the
2957
+ attribute allowlist off its shared binding before a hook can see it. */
2958
+ ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
2959
+ const hookEvent = {
2960
+ attrName: '',
2961
+ attrValue: '',
2962
+ keepAttr: true,
2963
+ allowedAttributes: ALLOWED_ATTR,
2964
+ forceKeepAttr: undefined
2965
+ };
2966
+ let l = attributes.length;
2967
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2968
+ /* Go backwards over all attributes; safely remove bad ones */
2969
+ while (l--) {
2970
+ const attr = attributes[l];
2971
+ const name = attr.name,
2972
+ namespaceURI = attr.namespaceURI,
2973
+ attrValue = attr.value;
2974
+ const lcName = transformCaseFunc(name);
2975
+ const initValue = attrValue;
2976
+ let value = name === 'value' ? initValue : stringTrim(initValue);
2977
+ /* Execute a hook if present */
2978
+ hookEvent.attrName = lcName;
2979
+ hookEvent.attrValue = value;
2980
+ hookEvent.keepAttr = true;
2981
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
2982
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2983
+ value = hookEvent.attrValue;
2984
+ /* Full DOM Clobbering protection via namespace isolation,
2985
+ * Prefix id and name attributes with `user-content-`
2986
+ */
2987
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2988
+ // Remove the attribute with this value
2989
+ _removeAttribute(name, currentNode, attr);
2990
+ // Prefix the value and later re-create the attribute with the sanitized value
2991
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2992
+ }
2993
+ // Else: already prefixed, leave the attribute alone — the prefix is
2994
+ // itself the clobbering protection, and re-applying it is incorrect.
2995
+ /* Work around a security issue with comments inside attributes */
2996
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
2997
+ _removeAttribute(name, currentNode, attr);
2998
+ continue;
2999
+ }
3000
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
3001
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
3002
+ _removeAttribute(name, currentNode, attr);
3003
+ continue;
3004
+ }
3005
+ /* Did the hooks force-keep the attribute? */
3006
+ if (hookEvent.forceKeepAttr) {
3007
+ continue;
3008
+ }
3009
+ /* Did the hooks approve of the attribute? */
3010
+ if (!hookEvent.keepAttr) {
3011
+ _removeAttribute(name, currentNode, attr);
3012
+ continue;
3013
+ }
3014
+ /* Work around a security issue in jQuery 3.0 */
3015
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
3016
+ _removeAttribute(name, currentNode, attr);
3017
+ continue;
3018
+ }
3019
+ /* Sanitize attribute content to be template-safe */
3020
+ if (SAFE_FOR_TEMPLATES) {
3021
+ value = _stripTemplateExpressions(value);
3022
+ }
3023
+ /* Is `value` valid for this attribute? */
3024
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3025
+ _removeAttribute(name, currentNode, attr);
3026
+ continue;
3027
+ }
3028
+ /* Handle attributes that require Trusted Types */
3029
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
3030
+ /* Handle invalid data-* attribute set by try-catching it */
3031
+ if (value !== initValue) {
3032
+ _setAttributeValue(currentNode, name, namespaceURI, value);
3033
+ }
3034
+ }
3035
+ /* Execute a hook if present */
3036
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3037
+ };
3038
+ /**
3039
+ * _sanitizeShadowDOM
3040
+ *
3041
+ * @param fragment to iterate over recursively
3042
+ */
3043
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3044
+ let shadowNode = null;
3045
+ const shadowIterator = _createNodeIterator(fragment);
3046
+ /* Execute a hook if present */
3047
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3048
+ while (shadowNode = shadowIterator.nextNode()) {
3049
+ /* Execute a hook if present */
3050
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3051
+ /* Sanitize tags and elements */
3052
+ _sanitizeElements(shadowNode, fragment);
3053
+ /* Check attributes next */
3054
+ _sanitizeAttributes(shadowNode);
3055
+ /* Deep shadow DOM detected.
3056
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
3057
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
3058
+ recurse into <template>.content from foreign realms too. */
3059
+ if (_isDocumentFragment(shadowNode.content)) {
3060
+ _sanitizeShadowDOM2(shadowNode.content);
3061
+ }
3062
+ /* An element iterated here may itself host an attached
3063
+ shadow root. The default NodeIterator does not enter shadow
3064
+ trees, so a shadow root nested inside template.content was
3065
+ previously reached by no walk at all (the pre-pass at
3066
+ _sanitizeAttachedShadowRoots descends via childNodes, which
3067
+ doesn't enter template.content; the template-content recursion
3068
+ above iterates the content but never inspected shadowRoot).
3069
+ Walk it explicitly. The nodeType guard avoids reading
3070
+ shadowRoot off text / comment / CDATA / PI nodes that the
3071
+ iterator also surfaces. */
3072
+ if (_readNodeType(shadowNode) === NODE_TYPE.element) {
3073
+ const innerSr = getShadowRoot(shadowNode);
3074
+ if (_isDocumentFragment(innerSr)) {
3075
+ _sanitizeAttachedShadowRoots(innerSr);
3076
+ _sanitizeShadowDOM2(innerSr);
3077
+ }
3078
+ }
3079
+ }
3080
+ /* Execute a hook if present */
3081
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3082
+ };
3083
+ /**
3084
+ * _sanitizeAttachedShadowRoots
3085
+ *
3086
+ * Walks `root` and feeds every attached shadow root we encounter into
3087
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
3088
+ * does not descend into shadow trees, so nodes inside an attached
3089
+ * shadow root would otherwise be skipped entirely.
3090
+ *
3091
+ * Two real input paths put attached shadow roots in front of us:
3092
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
3093
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
3094
+ * shadow root because it was created with `clonable: true`.
3095
+ *
3096
+ * This pass runs once, up front, so the main iteration loop (and the
3097
+ * existing _sanitizeShadowDOM template-content recursion) stay
3098
+ * untouched — string-input paths are not affected.
3099
+ *
3100
+ * @param root the subtree root to walk for attached shadow roots
3101
+ */
3102
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
3103
+ /* Iterative (explicit stack) rather than per-child recursion. DOM APIs
3104
+ impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
3105
+ built straight into the DOM — the IN_PLACE surface) deeper than the JS
3106
+ call-stack budget would otherwise overflow native recursion here and
3107
+ throw at the IN_PLACE entry pre-pass, before a single node is
3108
+ sanitized, leaving the caller's live tree untouched (fail-open). See
3109
+ campaign-3 F4. A heap stack keeps depth off the call stack.
3110
+ Each work item is either a node to descend into, or a deferred
3111
+ `_sanitizeShadowDOM` for an already-walked shadow root. The deferred
3112
+ form preserves the original post-order discipline: a shadow root's
3113
+ nested shadow roots are discovered before the outer shadow is
3114
+ sanitized (which may remove hosts). Pushes are in reverse of the
3115
+ desired processing order (LIFO): template content, then children, then
3116
+ the shadow-sanitize, then the shadow walk — so the order matches the
3117
+ previous recursion exactly. */
3118
+ const stack = [{
3119
+ node: root,
3120
+ shadow: null
3121
+ }];
3122
+ while (stack.length > 0) {
3123
+ const item = stack.pop();
3124
+ /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
3125
+ if (item.shadow) {
3126
+ _sanitizeShadowDOM2(item.shadow);
3127
+ continue;
3128
+ }
3129
+ const node = item.node;
3130
+ const nodeType = _readNodeType(node);
3131
+ const isElement = nodeType === NODE_TYPE.element;
3132
+ /* (pushed last → processed first) Children, snapshotted in reverse so
3133
+ the first child is processed first. Snapshotting matters because a
3134
+ hook may detach siblings mid-walk. */
3135
+ const childNodes = getChildNodes(node);
3136
+ if (childNodes) {
3137
+ for (let i = childNodes.length - 1; i >= 0; --i) {
3138
+ stack.push({
3139
+ node: childNodes[i],
3140
+ shadow: null
3141
+ });
3142
+ }
3143
+ }
3144
+ /* (pushed before children → processed after them, matching the old
3145
+ "template content last" order) When the node is a <template>,
3146
+ descend into its content. */
3147
+ if (isElement) {
3148
+ const rootName = getNodeName ? getNodeName(node) : null;
3149
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
3150
+ const content = node.content;
3151
+ if (_isDocumentFragment(content)) {
3152
+ stack.push({
3153
+ node: content,
3154
+ shadow: null
3155
+ });
3156
+ }
3157
+ }
3158
+ }
3159
+ /* Shadow root (processed first): walk its subtree, then sanitise it.
3160
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
3161
+ rather than `instanceof DocumentFragment`, which is realm-bound and
3162
+ silently skipped foreign-realm shadow roots (e.g.
3163
+ iframe.contentDocument attachShadow). */
3164
+ if (isElement) {
3165
+ const sr = getShadowRoot(node);
3166
+ if (_isDocumentFragment(sr)) {
3167
+ /* Push the deferred sanitise first so it pops after the shadow
3168
+ walk we push next, i.e. nested shadow roots are discovered
3169
+ before this one is sanitised. */
3170
+ stack.push({
3171
+ node: null,
3172
+ shadow: sr
3173
+ }, {
3174
+ node: sr,
3175
+ shadow: null
3176
+ });
3177
+ }
3178
+ }
3179
+ }
3180
+ };
3181
+ // eslint-disable-next-line complexity
3182
+ DOMPurify.sanitize = function (dirty) {
3183
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3184
+ let body = null;
3185
+ let importedNode = null;
3186
+ let currentNode = null;
3187
+ let returnNode = null;
3188
+ /* Make sure we have a string to sanitize.
3189
+ DO NOT return early, as this will return the wrong type if
3190
+ the user has requested a DOM object rather than a string */
3191
+ IS_EMPTY_INPUT = !dirty;
3192
+ if (IS_EMPTY_INPUT) {
3193
+ dirty = '<!-->';
3194
+ }
3195
+ /* Stringify, in case dirty is an object */
3196
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
3197
+ dirty = stringifyValue(dirty);
3198
+ if (typeof dirty !== 'string') {
3199
+ throw typeErrorCreate('dirty is not a string, aborting');
3200
+ }
3201
+ }
3202
+ /* Return dirty HTML if DOMPurify cannot run */
3203
+ if (!DOMPurify.isSupported) {
3204
+ return dirty;
3205
+ }
3206
+ /* Assign config vars */
3207
+ if (SET_CONFIG) {
3208
+ /* Persistent setConfig() path: _parseConfig is skipped, so the sets are
3209
+ * not re-derived per call. Restore them from the pristine bindings
3210
+ * captured at setConfig() time so a previous call's hook clone (mutated
3211
+ * below) does not carry over. */
3212
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
3213
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
591
3214
  } else {
592
- setPost(unreadcount);
3215
+ _parseConfig(cfg);
3216
+ }
3217
+ /* Clone the hook-mutable allowlists before the walk whenever an
3218
+ * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
3219
+ * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
3220
+ * a hook that widens them would otherwise mutate the shared set
3221
+ * permanently: across later calls and across every element. Cloning per
3222
+ * walk keeps documented in-call widening working while scoping it to the
3223
+ * call. A single guard for both config paths - the per-call path rebinds
3224
+ * the sets in _parseConfig each call, the persistent path restores them
3225
+ * from the captured bindings just above - so the two cannot diverge. */
3226
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
3227
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
3228
+ }
3229
+ if (hooks.uponSanitizeAttribute.length > 0) {
3230
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
3231
+ }
3232
+ /* Clean up removed elements */
3233
+ DOMPurify.removed = [];
3234
+ /* Resolve IN_PLACE for this call without mutating persistent config.
3235
+ Writing the IN_PLACE closure variable here leaks under setConfig(),
3236
+ where _parseConfig is skipped on later calls: a single string call would
3237
+ disable in-place mode for every subsequent node call, returning a
3238
+ sanitized copy while leaving the caller's node — which in-place callers
3239
+ keep using and whose return value they ignore — unsanitized. REPORT-2. */
3240
+ const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
3241
+ if (inPlace) {
3242
+ /* Declarative-partial-updates / streaming pre-pass: sever every patch
3243
+ linkage across the live tree BEFORE the walk, so no patch can fire
3244
+ mid-walk and inject into an already-processed region. Runs first, so
3245
+ it also covers the forbidden/clobbered roots that throw below. */
3246
+ _neutralizePatchLinkage(dirty);
3247
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
3248
+ Read nodeName through the cached prototype getter — a clobbering
3249
+ child named "nodeName" on the form root would otherwise shadow
3250
+ the property and let this check skip the root-allowlist
3251
+ validation entirely. */
3252
+ const nn = _readNodeName(dirty);
3253
+ if (typeof nn === 'string') {
3254
+ const tagName = transformCaseFunc(nn);
3255
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3256
+ /* Fail closed on a live root: neutralize handlers/children before
3257
+ throwing, exactly as the mid-walk abort path does. */
3258
+ _neutralizeRoot(dirty);
3259
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
3260
+ }
3261
+ }
3262
+ /* Pre-flight the root through _isClobbered. The iterator-driven
3263
+ removal path can not detach a parent-less root: _forceRemove
3264
+ falls through to Element.prototype.remove(), which per spec
3265
+ is a no-op on a node with no parent. A clobbered root would
3266
+ then survive the main loop with its attributes uninspected,
3267
+ because _sanitizeAttributes early-returns on _isClobbered. The
3268
+ result would be an attacker-controlled form, complete with any
3269
+ event-handler attributes the caller passed in, handed back to
3270
+ the application unsanitized. Refuse to sanitize such a root
3271
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
3272
+ if (_isClobbered(dirty)) {
3273
+ /* Fail closed on a live clobbered root before throwing.
3274
+ _neutralizeRoot's reads are clobber-safe (cached getters); the
3275
+ form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */
3276
+ _neutralizeRoot(dirty);
3277
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
3278
+ }
3279
+ /* Sanitize attached shadow roots before the main iterator runs.
3280
+ The iterator does not descend into shadow trees. Same fail-closed
3281
+ barrier as the main walk (campaign-3 F2): a custom-element reaction
3282
+ inside a shadow root could abort this pre-pass before the walk runs,
3283
+ which would otherwise leave the entire live tree unsanitized. */
3284
+ try {
3285
+ _sanitizeAttachedShadowRoots(dirty);
3286
+ } catch (error) {
3287
+ _neutralizeRoot(dirty);
3288
+ throw error;
3289
+ }
3290
+ } else if (_isNode(dirty)) {
3291
+ /* If dirty is a DOM element, append to an empty document to avoid
3292
+ elements being stripped by the parser */
3293
+ body = _initDocument('<!---->');
3294
+ importedNode = body.ownerDocument.importNode(dirty, true);
3295
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
3296
+ /* Node is already a body, use as is */
3297
+ body = importedNode;
3298
+ } else if (importedNode.nodeName === 'HTML') {
3299
+ body = importedNode;
3300
+ } else {
3301
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
3302
+ body.appendChild(importedNode);
3303
+ }
3304
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
3305
+ them before the main iterator runs, since the iterator does not
3306
+ descend into shadow trees. The walk routes every read through a
3307
+ cached prototype getter so clobbering descendants on a form root
3308
+ cannot hide a shadow host from this pass. */
3309
+ _sanitizeAttachedShadowRoots(importedNode);
3310
+ } else {
3311
+ /* Exit directly if we have nothing to do */
3312
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
3313
+ // eslint-disable-next-line unicorn/prefer-includes
3314
+ dirty.indexOf('<') === -1) {
3315
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
3316
+ }
3317
+ /* Initialize the document to work on */
3318
+ body = _initDocument(dirty);
3319
+ /* Check we have a DOM node from the data */
3320
+ if (!body) {
3321
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
3322
+ }
593
3323
  }
594
- logConsole(configLogs, 'data', '', unreadcount);
595
- const favoriteValue = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
596
- if (type === 'get' && favoriteValue === true) {
597
- setColor('#ffcd38');
598
- } else if (type === 'set') {
599
- setColor('#ffcd38');
600
- localStorage.setItem('favoritessynch01', 'true');
601
- localStorage.setItem('favoritessynch02', 'true');
602
- window.dispatchEvent(new Event('favorites'));
603
- } else if (type === 'del') {
604
- setColor('');
605
- localStorage.setItem('favoritessynch01', 'true');
606
- localStorage.setItem('favoritessynch02', 'true');
607
- window.dispatchEvent(new Event('favorites'));
3324
+ /* Remove first element node (ours) if FORCE_BODY is set */
3325
+ if (body && FORCE_BODY) {
3326
+ _forceRemove(body.firstChild);
3327
+ }
3328
+ /* Get node iterator */
3329
+ const walkRoot = inPlace ? dirty : body;
3330
+ /* Now start iterating over the created document.
3331
+ The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
3332
+ engine/custom-element mutation can detach a node mid-walk so
3333
+ `_forceRemove`'s parentless guard throws, aborting the loop. Without the
3334
+ barrier the caller's in-place tree would be left half-sanitized with the
3335
+ unvisited tail still armed. _createNodeIterator itself is inside the
3336
+ barrier too: constructing the iterator dereferences the root's document,
3337
+ and any failure there (e.g. an exotic/clobbered root) must still fail
3338
+ closed rather than skip the neutralize. On any throw we fail closed -
3339
+ strip the in-place root bare - then rethrow so the existing throw
3340
+ contract is preserved. (String/DOM-copy paths never return the partial
3341
+ body, so the propagating throw is already fail-closed there.) */
3342
+ try {
3343
+ const nodeIterator = _createNodeIterator(walkRoot);
3344
+ while (currentNode = nodeIterator.nextNode()) {
3345
+ /* Sanitize tags and elements */
3346
+ _sanitizeElements(currentNode, walkRoot);
3347
+ /* Check attributes next */
3348
+ _sanitizeAttributes(currentNode);
3349
+ /* Shadow DOM detected, sanitize it.
3350
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
3351
+ instead of instanceof, so foreign-realm <template>.content is
3352
+ walked correctly. */
3353
+ if (_isDocumentFragment(currentNode.content)) {
3354
+ _sanitizeShadowDOM2(currentNode.content);
3355
+ }
3356
+ }
3357
+ } catch (error) {
3358
+ if (inPlace) {
3359
+ _neutralizeRoot(dirty);
3360
+ /* Nodes _forceRemove'd earlier in the aborted walk are already
3361
+ detached from the root, so _neutralizeRoot's subtree pass does not
3362
+ reach them. Defuse them too, mirroring the success-path loop below. */
3363
+ arrayForEach(DOMPurify.removed, entry => {
3364
+ if (entry.element) {
3365
+ _neutralizeSubtree(entry.element);
3366
+ }
3367
+ });
3368
+ }
3369
+ throw error;
608
3370
  }
609
- setIsError(false);
610
- } catch (err) {
611
- setError(true);
612
- handleError$3(err, t, configLogs, setIsError, setMessageerror);
613
- } finally {
614
- setLoading(false);
615
- }
616
- };
617
- const serviceGetFavorites = async (fpHash = '', sessionID, postURL, cxauthxc, t, setPost, setIsError, setError, setMessageerror, setLoading, configLogs, ...rest) => {
618
- const visitorIdHash = await getOrSetFingerprint(fpHash);
619
- try {
620
- const requestData = {
621
- ...rest[0],
622
- sessionID,
623
- cxauthxc,
624
- postServerURL: postURL,
625
- authorization: true,
626
- fingerprint: visitorIdHash
627
- };
628
- const unreadcount = await getservice(requestData, configLogs);
629
- const responseData = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
630
- setPost(responseData);
631
- localStorage.setItem('favoritessynch03', JSON.stringify(responseData));
632
- logConsole(configLogs, 'data', '', unreadcount);
633
- setIsError(false);
634
- } catch (err) {
635
- setError(true);
636
- handleError$3(err, t, configLogs, setIsError, setMessageerror);
637
- } finally {
638
- setLoading(false);
639
- }
640
- };
641
-
642
- const defaultConfig$3 = {
643
- enableLogs: false,
644
- enableLogsError: false,
645
- enableLogsWarning: false,
646
- enableLogsInfo: false,
647
- enableLogsData: false,
648
- enableLogsDebug: false,
649
- developmentMode: false
650
- };
651
- const ConexysConfigContext = /*#__PURE__*/React.createContext(defaultConfig$3);
652
- const ConexysConfigProvider = ({
653
- children,
654
- config = {}
655
- }) => {
656
- const mergedConfig = {
657
- ...defaultConfig$3,
658
- ...config
3371
+ /* If we sanitized `dirty` in-place, return it. */
3372
+ if (inPlace) {
3373
+ /* Fail-closed completion of the audit-5 F1 fix: every node removed from
3374
+ the caller's live tree is detached but may still hold a queued
3375
+ resource-event handler that fires in page scope after we return. The
3376
+ move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
3377
+ non-allow-listed attributes off every other removed subtree (clobber,
3378
+ mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
3379
+ cancelled before any event can fire. Runs synchronously, pre-return. */
3380
+ arrayForEach(DOMPurify.removed, entry => {
3381
+ if (entry.element) {
3382
+ _neutralizeSubtree(entry.element);
3383
+ }
3384
+ });
3385
+ if (SAFE_FOR_TEMPLATES) {
3386
+ _scrubTemplateExpressions2(dirty);
3387
+ }
3388
+ return dirty;
3389
+ }
3390
+ /* Return sanitized string or DOM */
3391
+ if (RETURN_DOM) {
3392
+ if (SAFE_FOR_TEMPLATES) {
3393
+ _scrubTemplateExpressions2(body);
3394
+ }
3395
+ if (RETURN_DOM_FRAGMENT) {
3396
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3397
+ while (body.firstChild) {
3398
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
3399
+ returnNode.appendChild(body.firstChild);
3400
+ }
3401
+ } else {
3402
+ returnNode = body;
3403
+ }
3404
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3405
+ /*
3406
+ AdoptNode() is not used because internal state is not reset
3407
+ (e.g. the past names map of a HTMLFormElement), this is safe
3408
+ in theory but we would rather not risk another attack vector.
3409
+ The state that is cloned by importNode() is explicitly defined
3410
+ by the specs.
3411
+ */
3412
+ returnNode = importNode.call(originalDocument, returnNode, true);
3413
+ }
3414
+ return returnNode;
3415
+ }
3416
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3417
+ /* Serialize doctype if allowed */
3418
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3419
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
3420
+ }
3421
+ /* Sanitize final string template-safe */
3422
+ if (SAFE_FOR_TEMPLATES) {
3423
+ serializedHTML = _stripTemplateExpressions(serializedHTML);
3424
+ }
3425
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
3426
+ };
3427
+ DOMPurify.setConfig = function () {
3428
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3429
+ _parseConfig(cfg);
3430
+ SET_CONFIG = true;
3431
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
3432
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
3433
+ };
3434
+ DOMPurify.clearConfig = function () {
3435
+ CONFIG = null;
3436
+ SET_CONFIG = false;
3437
+ SET_CONFIG_ALLOWED_TAGS = null;
3438
+ SET_CONFIG_ALLOWED_ATTR = null;
3439
+ // Drop any caller-supplied Trusted Types policy so it cannot poison later
3440
+ // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
3441
+ // never recreated — Trusted Types throws on duplicate names) is restored by
3442
+ // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
3443
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
3444
+ emptyHTML = '';
3445
+ };
3446
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
3447
+ /* Initialize shared config vars if necessary. */
3448
+ if (!CONFIG) {
3449
+ _parseConfig({});
3450
+ }
3451
+ const lcTag = transformCaseFunc(tag);
3452
+ const lcName = transformCaseFunc(attr);
3453
+ return _isValidAttribute(lcTag, lcName, value);
3454
+ };
3455
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
3456
+ if (typeof hookFunction !== 'function') {
3457
+ return;
3458
+ }
3459
+ /* Reject unknown entry points. Without this, a non-hook key (e.g.
3460
+ * '__proto__') indexes off the prototype chain rather than a real
3461
+ * hook array, and arrayPush then writes to Object.prototype. Guard
3462
+ * with an own-property check against the known hook names. */
3463
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3464
+ return;
3465
+ }
3466
+ arrayPush(hooks[entryPoint], hookFunction);
659
3467
  };
660
- return /*#__PURE__*/React.createElement(ConexysConfigContext.Provider, {
661
- value: mergedConfig
662
- }, children);
663
- };
664
- const useConexysConfig = () => {
665
- return React.useContext(ConexysConfigContext);
666
- };
667
- const isDevelopmentMode = config => {
668
- return config.developmentMode;
669
- };
670
-
671
- const config$3 = {
672
- headers: {
673
- 'Content-Type': 'application/json'
674
- }
675
- };
676
- function AppDataSettings({
677
- keys
678
- }) {
679
- const configLogs = useConexysConfig();
680
- const postURL = Url + 'getsettings';
681
- const [post, setPost] = React.useState(null);
682
- const [error, setError] = React.useState(false);
683
- const hasFetched = React.useRef(false);
684
- const fetchData = React.useCallback(async () => {
685
- if (hasFetched.current) return;
686
- hasFetched.current = true;
687
- try {
688
- await serviceData(postURL, {
689
- keys: keys
690
- }, config$3, setPost, configLogs);
691
- } catch (err) {
692
- setError(true);
693
- logConsole(configLogs, 'error', 'Error fetching data:', err);
694
- console.error('Error fetching data:', err);
3468
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
3469
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3470
+ return undefined;
695
3471
  }
696
- }, []);
697
- React.useEffect(() => {
698
- fetchData();
699
- }, [fetchData]);
700
- if (!post) return null;
701
- return /*#__PURE__*/React.createElement(React.Fragment, null, error ? /*#__PURE__*/React.createElement("div", null, "Error loading data") : post);
3472
+ if (hookFunction !== undefined) {
3473
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3474
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
3475
+ }
3476
+ return arrayPop(hooks[entryPoint]);
3477
+ };
3478
+ DOMPurify.removeHooks = function (entryPoint) {
3479
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3480
+ return;
3481
+ }
3482
+ hooks[entryPoint] = [];
3483
+ };
3484
+ DOMPurify.removeAllHooks = function () {
3485
+ hooks = _createHooksMap();
3486
+ };
3487
+ return DOMPurify;
3488
+ }
3489
+ var purify = createDOMPurify();
3490
+
3491
+ function sanitizeHtml(html) {
3492
+ if (!html) return '';
3493
+ return purify.sanitize(html);
702
3494
  }
703
3495
 
704
3496
  const config$2 = {
@@ -733,7 +3525,7 @@ function AppDataSettingsHTML({
733
3525
  if (!htmlString) return null;
734
3526
  return /*#__PURE__*/React.createElement(React.Fragment, null, error ? (/*#__PURE__*/React.createElement("div", null, "Error loading data")) : (/*#__PURE__*/React.createElement("div", {
735
3527
  dangerouslySetInnerHTML: {
736
- __html: htmlString
3528
+ __html: sanitizeHtml(htmlString)
737
3529
  }
738
3530
  })));
739
3531
  }
@@ -827,14 +3619,18 @@ const postFormService = async (datauser, configLogs) => {
827
3619
  }
828
3620
  }
829
3621
  const dataload = [restData, valueToPush];
3622
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
830
3623
  let config;
831
3624
  let datasend;
832
3625
  if (authorization === true) {
833
3626
  config = {
3627
+ withCredentials: true,
834
3628
  headers: {
835
3629
  Authorization: `Bearer ${datauser.cxauthxc}`,
3630
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
836
3631
  'X-Session-ID': datauser.sessionID || '',
837
3632
  'X-Fingerprint': datauser.fingerprint || '',
3633
+ 'X-Session-Type': xSessionType,
838
3634
  'Content-Type': 'application/json'
839
3635
  }
840
3636
  };
@@ -854,7 +3650,9 @@ const postFormService = async (datauser, configLogs) => {
854
3650
  }
855
3651
  } else {
856
3652
  config = {
3653
+ withCredentials: true,
857
3654
  headers: {
3655
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
858
3656
  'Content-Type': 'application/json'
859
3657
  }
860
3658
  };
@@ -908,14 +3706,18 @@ const patchFormService = async (datauser, configLogs) => {
908
3706
  }
909
3707
  }
910
3708
  const dataload = [restData, valueToPush];
3709
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
911
3710
  let config;
912
3711
  let datasend;
913
3712
  if (authorization === true) {
914
3713
  config = {
3714
+ withCredentials: true,
915
3715
  headers: {
916
3716
  Authorization: `Bearer ${datauser.cxauthxc}`,
3717
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
917
3718
  'X-Session-ID': datauser.sessionID || '',
918
3719
  'X-Fingerprint': datauser.fingerprint || '',
3720
+ 'X-Session-Type': xSessionType,
919
3721
  'Content-Type': 'application/json'
920
3722
  }
921
3723
  };
@@ -935,7 +3737,9 @@ const patchFormService = async (datauser, configLogs) => {
935
3737
  }
936
3738
  } else {
937
3739
  config = {
3740
+ withCredentials: true,
938
3741
  headers: {
3742
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
939
3743
  'Content-Type': 'application/json'
940
3744
  }
941
3745
  };
@@ -972,11 +3776,15 @@ const deleteFormService = async (datauser, configLogs) => {
972
3776
  ...datasend
973
3777
  } = datauser;
974
3778
  const logs = configLogs || defaultConfig$2;
3779
+ const xSessionType = authStorage.getSessionTypeValue(logs);
975
3780
  const config = {
3781
+ withCredentials: true,
976
3782
  headers: {
977
3783
  Authorization: `Bearer ${cxauthxc}`,
3784
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
978
3785
  'X-Session-ID': datauser.sessionID || '',
979
3786
  'X-Fingerprint': datauser.fingerprint || '',
3787
+ 'X-Session-Type': xSessionType,
980
3788
  'Content-Type': 'application/json'
981
3789
  }
982
3790
  };
@@ -1015,11 +3823,15 @@ const restoreFormService = async (datauser, configLogs) => {
1015
3823
  ...datasend
1016
3824
  } = datauser;
1017
3825
  const logs = configLogs || defaultConfig$1;
3826
+ const xSessionType = authStorage.getSessionTypeValue(logs);
1018
3827
  const config = {
3828
+ withCredentials: true,
1019
3829
  headers: {
1020
3830
  Authorization: `Bearer ${cxauthxc}`,
3831
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
1021
3832
  'X-Session-ID': datauser.sessionID || '',
1022
3833
  'X-Fingerprint': datauser.fingerprint || '',
3834
+ 'X-Session-Type': xSessionType,
1023
3835
  'Content-Type': 'application/json'
1024
3836
  }
1025
3837
  };
@@ -1038,7 +3850,7 @@ var restoreFormService$1 = {
1038
3850
  restoreFormService
1039
3851
  };
1040
3852
 
1041
- const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, id, restoreServerURL, feedback, method = 'post', restoreMethod = 'post', fetchMethod = 'post') => {
3853
+ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, id, restoreServerURL, feedback, method = 'post', restoreMethod = 'post', fetchMethod = 'post', allowEmptyIdFetch = false) => {
1042
3854
  const configLogs = useConexysConfig();
1043
3855
  const [t] = reactI18next.useTranslation('global');
1044
3856
  const MySwal = withReactContent(SweetAlert2);
@@ -1050,16 +3862,19 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1050
3862
  const [error, setError] = React.useState(false);
1051
3863
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
1052
3864
  const sessionID = authStorage.getSessionId(configLogs) || '';
3865
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1053
3866
  const iditem = id;
1054
3867
  const authorization = true;
1055
3868
  const updateDataUser = async visitorIdHash => {
1056
3869
  const getProfile = Url + 'getprofile';
1057
3870
  try {
1058
3871
  const response = await axios.get(getProfile, {
3872
+ withCredentials: true,
1059
3873
  headers: {
1060
3874
  Authorization: `Bearer ${cxauthxc}`,
1061
3875
  'X-Session-ID': sessionID,
1062
3876
  'X-Fingerprint': visitorIdHash,
3877
+ 'X-Session-Type': xSessionType,
1063
3878
  'Content-Type': 'application/json'
1064
3879
  }
1065
3880
  });
@@ -1205,6 +4020,7 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1205
4020
  Authorization: `Bearer ${cxauthxc}`,
1206
4021
  'X-Session-ID': sessionID,
1207
4022
  'X-Fingerprint': fpHash,
4023
+ 'X-Session-Type': xSessionType,
1208
4024
  'Content-Type': 'application/json'
1209
4025
  }
1210
4026
  }), [cxauthxc, sessionID, fpHash]);
@@ -1217,7 +4033,7 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1217
4033
  React.useEffect(() => {
1218
4034
  const setFp = async () => {
1219
4035
  setCheckdata(false);
1220
- if (id !== '') {
4036
+ if (id !== '' || allowEmptyIdFetch) {
1221
4037
  const visitorIdHash = await getOrSetFingerprint(fpHash, configLogs);
1222
4038
  const key = {
1223
4039
  sessionID: sessionID,
@@ -1227,11 +4043,21 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1227
4043
  try {
1228
4044
  let response;
1229
4045
  if (fetchMethod === 'get') {
1230
- const url = getServerURL + id;
1231
- response = await axios.get(url, config);
4046
+ const url = id !== '' ? getServerURL + id : getServerURL;
4047
+ response = await axios.get(url, {
4048
+ ...config,
4049
+ withCredentials: true
4050
+ });
1232
4051
  logConsole(configLogs, 'info', '[Request] ', url);
1233
4052
  } else {
1234
- response = await axios.post(getServerURL, key, config);
4053
+ response = await axios.post(getServerURL, key, {
4054
+ ...config,
4055
+ withCredentials: true,
4056
+ headers: {
4057
+ ...(config?.headers || {}),
4058
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
4059
+ }
4060
+ });
1235
4061
  logConsole(configLogs, 'info', '[Request] ', getServerURL);
1236
4062
  }
1237
4063
  const responseData = response.data;
@@ -1247,7 +4073,7 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1247
4073
  }
1248
4074
  };
1249
4075
  setFp();
1250
- }, [id]);
4076
+ }, [id, allowEmptyIdFetch]);
1251
4077
  return {
1252
4078
  handleFormSubmit,
1253
4079
  handleInputChange,
@@ -1276,17 +4102,20 @@ function AppFormFields({
1276
4102
  permission,
1277
4103
  show,
1278
4104
  feedback,
1279
- method = 'post'
4105
+ method = 'post',
4106
+ allowEmptyIdFetch = false
1280
4107
  }) {
1281
4108
  const configLogs = useConexysConfig();
1282
4109
  const [t] = reactI18next.useTranslation('global');
1283
4110
  const authTokens = authStorage.getAuthToken(configLogs) || '';
1284
4111
  const authTokensSes = authStorage.getSessionId(configLogs) || '';
4112
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1285
4113
  const config = React.useMemo(() => ({
1286
4114
  headers: {
1287
4115
  Authorization: `Bearer ${authTokens}`,
1288
4116
  'X-Session-ID': authTokensSes,
1289
4117
  'X-Fingerprint': fpHash,
4118
+ 'X-Session-Type': xSessionType,
1290
4119
  'Content-Type': 'application/json'
1291
4120
  }
1292
4121
  }), [authTokens, authTokensSes, fpHash]);
@@ -1313,7 +4142,7 @@ function AppFormFields({
1313
4142
  formInputs,
1314
4143
  handleInputChange,
1315
4144
  handleFormSubmit
1316
- } = useCustomForm$3(fpHash, postServerURL1, getServerURL1, deleteServerURL1, id1, '', feedback, method, 'post', 'get');
4145
+ } = useCustomForm$3(fpHash, postServerURL1, getServerURL1, deleteServerURL1, id1, '', feedback, method, 'post', 'get', allowEmptyIdFetch);
1317
4146
  if (!post) return null;
1318
4147
  const dataform = JSON.parse(post.data);
1319
4148
  let permissionstatus;
@@ -1476,6 +4305,7 @@ const useCustomForm$2 = (postServerURL, setAuth, message, dependencies = {}) =>
1476
4305
  const {
1477
4306
  setAuthTokens
1478
4307
  } = typeof externalUseAuth === 'function' ? externalUseAuth() : externalUseAuth || useAuth();
4308
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1479
4309
  const [t] = reactI18next.useTranslation('global');
1480
4310
  const MySwal = withReactContent(SweetAlert2);
1481
4311
  const [formInputs, setFormInputs] = React.useState({});
@@ -1532,11 +4362,14 @@ const useCustomForm$2 = (postServerURL, setAuth, message, dependencies = {}) =>
1532
4362
  try {
1533
4363
  const postServerURL2 = Url + 'authTwostep';
1534
4364
  const config = {
4365
+ withCredentials: true,
1535
4366
  headers: {
1536
4367
  Authorization: `Bearer ${dataform.auth}`,
1537
4368
  'X-Session-ID': dataform.sessionid,
1538
4369
  'X-Fingerprint': dataform.fingerprint || visitorId,
1539
- 'Content-Type': 'application/json'
4370
+ 'X-Session-Type': xSessionType,
4371
+ 'Content-Type': 'application/json',
4372
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
1540
4373
  }
1541
4374
  };
1542
4375
  const dataload = [dataform, visitorId, login];
@@ -1652,11 +4485,17 @@ const getServiceBasic = async (fpHash = '', sessionID, baseURL, config, setData,
1652
4485
  sessionID,
1653
4486
  fingerprint: visitorIdHash
1654
4487
  };
4488
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1655
4489
  logConsole(configLogs, 'debug', '[Params] ', key);
1656
4490
  try {
1657
4491
  const response = await axios.get(baseURL, {
1658
4492
  ...config,
1659
- params: key
4493
+ withCredentials: true,
4494
+ params: key,
4495
+ headers: {
4496
+ ...(config?.headers || {}),
4497
+ 'X-Session-Type': xSessionType
4498
+ }
1660
4499
  });
1661
4500
  logConsole(configLogs, 'info', '[Request] ', baseURL);
1662
4501
  logConsole(configLogs, 'data', '', response.data);
@@ -1696,7 +4535,12 @@ const getServiceData = async (baseURL, params, config, setData, configLogs) => {
1696
4535
  try {
1697
4536
  const response = await axios.get(baseURL, {
1698
4537
  ...config,
1699
- params
4538
+ withCredentials: true,
4539
+ params,
4540
+ headers: {
4541
+ ...(config?.headers || {}),
4542
+ 'X-Session-Type': authStorage.getSessionTypeValue(configLogs)
4543
+ }
1700
4544
  });
1701
4545
  logConsole(configLogs, 'debug', '[Params] ', params);
1702
4546
  logConsole(configLogs, 'info', '[Request] ', baseURL);
@@ -1726,11 +4570,13 @@ function AppFormFieldsNoUser({
1726
4570
  const [fingerprint, setFingerprint] = React.useState('');
1727
4571
  const authTokens = authStorage.getAuthToken(configLogs) || '';
1728
4572
  const authTokensSes = authStorage.getSessionId(configLogs) || '';
4573
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1729
4574
  const config = React.useMemo(() => ({
1730
4575
  headers: {
1731
4576
  Authorization: `Bearer ${authTokens}`,
1732
4577
  'X-Session-ID': authTokensSes,
1733
4578
  'X-Fingerprint': fingerprint,
4579
+ 'X-Session-Type': xSessionType,
1734
4580
  'Content-Type': 'application/json'
1735
4581
  }
1736
4582
  }), [authTokens, authTokensSes, fingerprint]);
@@ -1844,11 +4690,13 @@ function AppFormFieldsTable({
1844
4690
  const [t] = reactI18next.useTranslation('global');
1845
4691
  const authTokens = authStorage.getAuthToken(configLogs) || '';
1846
4692
  const authTokensSes = authStorage.getSessionId(configLogs) || '';
4693
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1847
4694
  React.useMemo(() => ({
1848
4695
  headers: {
1849
4696
  Authorization: `Bearer ${authTokens}`,
1850
4697
  'X-Session-ID': authTokensSes,
1851
4698
  'X-Fingerprint': fpHash,
4699
+ 'X-Session-Type': xSessionType,
1852
4700
  'Content-Type': 'application/json'
1853
4701
  }
1854
4702
  }), [authTokens, authTokensSes, fpHash]);
@@ -1972,7 +4820,9 @@ function AppFormFieldsTable({
1972
4820
  maxLength: block.maxlength || block.validate && block.validate.maxLength,
1973
4821
  pattern: block.pattern || block.validate && block.validate.pattern
1974
4822
  },
1975
- items: block.items || []
4823
+ items: block.items || [],
4824
+ itemID: id1,
4825
+ adminCheck: show === 'admin'
1976
4826
  }, nouser || '')), additionalfields1.content.body.map(block => RenderForm({
1977
4827
  component: block.component,
1978
4828
  type: block.type,
@@ -2001,7 +4851,9 @@ function AppFormFieldsTable({
2001
4851
  maxLength: block.maxlength || block.validate && block.validate.maxLength,
2002
4852
  pattern: block.pattern || block.validate && block.validate.pattern
2003
4853
  },
2004
- items: block.items || []
4854
+ items: block.items || [],
4855
+ itemID: id1,
4856
+ adminCheck: show === 'admin'
2005
4857
  }, nouser || '')));
2006
4858
  }
2007
4859
 
@@ -5820,11 +8672,9 @@ function GenIcon(data) {
5820
8672
  }
5821
8673
  function IconBase(props) {
5822
8674
  var elem = conf => {
5823
- var {
5824
- attr,
5825
- size,
5826
- title
5827
- } = props,
8675
+ var attr = props.attr,
8676
+ size = props.size,
8677
+ title = props.title,
5828
8678
  svgProps = _objectWithoutProperties(props, _excluded);
5829
8679
  var computedSize = size || conf.size || "1em";
5830
8680
  var className;
@@ -6168,6 +9018,9 @@ function Mailbox({
6168
9018
  theObj,
6169
9019
  t
6170
9020
  }) {
9021
+ const safeObj = {
9022
+ __html: sanitizeHtml(theObj.__html)
9023
+ };
6171
9024
  return /*#__PURE__*/React.createElement("div", {
6172
9025
  className: "mailbox-email",
6173
9026
  style: {
@@ -6194,7 +9047,7 @@ function Mailbox({
6194
9047
  }), ' ', msgTarget)), /*#__PURE__*/React.createElement("div", {
6195
9048
  className: "card-body"
6196
9049
  }, /*#__PURE__*/React.createElement("div", {
6197
- dangerouslySetInnerHTML: theObj
9050
+ dangerouslySetInnerHTML: safeObj
6198
9051
  })), /*#__PURE__*/React.createElement("div", {
6199
9052
  className: "card-footer"
6200
9053
  }, /*#__PURE__*/React.createElement("p", {
@@ -6246,7 +9099,7 @@ function MailTemplateWidget({
6246
9099
  setIsError(false);
6247
9100
  }, []);
6248
9101
  const theObj = {
6249
- __html: getthemedata.html || ''
9102
+ __html: sanitizeHtml(getthemedata.html) || ''
6250
9103
  };
6251
9104
  logConsole(configLogs, 'data', '', getthemedata);
6252
9105
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
@@ -6785,7 +9638,7 @@ function UserWidget({
6785
9638
  setIsError(false);
6786
9639
  };
6787
9640
  const theObj = {
6788
- __html: datauserdata.biography || ''
9641
+ __html: sanitizeHtml(datauserdata.biography) || ''
6789
9642
  };
6790
9643
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
6791
9644
  error: error,
@@ -6802,7 +9655,7 @@ function UserWidget({
6802
9655
  className: "solid short"
6803
9656
  }), /*#__PURE__*/React.createElement("ul", {
6804
9657
  className: "simple-todo-list mt-3"
6805
- }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.username')), ": ", datauserdata.username), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.email')), ": ", datauserdata.email), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.name')), ": ", datauserdata.name), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.lastname')), ": ", datauserdata.lastname), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('User.type_of_user')), ": ", datausertype)))), /*#__PURE__*/React.createElement(Snackbar, {
9658
+ }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.username')), ": ", datauserdata.username), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.name')), ": ", datauserdata.name), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('login.lastname')), ": ", datauserdata.lastname), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("b", null, t('User.type_of_user')), ": ", datausertype)))), /*#__PURE__*/React.createElement(Snackbar, {
6806
9659
  open: isError,
6807
9660
  autoHideDuration: 6000,
6808
9661
  onClose: handleClose,
@@ -6837,16 +9690,32 @@ const AppHeaderPage = ({
6837
9690
  const [color, setColor] = React.useState('');
6838
9691
  const [getfavorites, setFavoritesList] = React.useState('');
6839
9692
  const hasFetched = React.useRef(false);
6840
- const cxauthxc = authStorage.getAuthToken(configLogs) || '';
6841
- const sessionID = authStorage.getSessionId(configLogs) || '';
9693
+ const [token, setToken] = React.useState('');
9694
+ const [sessionId, setSessionId] = React.useState('');
9695
+ const [authReady, setAuthReady] = React.useState(false);
9696
+ React.useEffect(() => {
9697
+ let cancelled = false;
9698
+ authStorage.initialize(configLogs).then(() => {
9699
+ if (cancelled) return;
9700
+ setToken(authStorage.getAuthToken(configLogs) || '');
9701
+ setSessionId(authStorage.getSessionId(configLogs) || '');
9702
+ setAuthReady(true);
9703
+ });
9704
+ return () => {
9705
+ cancelled = true;
9706
+ };
9707
+ }, []);
9708
+ const cxauthxc = token;
9709
+ const sessionID = sessionId;
6842
9710
  const hash = window.location.pathname;
6843
9711
  React.useEffect(() => {
9712
+ if (!authReady) return;
6844
9713
  if (hasFetched.current) return;
6845
9714
  hasFetched.current = true;
6846
9715
  serviceFavorites('get', fpHash, sessionID, 'getfavorites', cxauthxc, t, setFavoritesList, setIsError, setError, setMessageerror, setLoading, setColor, configLogs, {
6847
9716
  url: hash
6848
9717
  });
6849
- }, []);
9718
+ }, [authReady, fpHash, sessionID, cxauthxc, t, hash, configLogs]);
6850
9719
  const handleClickMenuRigth = React.useCallback(() => {
6851
9720
  setOpenMenuRigth(prev => !prev);
6852
9721
  const themeElement = document.getElementById('themeclass');
@@ -7703,7 +10572,7 @@ const Info = ({
7703
10572
  texthtml
7704
10573
  } = block;
7705
10574
  const theObj = {
7706
- __html: texthtml
10575
+ __html: sanitizeHtml(texthtml)
7707
10576
  };
7708
10577
  return /*#__PURE__*/React.createElement("div", {
7709
10578
  className: ref
@@ -7719,9 +10588,9 @@ const Info = ({
7719
10588
 
7720
10589
  // THIS FILE IS AUTO GENERATED
7721
10590
  function MdCloudUpload (props) {
7722
- return GenIcon({"attr":{"viewBox":"0 0 24 24"},"child":[{"tag":"path","attr":{"fill":"none","d":"M0 0h24v24H0z"},"child":[]},{"tag":"path","attr":{"d":"M19.35 10.04A7.49 7.49 0 0 0 12 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 0 0 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"},"child":[]}]})(props);
10591
+ return GenIcon({"attr":{"viewBox":"0 0 24 24"},"child":[{"tag":"path","attr":{"fill":"none","d":"M0 0h24v24H0z"},"child":[]},{"tag":"path","attr":{"d":"M19.35 10.04A7.49 7.49 0 0 0 12 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 0 0 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5 5 5z"},"child":[]}]})(props);
7723
10592
  }function MdDelete (props) {
7724
- return GenIcon({"attr":{"viewBox":"0 0 24 24"},"child":[{"tag":"path","attr":{"fill":"none","d":"M0 0h24v24H0z"},"child":[]},{"tag":"path","attr":{"d":"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"},"child":[]}]})(props);
10593
+ return GenIcon({"attr":{"viewBox":"0 0 24 24"},"child":[{"tag":"path","attr":{"fill":"none","d":"M0 0h24v24H0z"},"child":[]},{"tag":"path","attr":{"d":"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"},"child":[]}]})(props);
7725
10594
  }
7726
10595
 
7727
10596
  // THIS FILE IS AUTO GENERATED
@@ -8033,6 +10902,8 @@ const InputPassword = ({
8033
10902
 
8034
10903
  const postURLusername = Url + 'checkusername';
8035
10904
  const postURLmail = Url + 'checkmail';
10905
+ const postURLAdminUsername = Url + 'admincheckusername';
10906
+ const postURLAdminMail = Url + 'admincheckmail';
8036
10907
  const config$1 = {
8037
10908
  headers: {
8038
10909
  'Content-Type': 'application/json'
@@ -8050,7 +10921,14 @@ const checkExistsUsername = async ({
8050
10921
  try {
8051
10922
  const {
8052
10923
  data
8053
- } = await axios.post(postURLusername, requestData, config$1);
10924
+ } = await axios.post(postURLusername, requestData, {
10925
+ ...config$1,
10926
+ withCredentials: true,
10927
+ headers: {
10928
+ ...(config$1?.headers || {}),
10929
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
10930
+ }
10931
+ });
8054
10932
  logConsole(configLogs, 'info', '[Request] ', postURLusername);
8055
10933
  logConsole(configLogs, 'data', '', data.result);
8056
10934
  return data.result === 'Valid';
@@ -8072,7 +10950,14 @@ const checkExistsMail = async ({
8072
10950
  try {
8073
10951
  const {
8074
10952
  data
8075
- } = await axios.post(postURLmail, requestData, config$1);
10953
+ } = await axios.post(postURLmail, requestData, {
10954
+ ...config$1,
10955
+ withCredentials: true,
10956
+ headers: {
10957
+ ...(config$1?.headers || {}),
10958
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
10959
+ }
10960
+ });
8076
10961
  logConsole(configLogs, 'info', '[Request] ', postURLmail);
8077
10962
  logConsole(configLogs, 'data', '', data.result);
8078
10963
  return data.result === 'Valid';
@@ -8082,6 +10967,70 @@ const checkExistsMail = async ({
8082
10967
  return false;
8083
10968
  }
8084
10969
  };
10970
+ const checkExistsUsernameAdmin = async ({
10971
+ username,
10972
+ itemID
10973
+ }, configLogs) => {
10974
+ const requestData = {
10975
+ username,
10976
+ itemID
10977
+ };
10978
+ logConsole(configLogs, 'debug', '[Payload admincheckusername] ', requestData);
10979
+ try {
10980
+ const {
10981
+ data
10982
+ } = await axios.post(postURLAdminUsername, requestData, {
10983
+ ...config$1,
10984
+ withCredentials: true,
10985
+ headers: {
10986
+ ...(config$1?.headers || {}),
10987
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
10988
+ }
10989
+ });
10990
+ logConsole(configLogs, 'info', '[Request] ', postURLAdminUsername);
10991
+ logConsole(configLogs, 'data', '', data);
10992
+ return data;
10993
+ } catch (err) {
10994
+ logConsole(configLogs, 'error', '', err);
10995
+ console.error(err);
10996
+ return {
10997
+ available: false,
10998
+ isCurrent: false
10999
+ };
11000
+ }
11001
+ };
11002
+ const checkExistsMailAdmin = async ({
11003
+ email,
11004
+ itemID
11005
+ }, configLogs) => {
11006
+ const requestData = {
11007
+ email,
11008
+ itemID
11009
+ };
11010
+ logConsole(configLogs, 'debug', '[Payload admincheckmail] ', requestData);
11011
+ try {
11012
+ const {
11013
+ data
11014
+ } = await axios.post(postURLAdminMail, requestData, {
11015
+ ...config$1,
11016
+ withCredentials: true,
11017
+ headers: {
11018
+ ...(config$1?.headers || {}),
11019
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
11020
+ }
11021
+ });
11022
+ logConsole(configLogs, 'info', '[Request] ', postURLAdminMail);
11023
+ logConsole(configLogs, 'data', '', data);
11024
+ return data;
11025
+ } catch (err) {
11026
+ logConsole(configLogs, 'error', '', err);
11027
+ console.error(err);
11028
+ return {
11029
+ available: false,
11030
+ isCurrent: false
11031
+ };
11032
+ }
11033
+ };
8085
11034
 
8086
11035
  const InputText = /*#__PURE__*/React.memo(({
8087
11036
  block
@@ -8091,7 +11040,7 @@ const InputText = /*#__PURE__*/React.memo(({
8091
11040
  const [errors, setError] = React.useState(false);
8092
11041
  const [texterror, setTextError] = React.useState('');
8093
11042
  const handleInputBlur = React.useCallback(async event => {
8094
- const session = localStorage.getItem('cx_session') || '';
11043
+ const session = authStorage.getSessionId(configLogs) || '';
8095
11044
  const value = event.target.value;
8096
11045
  const setErrorState = (error, message) => {
8097
11046
  setError(error);
@@ -8100,22 +11049,44 @@ const InputText = /*#__PURE__*/React.memo(({
8100
11049
  };
8101
11050
  try {
8102
11051
  if (block.validate.check === 'email' && value) {
8103
- const mailexist = await checkExistsMail({
8104
- email: value,
8105
- sessionID: session
8106
- }, configLogs);
8107
- if (!mailexist) {
8108
- setErrorState(true, t('error.email_already_exists'));
8109
- return;
11052
+ if (block.adminCheck) {
11053
+ const mailAdmin = await checkExistsMailAdmin({
11054
+ email: value,
11055
+ itemID: block.itemID
11056
+ }, configLogs);
11057
+ if (!mailAdmin.available && !mailAdmin.isCurrent) {
11058
+ setErrorState(true, t('error.email_already_exists'));
11059
+ return;
11060
+ }
11061
+ } else {
11062
+ const mailexist = await checkExistsMail({
11063
+ email: value,
11064
+ sessionID: session
11065
+ }, configLogs);
11066
+ if (!mailexist) {
11067
+ setErrorState(true, t('error.email_already_exists'));
11068
+ return;
11069
+ }
8110
11070
  }
8111
11071
  } else if (block.validate.check === 'username' && value) {
8112
- const usernameExist = await checkExistsUsername({
8113
- username: value,
8114
- sessionID: session
8115
- }, configLogs);
8116
- if (!usernameExist) {
8117
- setErrorState(true, t('error.username_is_not_valid'));
8118
- return;
11072
+ if (block.adminCheck) {
11073
+ const usernameAdmin = await checkExistsUsernameAdmin({
11074
+ username: value,
11075
+ itemID: block.itemID
11076
+ }, configLogs);
11077
+ if (!usernameAdmin.available && !usernameAdmin.isCurrent) {
11078
+ setErrorState(true, t('error.username_already_exists'));
11079
+ return;
11080
+ }
11081
+ } else {
11082
+ const usernameExist = await checkExistsUsername({
11083
+ username: value,
11084
+ sessionID: session
11085
+ }, configLogs);
11086
+ if (!usernameExist) {
11087
+ setErrorState(true, t('error.username_is_not_valid'));
11088
+ return;
11089
+ }
8119
11090
  }
8120
11091
  }
8121
11092
  if (block.validate.minLength && value.length < block.validate.minLength) {
@@ -8214,6 +11185,8 @@ const InputWYSIWYG = /*#__PURE__*/React.memo(({
8214
11185
  const editor = React.useRef(null);
8215
11186
  const config = React.useMemo(() => ({
8216
11187
  readonly: false,
11188
+ toolbarAdaptive: false,
11189
+ allowTags: ['p', 'br', 'b', 'strong', 'i', 'em', 'u', 's', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'code', 'pre', 'a', 'img', 'hr', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'div', 'span'],
8217
11190
  placeholder: textEditor && textEditor !== '<p><br></p>' || block.value && block.value !== '<p><br></p>' ? '' : t('general.start_typings') || 'Start typings...',
8218
11191
  language: t('language.name')
8219
11192
  }), [t, textEditor, block.value]);
@@ -8647,7 +11620,10 @@ const LanguageSet = () => {
8647
11620
  hasFetched.current = true;
8648
11621
  const fetchLanguages = async () => {
8649
11622
  try {
8650
- const response = await axios.get(postURL, config);
11623
+ const response = await axios.get(postURL, {
11624
+ ...config,
11625
+ withCredentials: true
11626
+ });
8651
11627
  logConsole(configLogs, 'info', '[Request] ', postURL);
8652
11628
  const langData = Array.isArray(response.data) ? {
8653
11629
  data: response.data
@@ -9710,19 +12686,25 @@ const postFormServiceGetPost = async (datauser, configLogs) => {
9710
12686
  formData.append('iditem', iditem);
9711
12687
  formData.append('sessionID', sessionID);
9712
12688
  formData.append('fingerprint', fingerprint);
12689
+ const xSessionType = authStorage.getSessionTypeValue(configLogs || defaultConfig);
9713
12690
  let config;
9714
12691
  if (authorization === true) {
9715
12692
  config = {
12693
+ withCredentials: true,
9716
12694
  headers: {
9717
12695
  Authorization: `Bearer ${cxauthxc}`,
12696
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
9718
12697
  'X-Session-ID': sessionID,
9719
12698
  'X-Fingerprint': fingerprint,
12699
+ 'X-Session-Type': xSessionType,
9720
12700
  'Content-Type': 'multipart/form-data'
9721
12701
  }
9722
12702
  };
9723
12703
  } else {
9724
12704
  config = {
12705
+ withCredentials: true,
9725
12706
  headers: {
12707
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
9726
12708
  'Content-Type': 'multipart/form-data'
9727
12709
  }
9728
12710
  };
@@ -9758,6 +12740,7 @@ const useCustomForm$1 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
9758
12740
  const [error, setError] = React.useState(false);
9759
12741
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
9760
12742
  const sessionID = authStorage.getSessionId(configLogs) || '';
12743
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
9761
12744
  const iditem = id;
9762
12745
  const authorization = true;
9763
12746
  const handleFormSubmit = async event => {
@@ -9879,6 +12862,7 @@ const useCustomForm$1 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
9879
12862
  Authorization: `Bearer ${cxauthxc}`,
9880
12863
  'X-Session-ID': sessionID,
9881
12864
  'X-Fingerprint': fpHash,
12865
+ 'X-Session-Type': xSessionType,
9882
12866
  'Content-Type': 'application/json'
9883
12867
  }
9884
12868
  }), [cxauthxc, sessionID, fpHash]);
@@ -9895,6 +12879,7 @@ const useCustomForm$1 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
9895
12879
  await getOrSetFingerprint(fpHash, configLogs);
9896
12880
  try {
9897
12881
  const response = await axios.get(getServerURL, {
12882
+ withCredentials: true,
9898
12883
  headers: config.headers,
9899
12884
  params: {
9900
12885
  itemID: id
@@ -10155,8 +13140,8 @@ const initializeSharedServices = () => {
10155
13140
  },
10156
13141
  getAuthData: () => {
10157
13142
  return {
10158
- sessionID: localStorage.getItem('cx_session'),
10159
- authToken: localStorage.getItem('cxauthxc')
13143
+ sessionID: authStorage.getSessionId(configLogs),
13144
+ authToken: authStorage.getAuthToken(configLogs)
10160
13145
  };
10161
13146
  }
10162
13147
  };
@@ -10187,19 +13172,25 @@ const patchservice = async (datauser, configLogs) => {
10187
13172
  cxauthxc,
10188
13173
  ...requestData
10189
13174
  } = datauser;
13175
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
10190
13176
  let config;
10191
13177
  if (authorization === true || authorization === 'true') {
10192
13178
  config = {
13179
+ withCredentials: true,
10193
13180
  headers: {
10194
13181
  Authorization: `Bearer ${cxauthxc}`,
13182
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
10195
13183
  'X-Session-ID': datauser.sessionID || '',
10196
13184
  'X-Fingerprint': datauser.fingerprint || '',
13185
+ 'X-Session-Type': xSessionType,
10197
13186
  'Content-Type': 'application/json'
10198
13187
  }
10199
13188
  };
10200
13189
  } else {
10201
13190
  config = {
13191
+ withCredentials: true,
10202
13192
  headers: {
13193
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
10203
13194
  'Content-Type': 'application/json'
10204
13195
  }
10205
13196
  };
@@ -10310,9 +13301,8 @@ const serviceDelete2 = async (fpHash = '', sessionID, deleteURL, cxauthxc, t, se
10310
13301
  };
10311
13302
 
10312
13303
  const checkAuth = configLogs => {
10313
- const cxauthxc = authStorage.getAuthToken(configLogs) || '';
10314
- const sessionID = authStorage.getSessionId(configLogs) || '';
10315
- if (cxauthxc === '' || sessionID === '' || cxauthxc === null || sessionID === null) {
13304
+ const hasSession = authStorage.hasActiveSession(configLogs);
13305
+ if (!hasSession) {
10316
13306
  localStorage.removeItem('datauser');
10317
13307
  localStorage.removeItem('sidebarleft');
10318
13308
  localStorage.removeItem('cxl0k2mw');
@@ -10353,6 +13343,7 @@ const useCustomForm = (fpHash, getServerURL, postServerURL, feedback, id, reset
10353
13343
  const [error, setError] = React.useState(false);
10354
13344
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
10355
13345
  const sessionID = authStorage.getSessionId(configLogs) || '';
13346
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
10356
13347
  const authorization = true;
10357
13348
  const handleFormSubmit = async event => {
10358
13349
  const visitorIdHash = await getOrSetFingerprint(fpHash, configLogs);
@@ -10449,6 +13440,7 @@ const useCustomForm = (fpHash, getServerURL, postServerURL, feedback, id, reset
10449
13440
  Authorization: `Bearer ${cxauthxc}`,
10450
13441
  'X-Session-ID': sessionID,
10451
13442
  'X-Fingerprint': fpHash,
13443
+ 'X-Session-Type': xSessionType,
10452
13444
  'Content-Type': 'application/json'
10453
13445
  }
10454
13446
  }), [cxauthxc, sessionID, fpHash]);
@@ -10461,7 +13453,14 @@ const useCustomForm = (fpHash, getServerURL, postServerURL, feedback, id, reset
10461
13453
  fingerprint: visitorIdHash
10462
13454
  };
10463
13455
  try {
10464
- const response = await axios.post(getServerURL, key, config);
13456
+ const response = await axios.post(getServerURL, key, {
13457
+ ...config,
13458
+ withCredentials: true,
13459
+ headers: {
13460
+ ...(config?.headers || {}),
13461
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
13462
+ }
13463
+ });
10465
13464
  logConsole(configLogs, 'info', '[Request] ', getServerURL);
10466
13465
  const responseData = response.data;
10467
13466
  const formData = Array.isArray(responseData) ? responseData[0] : typeof responseData?.data === 'object' && responseData.data !== null ? Array.isArray(responseData.data) ? responseData.data[0] : responseData.data : responseData;
@@ -10496,6 +13495,7 @@ const useCustomFormPatch = (fpHash, getServerURL, patchServerURL, feedback, id,
10496
13495
  const [error, setError] = React.useState(false);
10497
13496
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
10498
13497
  const sessionID = authStorage.getSessionId(configLogs) || '';
13498
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
10499
13499
  const authorization = true;
10500
13500
  const handleFormSubmit = async event => {
10501
13501
  const visitorIdHash = await getOrSetFingerprint(fpHash, configLogs);
@@ -10592,6 +13592,7 @@ const useCustomFormPatch = (fpHash, getServerURL, patchServerURL, feedback, id,
10592
13592
  Authorization: `Bearer ${cxauthxc}`,
10593
13593
  'X-Session-ID': sessionID,
10594
13594
  'X-Fingerprint': fpHash,
13595
+ 'X-Session-Type': xSessionType,
10595
13596
  'Content-Type': 'application/json'
10596
13597
  }
10597
13598
  }), [cxauthxc, sessionID, fpHash]);
@@ -10604,7 +13605,14 @@ const useCustomFormPatch = (fpHash, getServerURL, patchServerURL, feedback, id,
10604
13605
  fingerprint: visitorIdHash
10605
13606
  };
10606
13607
  try {
10607
- const response = await axios.post(getServerURL, key, config);
13608
+ const response = await axios.post(getServerURL, key, {
13609
+ ...config,
13610
+ withCredentials: true,
13611
+ headers: {
13612
+ ...(config?.headers || {}),
13613
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
13614
+ }
13615
+ });
10608
13616
  logConsole(configLogs, 'info', '[Request] ', getServerURL);
10609
13617
  const responseData = response.data;
10610
13618
  const formData = Array.isArray(responseData) ? responseData[0] : typeof responseData?.data === 'object' && responseData.data !== null ? Array.isArray(responseData.data) ? responseData.data[0] : responseData.data : responseData;
@@ -10712,7 +13720,7 @@ const useZoomPrevention = () => {
10712
13720
  };
10713
13721
 
10714
13722
  const getWsBaseUrl = () => {
10715
- const restApi = window.restAPI || 'http://localhost:3001/restapi/';
13723
+ const restApi = Url || 'http://localhost:3001/restapi/';
10716
13724
  return restApi.replace(/\/restapi\/?$/, '');
10717
13725
  };
10718
13726
  const useSocket = () => {
@@ -10729,12 +13737,16 @@ const useSocket = () => {
10729
13737
  logConsole(configLogs, 'warn', '[WS] ', 'No hay token, no se conecta WebSocket');
10730
13738
  return;
10731
13739
  }
13740
+ const isCookieMode = authStorage.getSessionTypeValue(configLogs) === 'cookie';
10732
13741
  const wsUrl = getWsBaseUrl();
10733
13742
  logConsole(configLogs, 'info', '[WS] ', `Conectando a ${wsUrl}...`);
10734
13743
  const socket = socket_ioClient.io(wsUrl, {
10735
- auth: {
10736
- token
10737
- },
13744
+ ...(isCookieMode ? {} : {
13745
+ auth: {
13746
+ token
13747
+ }
13748
+ }),
13749
+ withCredentials: true,
10738
13750
  transports: ['websocket', 'polling'],
10739
13751
  reconnection: true,
10740
13752
  reconnectionAttempts: Infinity,
@@ -10997,6 +14009,7 @@ exports.patchFormService = patchFormService$1;
10997
14009
  exports.patchservice = patchservice;
10998
14010
  exports.postFormService = postFormService$1;
10999
14011
  exports.postservice = postservice;
14012
+ exports.sanitizeHtml = sanitizeHtml;
11000
14013
  exports.serviceData = serviceData;
11001
14014
  exports.serviceDelete2 = serviceDelete2;
11002
14015
  exports.serviceFavorites = serviceFavorites;