conexys-elements 1.1.3 → 1.1.26

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 +1 -1
  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 +1 -1
  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 +1 -1
  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 +3394 -293
  137. package/dist/index.esm.js.map +1 -1
  138. package/dist/index.js +3394 -292
  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 +0 -0
  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 +2 -0
  195. package/dist/types/components/appFormFields.types.d.ts.map +1 -1
  196. package/dist/types/components/appFormFieldsFromConfig.types.d.ts +1 -0
  197. package/dist/types/components/appFormFieldsFromConfig.types.d.ts.map +1 -1
  198. package/dist/types/components/appFormFieldsNoUser.types.d.ts +1 -0
  199. package/dist/types/components/appFormFieldsNoUser.types.d.ts.map +1 -1
  200. package/dist/types/components/appFormFieldsTable.types.d.ts +1 -0
  201. package/dist/types/components/appFormFieldsTable.types.d.ts.map +1 -1
  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 +20 -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
@@ -41,8 +41,11 @@ var Checkboxmui = require('@mui/material/Checkbox');
41
41
  var FormControlLabel = require('@mui/material/FormControlLabel');
42
42
  var reactHookForm = require('react-hook-form');
43
43
  var Button$3 = require('@mui/material/Button');
44
+ var Visibility = require('@mui/icons-material/Visibility');
45
+ var VisibilityOff = require('@mui/icons-material/VisibilityOff');
44
46
  var TextField = require('@mui/material/TextField');
45
47
  var InputLabel = require('@mui/material/InputLabel');
48
+ var InputAdornment = require('@mui/material/InputAdornment');
46
49
  var JoditEditor = require('jodit-react');
47
50
  var Radio = require('@mui/material/Radio');
48
51
  var RadioGroup = require('@mui/material/RadioGroup');
@@ -73,7 +76,30 @@ function _interopNamespaceDefault(e) {
73
76
 
74
77
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
75
78
 
76
- const Url = window.restAPI || '';
79
+ const REST_API_KEY = 'restAPI';
80
+ function resolveRestAPI() {
81
+ let value;
82
+ if (typeof window !== 'undefined') {
83
+ const existing = window[REST_API_KEY];
84
+ if (typeof existing === 'string' && existing.length > 0) {
85
+ value = existing;
86
+ } else {
87
+ value = '';
88
+ }
89
+ try {
90
+ Object.defineProperty(window, REST_API_KEY, {
91
+ value,
92
+ writable: false,
93
+ configurable: false,
94
+ enumerable: true
95
+ });
96
+ } catch {}
97
+ } else {
98
+ value = '';
99
+ }
100
+ return value;
101
+ }
102
+ const Url = resolveRestAPI();
77
103
 
78
104
  const logConsole = (configLogs, type, message, ...args) => {
79
105
  if (!configLogs) return;
@@ -116,6 +142,159 @@ const logConsole = (configLogs, type, message, ...args) => {
116
142
  }
117
143
  };
118
144
 
145
+ const config$4 = {
146
+ headers: {
147
+ 'Content-Type': 'application/json'
148
+ }
149
+ };
150
+ const TYPE_SESSION_CACHE_KEY = 'cx_type_session';
151
+ const COOKIE_AUTH_MARKER = 'cookie';
152
+ let USE_COOKIES_FOR_AUTH = false;
153
+ let SESSION_EXPIRATION = 365;
154
+ let isConfigInitialized = false;
155
+ let initPromise = null;
156
+ let isFetching = false;
157
+ const getCachedTypeSession = () => {
158
+ try {
159
+ return localStorage.getItem(TYPE_SESSION_CACHE_KEY);
160
+ } catch {
161
+ return null;
162
+ }
163
+ };
164
+ const resetAuthConfig = () => {
165
+ initPromise = null;
166
+ isConfigInitialized = false;
167
+ isFetching = false;
168
+ };
169
+ const setCachedTypeSession = value => {
170
+ try {
171
+ localStorage.setItem(TYPE_SESSION_CACHE_KEY, value);
172
+ } catch {}
173
+ };
174
+ const fetchTypeSession = async configLogs => {
175
+ const baseURL = Url + 'getsettings';
176
+ try {
177
+ await serviceData(baseURL, {
178
+ keys: 'type_session'
179
+ }, config$4, value => {
180
+ const resolved = value && typeof value === 'string' ? value : 'localstorage';
181
+ USE_COOKIES_FOR_AUTH = resolved === 'cookie';
182
+ setCachedTypeSession(resolved);
183
+ }, configLogs);
184
+ } catch (error) {
185
+ logConsole(configLogs, 'error', 'Error loading authentication configuration:', error);
186
+ }
187
+ };
188
+ const initializeAuthConfig = configLogs => {
189
+ if (isConfigInitialized) return Promise.resolve();
190
+ if (initPromise) return initPromise;
191
+ initPromise = (async () => {
192
+ if (isConfigInitialized) return;
193
+ const cached = getCachedTypeSession();
194
+ if (cached !== null) {
195
+ USE_COOKIES_FOR_AUTH = cached === 'cookie';
196
+ isConfigInitialized = true;
197
+ return;
198
+ }
199
+ if (isFetching) return;
200
+ isFetching = true;
201
+ try {
202
+ await fetchTypeSession(configLogs);
203
+ isConfigInitialized = true;
204
+ } finally {
205
+ isFetching = false;
206
+ initPromise = null;
207
+ }
208
+ })();
209
+ return initPromise;
210
+ };
211
+ const refreshTypeSessionFromDB = async configLogs => {
212
+ if (initPromise && !isFetching) {
213
+ await initPromise;
214
+ } else if (isFetching) {
215
+ if (initPromise) await initPromise;
216
+ }
217
+ if (isFetching) {
218
+ if (initPromise) await initPromise;
219
+ return;
220
+ }
221
+ isFetching = true;
222
+ initPromise = (async () => {
223
+ try {
224
+ await fetchTypeSession(configLogs);
225
+ isConfigInitialized = true;
226
+ } finally {
227
+ isFetching = false;
228
+ initPromise = null;
229
+ }
230
+ })();
231
+ await initPromise;
232
+ };
233
+ const authStorage = {
234
+ initialize(configLogs) {
235
+ return initializeAuthConfig(configLogs);
236
+ },
237
+ getSessionTypeValue(_configLogs) {
238
+ return 'cookie';
239
+ },
240
+ async setAuthToken(_token, _configLogs) {
241
+ localStorage.removeItem('cxauthxc');
242
+ this.deleteCookie('cxauthxc');
243
+ },
244
+ getAuthToken(_configLogs) {
245
+ return COOKIE_AUTH_MARKER;
246
+ },
247
+ hasActiveSession(_configLogs) {
248
+ const sessionId = this.getCookie('cx_session');
249
+ const csrfToken = this.getCookie('csrf_token');
250
+ return sessionId !== null && sessionId !== '' && csrfToken !== null && csrfToken !== '';
251
+ },
252
+ getCsrfToken() {
253
+ return this.getCookie('csrf_token');
254
+ },
255
+ async setSessionId(sessionId, _configLogs) {
256
+ this.setCookie('cx_session', sessionId, SESSION_EXPIRATION);
257
+ localStorage.removeItem('cx_session');
258
+ },
259
+ getSessionId(_configLogs) {
260
+ return this.getCookie('cx_session');
261
+ },
262
+ refreshTypeSession(configLogs) {
263
+ return refreshTypeSessionFromDB(configLogs);
264
+ },
265
+ async removeAuthData(configLogs) {
266
+ this.deleteCookie('cxauthxc');
267
+ this.deleteCookie('cx_session');
268
+ this.deleteCookie('csrf_token');
269
+ localStorage.removeItem('cxauthxc');
270
+ localStorage.removeItem('cx_session');
271
+ try {
272
+ localStorage.removeItem(TYPE_SESSION_CACHE_KEY);
273
+ } catch {}
274
+ resetAuthConfig();
275
+ },
276
+ setCookie(name, value, days) {
277
+ const date = new Date();
278
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
279
+ const expires = `expires=${date.toUTCString()}`;
280
+ const secure = window.location.protocol === 'https:' ? ';Secure' : '';
281
+ document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict${secure}`;
282
+ },
283
+ getCookie(name) {
284
+ const nameEQ = `${name}=`;
285
+ const ca = document.cookie.split(';');
286
+ for (let i = 0; i < ca.length; i++) {
287
+ let c = ca[i];
288
+ while (c.charAt(0) === ' ') c = c.substring(1, c.length);
289
+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
290
+ }
291
+ return null;
292
+ },
293
+ deleteCookie(name) {
294
+ document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;`;
295
+ }
296
+ };
297
+
119
298
  const postservice = async (datauser, configLogs) => {
120
299
  const postURL = Url + datauser.postServerURL;
121
300
  const {
@@ -124,19 +303,25 @@ const postservice = async (datauser, configLogs) => {
124
303
  cxauthxc,
125
304
  ...requestData
126
305
  } = datauser;
306
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
127
307
  let config;
128
308
  if (authorization === true || authorization === 'true') {
129
309
  config = {
310
+ withCredentials: true,
130
311
  headers: {
131
312
  Authorization: `Bearer ${cxauthxc}`,
313
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
132
314
  'X-Session-ID': datauser.sessionID || '',
133
315
  'X-Fingerprint': datauser.fingerprint || '',
316
+ 'X-Session-Type': xSessionType,
134
317
  'Content-Type': 'application/json'
135
318
  }
136
319
  };
137
320
  } else {
138
321
  config = {
322
+ withCredentials: true,
139
323
  headers: {
324
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
140
325
  'Content-Type': 'application/json'
141
326
  }
142
327
  };
@@ -164,22 +349,27 @@ const deleteservice = async (datauser, configLogs) => {
164
349
  cxauthxc,
165
350
  ...requestData
166
351
  } = datauser;
352
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
167
353
  let headers;
168
354
  if (authorization === true || authorization === 'true') {
169
355
  headers = {
170
356
  Authorization: `Bearer ${cxauthxc}`,
357
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
171
358
  'X-Session-ID': datauser.sessionID || '',
172
359
  'X-Fingerprint': datauser.fingerprint || '',
360
+ 'X-Session-Type': xSessionType,
173
361
  'Content-Type': 'application/json'
174
362
  };
175
363
  } else {
176
364
  headers = {
365
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
177
366
  'Content-Type': 'application/json'
178
367
  };
179
368
  }
180
369
  logConsole(configLogs, 'debug', '[Payload] ', requestData);
181
370
  try {
182
371
  const response = await axios.delete(deleteURL, {
372
+ withCredentials: true,
183
373
  headers,
184
374
  data: requestData
185
375
  });
@@ -194,6 +384,7 @@ const deleteservice = async (datauser, configLogs) => {
194
384
 
195
385
  const getservice = async (datauser, configLogs) => {
196
386
  const getURL = Url + datauser.postServerURL;
387
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
197
388
  const {
198
389
  authorization,
199
390
  postServerURL,
@@ -205,15 +396,18 @@ const getservice = async (datauser, configLogs) => {
205
396
  let config;
206
397
  if (authorization === true || authorization === 'true') {
207
398
  config = {
399
+ withCredentials: true,
208
400
  headers: {
209
401
  Authorization: `Bearer ${cxauthxc}`,
210
402
  'X-Session-ID': sessionID || '',
211
- 'X-Fingerprint': fingerprint || ''
403
+ 'X-Fingerprint': fingerprint || '',
404
+ 'X-Session-Type': xSessionType
212
405
  },
213
406
  params: requestData
214
407
  };
215
408
  } else {
216
409
  config = {
410
+ withCredentials: true,
217
411
  params: requestData
218
412
  };
219
413
  }
@@ -255,105 +449,6 @@ const getOrSetFingerprint = async (fpHash = '', configLogs) => {
255
449
  return await loadFingerprint(configLogs);
256
450
  };
257
451
 
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
- const local = localStorage.getItem('cxauthxc');
305
- if (local !== null) return local;
306
- return this.getCookie('cxauthxc');
307
- },
308
- setSessionId(sessionId, configLogs) {
309
- initializeAuthConfig(configLogs);
310
- if (USE_COOKIES_FOR_AUTH) {
311
- this.setCookie('cx_session', sessionId, SESSION_EXPIRATION);
312
- } else {
313
- localStorage.setItem('cx_session', sessionId);
314
- }
315
- },
316
- getSessionId(configLogs) {
317
- initializeAuthConfig(configLogs);
318
- if (USE_COOKIES_FOR_AUTH) {
319
- return this.getCookie('cx_session');
320
- }
321
- const local = localStorage.getItem('cx_session');
322
- if (local !== null) return local;
323
- return this.getCookie('cx_session');
324
- },
325
- removeAuthData(configLogs) {
326
- initializeAuthConfig(configLogs);
327
- if (USE_COOKIES_FOR_AUTH) {
328
- this.deleteCookie('cxauthxc');
329
- this.deleteCookie('cx_session');
330
- } else {
331
- localStorage.removeItem('cxauthxc');
332
- localStorage.removeItem('cx_session');
333
- }
334
- },
335
- setCookie(name, value, days) {
336
- const date = new Date();
337
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
338
- const expires = `expires=${date.toUTCString()}`;
339
- const secure = window.location.protocol === 'https:' ? ';Secure' : '';
340
- document.cookie = `${name}=${value};${expires};path=/;SameSite=Strict${secure}`;
341
- },
342
- getCookie(name) {
343
- const nameEQ = `${name}=`;
344
- const ca = document.cookie.split(';');
345
- for (let i = 0; i < ca.length; i++) {
346
- let c = ca[i];
347
- while (c.charAt(0) === ' ') c = c.substring(1, c.length);
348
- if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
349
- }
350
- return null;
351
- },
352
- deleteCookie(name) {
353
- document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;`;
354
- }
355
- };
356
-
357
452
  const handleError$3 = (err, t, configLogs, setIsError, setMessageerror) => {
358
453
  let errorMessage;
359
454
  if (!err?.response) {
@@ -381,7 +476,15 @@ const servicePostBasic = async (fpHash = '', sessionID, baseURL, config, setData
381
476
  };
382
477
  logConsole(configLogs, 'debug', '[Payload] ', key);
383
478
  try {
384
- const response = await axios.post(baseURL, key, config);
479
+ const response = await axios.post(baseURL, key, {
480
+ ...config,
481
+ withCredentials: true,
482
+ headers: {
483
+ ...(config?.headers || {}),
484
+ 'X-Session-Type': authStorage.getSessionTypeValue(configLogs),
485
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
486
+ }
487
+ });
385
488
  logConsole(configLogs, 'info', '[Request] ', baseURL);
386
489
  logConsole(configLogs, 'data', '', response.data);
387
490
  setData(response.data);
@@ -393,7 +496,15 @@ const servicePostBasic = async (fpHash = '', sessionID, baseURL, config, setData
393
496
  const serviceData = async (baseURL, key, config, setData, configLogs) => {
394
497
  logConsole(configLogs, 'debug', '[Payload] ', key);
395
498
  try {
396
- const response = await axios.post(baseURL, key, config);
499
+ const response = await axios.post(baseURL, key, {
500
+ ...config,
501
+ withCredentials: true,
502
+ headers: {
503
+ ...(config?.headers || {}),
504
+ 'X-Session-Type': authStorage.getSessionTypeValue(configLogs),
505
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
506
+ }
507
+ });
397
508
  logConsole(configLogs, 'info', '[Request] ', baseURL);
398
509
  logConsole(configLogs, 'data', '', response.data);
399
510
  const responseData = response.data;
@@ -431,7 +542,14 @@ const servicePost = async (fpHash = '', sessionID, id, permission, postURL, conf
431
542
  } else {
432
543
  logConsole(configLogs, 'debug', '[Payload] ', key);
433
544
  try {
434
- const response = await axios.post(postURL1, key, config);
545
+ const response = await axios.post(postURL1, key, {
546
+ ...config,
547
+ withCredentials: true,
548
+ headers: {
549
+ ...(config?.headers || {}),
550
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
551
+ }
552
+ });
435
553
  logConsole(configLogs, 'info', '[Request] ', postURL1);
436
554
  logConsole(configLogs, 'data', '', response.data);
437
555
  setPost(response.data);
@@ -514,8 +632,16 @@ const servicePostData = async (fpHash = '', sessionID, id, permission, postURL,
514
632
  } else {
515
633
  logConsole(configLogs, 'debug', '[Payload] ', key);
516
634
  try {
517
- const response = await axios.post(postURL1, key, config);
635
+ const response = await axios.post(postURL1, key, {
636
+ ...config,
637
+ withCredentials: true,
638
+ headers: {
639
+ ...(config?.headers || {}),
640
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
641
+ }
642
+ });
518
643
  logConsole(configLogs, 'info', '[Request] ', postURL1);
644
+ logConsole(configLogs, 'data', '', response.data);
519
645
  setPost(response.data);
520
646
  } catch (error) {
521
647
  logConsole(configLogs, 'error', '', error);
@@ -549,11 +675,6 @@ const serviceLogout = async (fpHash = '', sessionID, cxauthxc, t, setAuthTokens,
549
675
  const userLanguage = localStorage.getItem('userLanguage');
550
676
  const displaymode = localStorage.getItem('displaymode');
551
677
  const displayzoom = localStorage.getItem('displayzoom');
552
- localStorage.clear();
553
- authStorage.removeAuthData(configLogs);
554
- if (userLanguage) localStorage.setItem('userLanguage', userLanguage);
555
- if (displaymode) localStorage.setItem('displaymode', displaymode);
556
- if (displayzoom) localStorage.setItem('displayzoom', displayzoom);
557
678
  await postService.postservice({
558
679
  sessionID,
559
680
  cxauthxc,
@@ -561,6 +682,10 @@ const serviceLogout = async (fpHash = '', sessionID, cxauthxc, t, setAuthTokens,
561
682
  authorization: true,
562
683
  fingerprint: visitorIdHash
563
684
  }, configLogs);
685
+ authStorage.removeAuthData(configLogs);
686
+ if (userLanguage) localStorage.setItem('userLanguage', userLanguage);
687
+ if (displaymode) localStorage.setItem('displaymode', displaymode);
688
+ if (displayzoom) localStorage.setItem('displayzoom', displayzoom);
564
689
  setAuthTokens('');
565
690
  } catch (err) {
566
691
  const errorMessage = handleError$3(err, t, configLogs);
@@ -590,119 +715,2785 @@ const serviceFavorites = async (type = '', fpHash = '', sessionID, postURL, cxau
590
715
  } else {
591
716
  unreadcount = await postService.postservice(requestData, configLogs);
592
717
  }
593
- if (unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount)) {
594
- setPost(unreadcount.data);
718
+ if (unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount)) {
719
+ setPost(unreadcount.data);
720
+ } else {
721
+ setPost(unreadcount);
722
+ }
723
+ logConsole(configLogs, 'data', '', unreadcount);
724
+ const favoriteValue = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
725
+ if (type === 'get' && favoriteValue === true) {
726
+ setColor('#ffcd38');
727
+ } else if (type === 'set') {
728
+ setColor('#ffcd38');
729
+ localStorage.setItem('favoritessynch01', 'true');
730
+ localStorage.setItem('favoritessynch02', 'true');
731
+ window.dispatchEvent(new Event('favorites'));
732
+ } else if (type === 'del') {
733
+ setColor('');
734
+ localStorage.setItem('favoritessynch01', 'true');
735
+ localStorage.setItem('favoritessynch02', 'true');
736
+ window.dispatchEvent(new Event('favorites'));
737
+ }
738
+ setIsError(false);
739
+ } catch (err) {
740
+ setError(true);
741
+ handleError$3(err, t, configLogs, setIsError, setMessageerror);
742
+ } finally {
743
+ setLoading(false);
744
+ }
745
+ };
746
+ const serviceGetFavorites = async (fpHash = '', sessionID, postURL, cxauthxc, t, setPost, setIsError, setError, setMessageerror, setLoading, configLogs, ...rest) => {
747
+ const visitorIdHash = await getOrSetFingerprint(fpHash);
748
+ try {
749
+ const requestData = {
750
+ ...rest[0],
751
+ sessionID,
752
+ cxauthxc,
753
+ postServerURL: postURL,
754
+ authorization: true,
755
+ fingerprint: visitorIdHash
756
+ };
757
+ const unreadcount = await getservice(requestData, configLogs);
758
+ const responseData = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
759
+ setPost(responseData);
760
+ localStorage.setItem('favoritessynch03', JSON.stringify(responseData));
761
+ logConsole(configLogs, 'data', '', unreadcount);
762
+ setIsError(false);
763
+ } catch (err) {
764
+ setError(true);
765
+ handleError$3(err, t, configLogs, setIsError, setMessageerror);
766
+ } finally {
767
+ setLoading(false);
768
+ }
769
+ };
770
+
771
+ const defaultConfig$3 = {
772
+ enableLogs: false,
773
+ enableLogsError: false,
774
+ enableLogsWarning: false,
775
+ enableLogsInfo: false,
776
+ enableLogsData: false,
777
+ enableLogsDebug: false,
778
+ developmentMode: false
779
+ };
780
+ const ConexysConfigContext = /*#__PURE__*/React.createContext(defaultConfig$3);
781
+ const ConexysConfigProvider = ({
782
+ children,
783
+ config = {}
784
+ }) => {
785
+ const mergedConfig = {
786
+ ...defaultConfig$3,
787
+ ...config
788
+ };
789
+ return /*#__PURE__*/React.createElement(ConexysConfigContext.Provider, {
790
+ value: mergedConfig
791
+ }, children);
792
+ };
793
+ const useConexysConfig = () => {
794
+ return React.useContext(ConexysConfigContext);
795
+ };
796
+ const isDevelopmentMode = config => {
797
+ return config.developmentMode;
798
+ };
799
+
800
+ const config$3 = {
801
+ headers: {
802
+ 'Content-Type': 'application/json'
803
+ }
804
+ };
805
+ function AppDataSettings({
806
+ keys
807
+ }) {
808
+ const configLogs = useConexysConfig();
809
+ const postURL = Url + 'getsettings';
810
+ const [post, setPost] = React.useState(null);
811
+ const [error, setError] = React.useState(false);
812
+ const hasFetched = React.useRef(false);
813
+ const fetchData = React.useCallback(async () => {
814
+ if (hasFetched.current) return;
815
+ hasFetched.current = true;
816
+ try {
817
+ await serviceData(postURL, {
818
+ keys: keys
819
+ }, config$3, setPost, configLogs);
820
+ } catch (err) {
821
+ setError(true);
822
+ logConsole(configLogs, 'error', 'Error fetching data:', err);
823
+ console.error('Error fetching data:', err);
824
+ }
825
+ }, []);
826
+ React.useEffect(() => {
827
+ fetchData();
828
+ }, [fetchData]);
829
+ if (!post) return null;
830
+ return /*#__PURE__*/React.createElement(React.Fragment, null, error ? /*#__PURE__*/React.createElement("div", null, "Error loading data") : post);
831
+ }
832
+
833
+ /*! @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 */
834
+
835
+ function _arrayLikeToArray(r, a) {
836
+ (null == a || a > r.length) && (a = r.length);
837
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
838
+ return n;
839
+ }
840
+ function _arrayWithHoles(r) {
841
+ if (Array.isArray(r)) return r;
842
+ }
843
+ function _iterableToArrayLimit(r, l) {
844
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
845
+ if (null != t) {
846
+ var e,
847
+ n,
848
+ i,
849
+ u,
850
+ a = [],
851
+ f = true,
852
+ o = false;
853
+ try {
854
+ 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);
855
+ } catch (r) {
856
+ o = true, n = r;
857
+ } finally {
858
+ try {
859
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
860
+ } finally {
861
+ if (o) throw n;
862
+ }
863
+ }
864
+ return a;
865
+ }
866
+ }
867
+ function _nonIterableRest() {
868
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
869
+ }
870
+ function _slicedToArray(r, e) {
871
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
872
+ }
873
+ function _unsupportedIterableToArray(r, a) {
874
+ if (r) {
875
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
876
+ var t = {}.toString.call(r).slice(8, -1);
877
+ 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;
878
+ }
879
+ }
880
+
881
+ const entries = Object.entries,
882
+ setPrototypeOf = Object.setPrototypeOf,
883
+ isFrozen = Object.isFrozen,
884
+ getPrototypeOf = Object.getPrototypeOf,
885
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
886
+ let freeze = Object.freeze,
887
+ seal = Object.seal,
888
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
889
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
890
+ apply = _ref.apply,
891
+ construct = _ref.construct;
892
+ if (!freeze) {
893
+ freeze = function freeze(x) {
894
+ return x;
895
+ };
896
+ }
897
+ if (!seal) {
898
+ seal = function seal(x) {
899
+ return x;
900
+ };
901
+ }
902
+ if (!apply) {
903
+ apply = function apply(func, thisArg) {
904
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
905
+ args[_key - 2] = arguments[_key];
906
+ }
907
+ return func.apply(thisArg, args);
908
+ };
909
+ }
910
+ if (!construct) {
911
+ construct = function construct(Func) {
912
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
913
+ args[_key2 - 1] = arguments[_key2];
914
+ }
915
+ return new Func(...args);
916
+ };
917
+ }
918
+ const arrayForEach = unapply(Array.prototype.forEach);
919
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
920
+ const arrayPop = unapply(Array.prototype.pop);
921
+ const arrayPush = unapply(Array.prototype.push);
922
+ const arraySplice = unapply(Array.prototype.splice);
923
+ const arrayIsArray = Array.isArray;
924
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
925
+ const stringToString = unapply(String.prototype.toString);
926
+ const stringMatch = unapply(String.prototype.match);
927
+ const stringReplace = unapply(String.prototype.replace);
928
+ const stringIndexOf = unapply(String.prototype.indexOf);
929
+ const stringTrim = unapply(String.prototype.trim);
930
+ const numberToString = unapply(Number.prototype.toString);
931
+ const booleanToString = unapply(Boolean.prototype.toString);
932
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
933
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
934
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
935
+ const objectToString = unapply(Object.prototype.toString);
936
+ const regExpTest = unapply(RegExp.prototype.test);
937
+ const typeErrorCreate = unconstruct(TypeError);
938
+ /**
939
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
940
+ *
941
+ * @param func - The function to be wrapped and called.
942
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
943
+ */
944
+ function unapply(func) {
945
+ return function (thisArg) {
946
+ if (thisArg instanceof RegExp) {
947
+ thisArg.lastIndex = 0;
948
+ }
949
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
950
+ args[_key3 - 1] = arguments[_key3];
951
+ }
952
+ return apply(func, thisArg, args);
953
+ };
954
+ }
955
+ /**
956
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
957
+ *
958
+ * @param func - The constructor function to be wrapped and called.
959
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
960
+ */
961
+ function unconstruct(Func) {
962
+ return function () {
963
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
964
+ args[_key4] = arguments[_key4];
965
+ }
966
+ return construct(Func, args);
967
+ };
968
+ }
969
+ /**
970
+ * Add properties to a lookup table
971
+ *
972
+ * @param set - The set to which elements will be added.
973
+ * @param array - The array containing elements to be added to the set.
974
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
975
+ * @returns The modified set with added elements.
976
+ */
977
+ function addToSet(set, array) {
978
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
979
+ if (setPrototypeOf) {
980
+ // Make 'in' and truthy checks like Boolean(set.constructor)
981
+ // independent of any properties defined on Object.prototype.
982
+ // Prevent prototype setters from intercepting set as a this value.
983
+ setPrototypeOf(set, null);
984
+ }
985
+ if (!arrayIsArray(array)) {
986
+ return set;
987
+ }
988
+ let l = array.length;
989
+ while (l--) {
990
+ let element = array[l];
991
+ if (typeof element === 'string') {
992
+ const lcElement = transformCaseFunc(element);
993
+ if (lcElement !== element) {
994
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
995
+ if (!isFrozen(array)) {
996
+ array[l] = lcElement;
997
+ }
998
+ element = lcElement;
999
+ }
1000
+ }
1001
+ set[element] = true;
1002
+ }
1003
+ return set;
1004
+ }
1005
+ /**
1006
+ * Clean up an array to harden against CSPP
1007
+ *
1008
+ * @param array - The array to be cleaned.
1009
+ * @returns The cleaned version of the array
1010
+ */
1011
+ function cleanArray(array) {
1012
+ for (let index = 0; index < array.length; index++) {
1013
+ const isPropertyExist = objectHasOwnProperty(array, index);
1014
+ if (!isPropertyExist) {
1015
+ array[index] = null;
1016
+ }
1017
+ }
1018
+ return array;
1019
+ }
1020
+ /**
1021
+ * Shallow clone an object
1022
+ *
1023
+ * @param object - The object to be cloned.
1024
+ * @returns A new object that copies the original.
1025
+ */
1026
+ function clone(object) {
1027
+ const newObject = create(null);
1028
+ for (const _ref2 of entries(object)) {
1029
+ var _ref3 = _slicedToArray(_ref2, 2);
1030
+ const property = _ref3[0];
1031
+ const value = _ref3[1];
1032
+ const isPropertyExist = objectHasOwnProperty(object, property);
1033
+ if (isPropertyExist) {
1034
+ if (arrayIsArray(value)) {
1035
+ newObject[property] = cleanArray(value);
1036
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
1037
+ newObject[property] = clone(value);
1038
+ } else {
1039
+ newObject[property] = value;
1040
+ }
1041
+ }
1042
+ }
1043
+ return newObject;
1044
+ }
1045
+ /**
1046
+ * Convert non-node values into strings without depending on direct property access.
1047
+ *
1048
+ * @param value - The value to stringify.
1049
+ * @returns A string representation of the provided value.
1050
+ */
1051
+ function stringifyValue(value) {
1052
+ switch (typeof value) {
1053
+ case 'string':
1054
+ {
1055
+ return value;
1056
+ }
1057
+ case 'number':
1058
+ {
1059
+ return numberToString(value);
1060
+ }
1061
+ case 'boolean':
1062
+ {
1063
+ return booleanToString(value);
1064
+ }
1065
+ case 'bigint':
1066
+ {
1067
+ return bigintToString ? bigintToString(value) : '0';
1068
+ }
1069
+ case 'symbol':
1070
+ {
1071
+ return symbolToString ? symbolToString(value) : 'Symbol()';
1072
+ }
1073
+ case 'undefined':
1074
+ {
1075
+ return objectToString(value);
1076
+ }
1077
+ case 'function':
1078
+ case 'object':
1079
+ {
1080
+ if (value === null) {
1081
+ return objectToString(value);
1082
+ }
1083
+ const valueAsRecord = value;
1084
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
1085
+ if (typeof valueToString === 'function') {
1086
+ const stringified = valueToString(valueAsRecord);
1087
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
1088
+ }
1089
+ return objectToString(value);
1090
+ }
1091
+ default:
1092
+ {
1093
+ return objectToString(value);
1094
+ }
1095
+ }
1096
+ }
1097
+ /**
1098
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
1099
+ *
1100
+ * @param object - The object to look up the getter function in its prototype chain.
1101
+ * @param prop - The property name for which to find the getter function.
1102
+ * @returns The getter function found in the prototype chain or a fallback function.
1103
+ */
1104
+ function lookupGetter(object, prop) {
1105
+ while (object !== null) {
1106
+ const desc = getOwnPropertyDescriptor(object, prop);
1107
+ if (desc) {
1108
+ if (desc.get) {
1109
+ return unapply(desc.get);
1110
+ }
1111
+ if (typeof desc.value === 'function') {
1112
+ return unapply(desc.value);
1113
+ }
1114
+ }
1115
+ object = getPrototypeOf(object);
1116
+ }
1117
+ function fallbackValue() {
1118
+ return null;
1119
+ }
1120
+ return fallbackValue;
1121
+ }
1122
+ function isRegex(value) {
1123
+ try {
1124
+ regExpTest(value, '');
1125
+ return true;
1126
+ } catch (_unused) {
1127
+ return false;
1128
+ }
1129
+ }
1130
+
1131
+ 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']);
1132
+ 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']);
1133
+ 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']);
1134
+ // List of SVG elements that are disallowed by default.
1135
+ // We still need to know them so that we can do namespace
1136
+ // checks properly in case one wants to add them to
1137
+ // allow-list.
1138
+ 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']);
1139
+ 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']);
1140
+ // Similarly to SVG, we want to know all MathML elements,
1141
+ // even those that we disallow by default.
1142
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
1143
+ const text = freeze(['#text']);
1144
+
1145
+ 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']);
1146
+ 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']);
1147
+ 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']);
1148
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
1149
+
1150
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
1151
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
1152
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
1153
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
1154
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
1155
+ 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
1156
+ );
1157
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
1158
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
1159
+ );
1160
+ const DOCTYPE_NAME = seal(/^html$/i);
1161
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1162
+ // Markup-significant character probes used by _sanitizeElements.
1163
+ // Shared module-level instances are safe despite the sticky /g flags:
1164
+ // unapply() resets lastIndex for RegExp receivers before every call.
1165
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
1166
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
1167
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
1168
+ const SELF_CLOSING_TAG = seal(/\/>/i);
1169
+
1170
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
1171
+ const NODE_TYPE = {
1172
+ element: 1,
1173
+ attribute: 2,
1174
+ text: 3,
1175
+ cdataSection: 4,
1176
+ entityReference: 5,
1177
+ // Deprecated
1178
+ entityNode: 6,
1179
+ // Deprecated
1180
+ processingInstruction: 7,
1181
+ comment: 8,
1182
+ document: 9,
1183
+ documentType: 10,
1184
+ documentFragment: 11,
1185
+ notation: 12 // Deprecated
1186
+ };
1187
+ /* HTML-namespace elements whose child text nodes are serialized *literally*
1188
+ (unescaped) by the HTML fragment-serialization algorithm. Two reparse-mXSS
1189
+ shapes ride on that literal serialization:
1190
+ (a) an element child - a tree the HTML parser can never build, but the DOM
1191
+ API and an XML/XHTML parse can - after which a `</tag>`-bearing text
1192
+ sibling breaks the element open on reparse; and
1193
+ (b) text-only content that already carries the element's OWN end tag, e.g.
1194
+ `<style>...</style><img onerror=x>` built as a node, which the literal
1195
+ serializer emits verbatim for the HTML parser to re-open.
1196
+ Shape (a) is handled by the firstElementChild branch in _isUnsafeNode; shape
1197
+ (b) by the LITERAL_TEXT_CLOSE probe. Both read textContent (the raw-serialized
1198
+ form for these elements) rather than innerHTML, because an XML/XHTML working
1199
+ document serializes innerHTML with `<` escaped, which silently blinds the
1200
+ innerHTML-based probes (rule 1's second probe and FALLBACK_TAG_CLOSE) there.
1201
+ `script` is never allow-listed, but is kept here so the guard matches the
1202
+ serializer's own literal-text list exactly. */
1203
+ const LITERAL_TEXT_ELEMENT_NAMES = ['style', 'script', 'xmp', 'iframe', 'noembed', 'noframes', 'plaintext', 'noscript'];
1204
+ const LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
1205
+ /* Per-element end-tag matcher. On an HTML reparse the ONLY token that
1206
+ terminates a literal-text element's raw content is its own end tag; a foreign
1207
+ literal-text close (e.g. `</xmp>` sitting inside `<style>`) does not break
1208
+ out, so matching is per-element, not a shared alternation. The lookahead
1209
+ requires an HTML tag-name terminator (whitespace, `/` or `>`) so a longer
1210
+ name such as `</styles` is not mistaken for `</style`. */
1211
+ const LITERAL_TEXT_CLOSE = function () {
1212
+ const map = {};
1213
+ arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, name => {
1214
+ map[name] = seal(new RegExp('</' + name + '(?=[\\t\\n\\f\\r />])', 'i'));
1215
+ });
1216
+ return freeze(map);
1217
+ }();
1218
+ const getGlobal = function getGlobal() {
1219
+ return typeof window === 'undefined' ? null : window;
1220
+ };
1221
+ /**
1222
+ * Creates a no-op policy for internal use only.
1223
+ * Don't export this function outside this module!
1224
+ * @param trustedTypes The policy factory.
1225
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
1226
+ * @return The policy created (or null, if Trusted Types
1227
+ * are not supported or creating the policy failed).
1228
+ */
1229
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
1230
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
1231
+ return null;
1232
+ }
1233
+ // Allow the callers to control the unique policy name
1234
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
1235
+ // Policy creation with duplicate names throws in Trusted Types.
1236
+ let suffix = null;
1237
+ const ATTR_NAME = 'data-tt-policy-suffix';
1238
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
1239
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
1240
+ }
1241
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
1242
+ try {
1243
+ return trustedTypes.createPolicy(policyName, {
1244
+ createHTML(html) {
1245
+ return html;
1246
+ },
1247
+ createScriptURL(scriptUrl) {
1248
+ return scriptUrl;
1249
+ }
1250
+ });
1251
+ } catch (_) {
1252
+ // Policy creation failed (most likely another DOMPurify script has
1253
+ // already run). Skip creating the policy, as this will only cause errors
1254
+ // if TT are enforced.
1255
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
1256
+ return null;
1257
+ }
1258
+ };
1259
+ const _createHooksMap = function _createHooksMap() {
1260
+ return {
1261
+ afterSanitizeAttributes: [],
1262
+ afterSanitizeElements: [],
1263
+ afterSanitizeShadowDOM: [],
1264
+ beforeSanitizeAttributes: [],
1265
+ beforeSanitizeElements: [],
1266
+ beforeSanitizeShadowDOM: [],
1267
+ uponSanitizeAttribute: [],
1268
+ uponSanitizeElement: [],
1269
+ uponSanitizeShadowNode: []
1270
+ };
1271
+ };
1272
+ /**
1273
+ * Resolve a set-valued configuration option: a fresh set built from
1274
+ * cfg[key] when it is an own array property (seeded with a clone of
1275
+ * options.base when given, case-normalized via options.transform),
1276
+ * the fallback set otherwise.
1277
+ *
1278
+ * @param cfg the cloned, prototype-free configuration object
1279
+ * @param key the configuration property to read
1280
+ * @param fallback the set to use when the option is absent or not an array
1281
+ * @param options transform and optional base set to merge into
1282
+ * @returns the resolved set
1283
+ */
1284
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
1285
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
1286
+ };
1287
+ /**
1288
+ * Resolve an object-valued configuration option: a prototype-free clone
1289
+ * of cfg[key] when it is an own, truthy object property, else a fresh
1290
+ * fallback built by makeFallback (fresh on every parse, so a previous
1291
+ * parse can never leak state into the next one).
1292
+ *
1293
+ * @param cfg the cloned, prototype-free configuration object
1294
+ * @param key the configuration property to read
1295
+ * @param makeFallback builds the fallback value when the option is absent
1296
+ * @returns the resolved object
1297
+ */
1298
+ const _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {
1299
+ const value = objectHasOwnProperty(cfg, key) ? cfg[key] : undefined;
1300
+ return value && typeof value === 'object' ? clone(value) : makeFallback();
1301
+ };
1302
+ function createDOMPurify() {
1303
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
1304
+ const DOMPurify = root => createDOMPurify(root);
1305
+ DOMPurify.version = '3.4.14';
1306
+ DOMPurify.removed = [];
1307
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1308
+ // Not running in a browser, provide a factory function
1309
+ // so that you can pass your own Window
1310
+ DOMPurify.isSupported = false;
1311
+ return DOMPurify;
1312
+ }
1313
+ let document = window.document;
1314
+ const originalDocument = document;
1315
+ const currentScript = originalDocument.currentScript;
1316
+ window.DocumentFragment;
1317
+ const HTMLTemplateElement = window.HTMLTemplateElement,
1318
+ Node = window.Node,
1319
+ Element = window.Element,
1320
+ NodeFilter = window.NodeFilter,
1321
+ _window$NamedNodeMap = window.NamedNodeMap;
1322
+ _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
1323
+ window.HTMLFormElement;
1324
+ const DOMParser = window.DOMParser,
1325
+ trustedTypes = window.trustedTypes;
1326
+ const ElementPrototype = Element.prototype;
1327
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
1328
+ const remove = lookupGetter(ElementPrototype, 'remove');
1329
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
1330
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
1331
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
1332
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
1333
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
1334
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
1335
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
1336
+ const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, 'ownerDocument') : null;
1337
+ /* Clobber-safe nodeType / nodeName reads through the cached Node.prototype
1338
+ getters, with a direct-property fallback for environments that lack
1339
+ Node.prototype. Sites that need a different fallback (e.g. _isClobbered
1340
+ returns early on a null name) intentionally keep their own reads. */
1341
+ const _readNodeType = function _readNodeType(node) {
1342
+ return getNodeType ? getNodeType(node) : node.nodeType;
1343
+ };
1344
+ const _readNodeName = function _readNodeName(node) {
1345
+ return getNodeName ? getNodeName(node) : node.nodeName;
1346
+ };
1347
+ // As per issue #47, the web-components registry is inherited by a
1348
+ // new document created via createHTMLDocument. As per the spec
1349
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
1350
+ // a new empty registry is used when creating a template contents owner
1351
+ // document, so we use that as our parent document to ensure nothing
1352
+ // is inherited.
1353
+ if (typeof HTMLTemplateElement === 'function') {
1354
+ const template = document.createElement('template');
1355
+ if (template.content && template.content.ownerDocument) {
1356
+ document = template.content.ownerDocument;
1357
+ }
1358
+ }
1359
+ let trustedTypesPolicy;
1360
+ let emptyHTML = '';
1361
+ // The instance's own internal Trusted Types policy. Unlike a caller-supplied
1362
+ // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
1363
+ // on duplicate policy names — and is the only policy allowed to persist
1364
+ // across configurations and survive `clearConfig()`.
1365
+ let defaultTrustedTypesPolicy;
1366
+ let defaultTrustedTypesPolicyResolved = false;
1367
+ // Tracks whether we are already inside a call to the configured Trusted Types
1368
+ // policy (`createHTML` or `createScriptURL`). If a supplied policy callback
1369
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
1370
+ // re-enter the policy and recurse until the stack overflows. We detect that
1371
+ // re-entry and throw a clear, actionable error instead. The guard is shared
1372
+ // across both callbacks, because either one re-entering `sanitize` triggers
1373
+ // the same unbounded recursion.
1374
+ let IN_TRUSTED_TYPES_POLICY = 0;
1375
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
1376
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
1377
+ 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.');
1378
+ }
1379
+ };
1380
+ const _createTrustedHTML = function _createTrustedHTML(html) {
1381
+ _assertNotInTrustedTypesPolicy();
1382
+ IN_TRUSTED_TYPES_POLICY++;
1383
+ try {
1384
+ return trustedTypesPolicy.createHTML(html);
1385
+ } finally {
1386
+ IN_TRUSTED_TYPES_POLICY--;
1387
+ }
1388
+ };
1389
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
1390
+ _assertNotInTrustedTypesPolicy();
1391
+ IN_TRUSTED_TYPES_POLICY++;
1392
+ try {
1393
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
1394
+ } finally {
1395
+ IN_TRUSTED_TYPES_POLICY--;
1396
+ }
1397
+ };
1398
+ // Lazily resolve (and cache) the instance's internal default policy.
1399
+ // Resolution is attempted at most once: a successful `createPolicy` cannot be
1400
+ // repeated (Trusted Types throws on duplicate names), and a failed or
1401
+ // unsupported attempt must not be retried on every parse.
1402
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
1403
+ if (!defaultTrustedTypesPolicyResolved) {
1404
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1405
+ defaultTrustedTypesPolicyResolved = true;
1406
+ }
1407
+ return defaultTrustedTypesPolicy;
1408
+ };
1409
+ const _document = document,
1410
+ implementation = _document.implementation,
1411
+ createNodeIterator = _document.createNodeIterator,
1412
+ createDocumentFragment = _document.createDocumentFragment,
1413
+ getElementsByTagName = _document.getElementsByTagName;
1414
+ const importNode = originalDocument.importNode;
1415
+ let hooks = _createHooksMap();
1416
+ /**
1417
+ * Expose whether this browser supports running the full DOMPurify.
1418
+ */
1419
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
1420
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
1421
+ ERB_EXPR$1 = ERB_EXPR,
1422
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
1423
+ DATA_ATTR$1 = DATA_ATTR,
1424
+ ARIA_ATTR$1 = ARIA_ATTR,
1425
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
1426
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
1427
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
1428
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
1429
+ /**
1430
+ * We consider the elements and attributes below to be safe. Ideally
1431
+ * don't add any new ones but feel free to remove unwanted ones.
1432
+ */
1433
+ /* allowed element names */
1434
+ let ALLOWED_TAGS = null;
1435
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
1436
+ /* Allowed attribute names */
1437
+ let ALLOWED_ATTR = null;
1438
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
1439
+ /*
1440
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
1441
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
1442
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
1443
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
1444
+ */
1445
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
1446
+ tagNameCheck: {
1447
+ writable: true,
1448
+ configurable: false,
1449
+ enumerable: true,
1450
+ value: null
1451
+ },
1452
+ attributeNameCheck: {
1453
+ writable: true,
1454
+ configurable: false,
1455
+ enumerable: true,
1456
+ value: null
1457
+ },
1458
+ allowCustomizedBuiltInElements: {
1459
+ writable: true,
1460
+ configurable: false,
1461
+ enumerable: true,
1462
+ value: false
1463
+ }
1464
+ }));
1465
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
1466
+ let FORBID_TAGS = null;
1467
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
1468
+ let FORBID_ATTR = null;
1469
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
1470
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
1471
+ tagCheck: {
1472
+ writable: true,
1473
+ configurable: false,
1474
+ enumerable: true,
1475
+ value: null
1476
+ },
1477
+ attributeCheck: {
1478
+ writable: true,
1479
+ configurable: false,
1480
+ enumerable: true,
1481
+ value: null
1482
+ }
1483
+ }));
1484
+ /* Decide if ARIA attributes are okay */
1485
+ let ALLOW_ARIA_ATTR = true;
1486
+ /* Decide if custom data attributes are okay */
1487
+ let ALLOW_DATA_ATTR = true;
1488
+ /* Decide if unknown protocols are okay */
1489
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1490
+ /* Decide if self-closing tags in attributes are allowed.
1491
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
1492
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1493
+ /* Output should be safe for common template engines.
1494
+ * This means, DOMPurify removes data attributes, mustaches and ERB
1495
+ */
1496
+ let SAFE_FOR_TEMPLATES = false;
1497
+ /* Output should be safe even for XML used within HTML and alike.
1498
+ * This means, DOMPurify removes comments when containing risky content.
1499
+ */
1500
+ let SAFE_FOR_XML = true;
1501
+ /* Decide if document with <html>... should be returned */
1502
+ let WHOLE_DOCUMENT = false;
1503
+ /* Track whether config is already set on this instance of DOMPurify. */
1504
+ let SET_CONFIG = false;
1505
+ /* Pristine allowlist bindings captured at setConfig() time. On the
1506
+ * persistent-config path sanitize() restores the sets from these before
1507
+ * the per-walk hook clone-guard, so a hook's in-call widening cannot
1508
+ * carry across calls. Null until setConfig() is called; reset by
1509
+ * clearConfig(). */
1510
+ let SET_CONFIG_ALLOWED_TAGS = null;
1511
+ let SET_CONFIG_ALLOWED_ATTR = null;
1512
+ /* Decide if all elements (e.g. style, script) must be children of
1513
+ * document.body. By default, browsers might move them to document.head */
1514
+ let FORCE_BODY = false;
1515
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
1516
+ * string (or a TrustedHTML object if Trusted Types are supported).
1517
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
1518
+ */
1519
+ let RETURN_DOM = false;
1520
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
1521
+ * string (or a TrustedHTML object if Trusted Types are supported) */
1522
+ let RETURN_DOM_FRAGMENT = false;
1523
+ /* Try to return a Trusted Type object instead of a string, return a string in
1524
+ * case Trusted Types are not supported */
1525
+ let RETURN_TRUSTED_TYPE = false;
1526
+ /* Output should be free from DOM clobbering attacks?
1527
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
1528
+ */
1529
+ let SANITIZE_DOM = true;
1530
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
1531
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
1532
+ *
1533
+ * HTML/DOM spec rules that enable DOM Clobbering:
1534
+ * - Named Access on Window (§7.3.3)
1535
+ * - DOM Tree Accessors (§3.1.5)
1536
+ * - Form Element Parent-Child Relations (§4.10.3)
1537
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
1538
+ * - HTMLCollection (§4.2.10.2)
1539
+ *
1540
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
1541
+ * with a constant string, i.e., `user-content-`
1542
+ */
1543
+ let SANITIZE_NAMED_PROPS = false;
1544
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
1545
+ /* Keep element content when removing element? */
1546
+ let KEEP_CONTENT = true;
1547
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
1548
+ * of importing it into a new Document and returning a sanitized copy */
1549
+ let IN_PLACE = false;
1550
+ /* Allow usage of profiles like html, svg and mathMl */
1551
+ let USE_PROFILES = {};
1552
+ /* Tags to ignore content of when KEEP_CONTENT is true */
1553
+ let FORBID_CONTENTS = null;
1554
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
1555
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
1556
+ // the UA (customizable <select>) — including any on* handlers — and the
1557
+ // engine re-mirrors synchronously whenever a removal changes which
1558
+ // option/selectedcontent is current, even inside DOMPurify's inert
1559
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
1560
+ // mirror target ahead of the walk, which the engine refills, looping
1561
+ // forever (DoS) and amplifying output. Dropping its content on removal
1562
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
1563
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
1564
+ 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
1565
+ /* Tags that are safe for data: URIs */
1566
+ let DATA_URI_TAGS = null;
1567
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
1568
+ /* Attributes safe for values like "javascript:" */
1569
+ let URI_SAFE_ATTRIBUTES = null;
1570
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
1571
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1572
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1573
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1574
+ /* Document namespace */
1575
+ let NAMESPACE = HTML_NAMESPACE;
1576
+ let IS_EMPTY_INPUT = false;
1577
+ /* Allowed XHTML+XML namespaces */
1578
+ let ALLOWED_NAMESPACES = null;
1579
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1580
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
1581
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1582
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
1583
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1584
+ // Certain elements are allowed in both SVG and HTML
1585
+ // namespace. We need to specify them explicitly
1586
+ // so that they don't get erroneously deleted from
1587
+ // HTML namespace.
1588
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1589
+ /* Parsing of strict XHTML documents */
1590
+ let PARSER_MEDIA_TYPE = null;
1591
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1592
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1593
+ let transformCaseFunc = null;
1594
+ /* Keep a reference to config to pass to hooks */
1595
+ let CONFIG = null;
1596
+ /* Ideally, do not touch anything below this line */
1597
+ /* ______________________________________________ */
1598
+ const formElement = document.createElement('form');
1599
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1600
+ return testValue instanceof RegExp || testValue instanceof Function;
1601
+ };
1602
+ /**
1603
+ * _parseConfig
1604
+ *
1605
+ * @param cfg optional config literal
1606
+ */
1607
+ // eslint-disable-next-line complexity
1608
+ const _parseConfig = function _parseConfig() {
1609
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1610
+ if (CONFIG && CONFIG === cfg) {
1611
+ return;
1612
+ }
1613
+ /* Shield configuration object from tampering */
1614
+ if (!cfg || typeof cfg !== 'object') {
1615
+ cfg = {};
1616
+ }
1617
+ /* Shield configuration object from prototype pollution */
1618
+ cfg = clone(cfg);
1619
+ PARSER_MEDIA_TYPE =
1620
+ // eslint-disable-next-line unicorn/prefer-includes
1621
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1622
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1623
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1624
+ /* Set configuration parameters */
1625
+ ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
1626
+ transform: transformCaseFunc
1627
+ });
1628
+ ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
1629
+ transform: transformCaseFunc
1630
+ });
1631
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
1632
+ transform: stringToString
1633
+ });
1634
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
1635
+ transform: transformCaseFunc,
1636
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1637
+ });
1638
+ DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
1639
+ transform: transformCaseFunc,
1640
+ base: DEFAULT_DATA_URI_TAGS
1641
+ });
1642
+ FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
1643
+ transform: transformCaseFunc
1644
+ });
1645
+ FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
1646
+ transform: transformCaseFunc
1647
+ });
1648
+ FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
1649
+ transform: transformCaseFunc
1650
+ });
1651
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1652
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1653
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1654
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1655
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1656
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1657
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
1658
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1659
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1660
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1661
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1662
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1663
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1664
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1665
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1666
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
1667
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
1668
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
1669
+ MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, 'MATHML_TEXT_INTEGRATION_POINTS', () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS) // Default built-in map
1670
+ );
1671
+ HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, 'HTML_INTEGRATION_POINTS', () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS) // Default built-in map
1672
+ );
1673
+ const customElementHandling = _resolveObjectOption(cfg, 'CUSTOM_ELEMENT_HANDLING', () => create(null));
1674
+ CUSTOM_ELEMENT_HANDLING = create(null);
1675
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
1676
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
1677
+ }
1678
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
1679
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
1680
+ }
1681
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
1682
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
1683
+ }
1684
+ seal(CUSTOM_ELEMENT_HANDLING);
1685
+ if (SAFE_FOR_TEMPLATES) {
1686
+ ALLOW_DATA_ATTR = false;
1687
+ }
1688
+ if (RETURN_DOM_FRAGMENT) {
1689
+ RETURN_DOM = true;
1690
+ }
1691
+ /* Parse profile info */
1692
+ if (USE_PROFILES) {
1693
+ ALLOWED_TAGS = addToSet({}, text);
1694
+ ALLOWED_ATTR = create(null);
1695
+ if (USE_PROFILES.html === true) {
1696
+ addToSet(ALLOWED_TAGS, html$1);
1697
+ addToSet(ALLOWED_ATTR, html);
1698
+ }
1699
+ if (USE_PROFILES.svg === true) {
1700
+ addToSet(ALLOWED_TAGS, svg$1);
1701
+ addToSet(ALLOWED_ATTR, svg);
1702
+ addToSet(ALLOWED_ATTR, xml);
1703
+ }
1704
+ if (USE_PROFILES.svgFilters === true) {
1705
+ addToSet(ALLOWED_TAGS, svgFilters);
1706
+ addToSet(ALLOWED_ATTR, svg);
1707
+ addToSet(ALLOWED_ATTR, xml);
1708
+ }
1709
+ if (USE_PROFILES.mathMl === true) {
1710
+ addToSet(ALLOWED_TAGS, mathMl$1);
1711
+ addToSet(ALLOWED_ATTR, mathMl);
1712
+ addToSet(ALLOWED_ATTR, xml);
1713
+ }
1714
+ }
1715
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
1716
+ * leaking across calls when switching from function to array config */
1717
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
1718
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
1719
+ /* Merge configuration parameters */
1720
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
1721
+ if (typeof cfg.ADD_TAGS === 'function') {
1722
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
1723
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
1724
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1725
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
1726
+ }
1727
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1728
+ }
1729
+ }
1730
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
1731
+ if (typeof cfg.ADD_ATTR === 'function') {
1732
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
1733
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
1734
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1735
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
1736
+ }
1737
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1738
+ }
1739
+ }
1740
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
1741
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1742
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1743
+ }
1744
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
1745
+ }
1746
+ /* Add #text in case KEEP_CONTENT is set to true */
1747
+ if (KEEP_CONTENT) {
1748
+ ALLOWED_TAGS['#text'] = true;
1749
+ }
1750
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1751
+ if (WHOLE_DOCUMENT) {
1752
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1753
+ }
1754
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1755
+ if (ALLOWED_TAGS.table) {
1756
+ addToSet(ALLOWED_TAGS, ['tbody']);
1757
+ delete FORBID_TAGS.tbody;
1758
+ }
1759
+ // Re-derive the active Trusted Types policy from this configuration on
1760
+ // every parse. The active policy must never be sticky closure state that
1761
+ // outlives the config that set it: a caller-supplied policy left in place
1762
+ // after `clearConfig()` — or after a later call that supplied none, or
1763
+ // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
1764
+ // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
1765
+ // See GHSA-vxr8-fq34-vvx9.
1766
+ if (cfg.TRUSTED_TYPES_POLICY) {
1767
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1768
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1769
+ }
1770
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1771
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1772
+ }
1773
+ // A caller-supplied policy applies to this configuration only.
1774
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1775
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1776
+ // Sign local variables required by `sanitize`. If the supplied policy's
1777
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
1778
+ // throws via the re-entrancy guard. Restore the previous policy first so
1779
+ // the instance is not left in a poisoned state. See #1422.
1780
+ try {
1781
+ emptyHTML = _createTrustedHTML('');
1782
+ } catch (error) {
1783
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1784
+ throw error;
1785
+ }
1786
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1787
+ // Explicit opt-out for this call: perform no Trusted Types signing and
1788
+ // create nothing (so a strict `trusted-types` CSP that disallows a
1789
+ // `dompurify` policy can still call `sanitize` from inside its own
1790
+ // policy — see #1422). Resetting to `undefined` rather than a sticky
1791
+ // `null` also drops any previously retained caller policy, so it cannot
1792
+ // resurface on a later call, while still allowing the next config-less
1793
+ // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
1794
+ trustedTypesPolicy = undefined;
1795
+ emptyHTML = '';
1796
+ } else {
1797
+ // No policy supplied: keep the currently active policy if one is set — a
1798
+ // previously supplied policy is intentionally sticky across config-less
1799
+ // calls — otherwise fall back to the instance's own internal policy,
1800
+ // created at most once. (A policy supplied for a *single* call still
1801
+ // lingers by design; what must not linger is a policy whose configuration
1802
+ // has been torn down via `clearConfig()`, which restores the default.)
1803
+ if (trustedTypesPolicy === undefined) {
1804
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1805
+ }
1806
+ // Sign internal variables only when a policy is active. A falsy policy
1807
+ // (Trusted Types unsupported, creation failed, or an explicit opt-out)
1808
+ // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
1809
+ // a non-policy and throw. See #1422.
1810
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
1811
+ emptyHTML = _createTrustedHTML('');
1812
+ }
1813
+ }
1814
+ // Prevent further manipulation of configuration.
1815
+ // Not available in IE8, Safari 5, etc.
1816
+ if (freeze) {
1817
+ freeze(cfg);
1818
+ }
1819
+ CONFIG = cfg;
1820
+ };
1821
+ /* Keep track of all possible SVG and MathML tags
1822
+ * so that we can perform the namespace checks
1823
+ * correctly. */
1824
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1825
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1826
+ /**
1827
+ * Namespace rules for an element in the SVG namespace.
1828
+ *
1829
+ * @param tagName the element's lowercase tag name
1830
+ * @param parent the (possibly simulated) parent node
1831
+ * @param parentTagName the parent's lowercase tag name
1832
+ * @returns true if a spec-compliant parser could produce this element
1833
+ */
1834
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
1835
+ // The only way to switch from HTML namespace to SVG
1836
+ // is via <svg>. If it happens via any other tag, then
1837
+ // it should be killed.
1838
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1839
+ return tagName === 'svg';
1840
+ }
1841
+ // The only way to switch from MathML to SVG is via <svg>
1842
+ // if the parent is either <annotation-xml> or a MathML
1843
+ // text integration point.
1844
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1845
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1846
+ }
1847
+ // We only allow elements that are defined in SVG
1848
+ // spec. All others are disallowed in SVG namespace.
1849
+ return Boolean(ALL_SVG_TAGS[tagName]);
1850
+ };
1851
+ /**
1852
+ * Namespace rules for an element in the MathML namespace.
1853
+ *
1854
+ * @param tagName the element's lowercase tag name
1855
+ * @param parent the (possibly simulated) parent node
1856
+ * @param parentTagName the parent's lowercase tag name
1857
+ * @returns true if a spec-compliant parser could produce this element
1858
+ */
1859
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
1860
+ // The only way to switch from HTML namespace to MathML
1861
+ // is via <math>. If it happens via any other tag, then
1862
+ // it should be killed.
1863
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1864
+ return tagName === 'math';
1865
+ }
1866
+ // The only way to switch from SVG to MathML is via
1867
+ // <math> and HTML integration points
1868
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1869
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1870
+ }
1871
+ // We only allow elements that are defined in MathML
1872
+ // spec. All others are disallowed in MathML namespace.
1873
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1874
+ };
1875
+ /**
1876
+ * Namespace rules for an element in the HTML namespace.
1877
+ *
1878
+ * @param tagName the element's lowercase tag name
1879
+ * @param parent the (possibly simulated) parent node
1880
+ * @param parentTagName the parent's lowercase tag name
1881
+ * @returns true if a spec-compliant parser could produce this element
1882
+ */
1883
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1884
+ // The only way to switch from SVG to HTML is via
1885
+ // HTML integration points, and from MathML to HTML
1886
+ // is via MathML text integration points
1887
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1888
+ return false;
1889
+ }
1890
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1891
+ return false;
1892
+ }
1893
+ // We disallow tags that are specific for MathML
1894
+ // or SVG and should never appear in HTML namespace
1895
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1896
+ };
1897
+ /**
1898
+ * @param element a DOM element whose namespace is being checked
1899
+ * @returns Return false if the element has a
1900
+ * namespace that a spec-compliant parser would never
1901
+ * return. Return true otherwise.
1902
+ */
1903
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1904
+ let parent = getParentNode(element);
1905
+ // In JSDOM, if we're inside shadow DOM, then parentNode
1906
+ // can be null. We just simulate parent in this case.
1907
+ if (!parent || !parent.tagName) {
1908
+ parent = {
1909
+ namespaceURI: NAMESPACE,
1910
+ tagName: 'template'
1911
+ };
1912
+ }
1913
+ const tagName = stringToLowerCase(element.tagName);
1914
+ const parentTagName = stringToLowerCase(parent.tagName);
1915
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1916
+ return false;
1917
+ }
1918
+ if (element.namespaceURI === SVG_NAMESPACE) {
1919
+ return _checkSvgNamespace(tagName, parent, parentTagName);
1920
+ }
1921
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1922
+ return _checkMathMlNamespace(tagName, parent, parentTagName);
1923
+ }
1924
+ if (element.namespaceURI === HTML_NAMESPACE) {
1925
+ return _checkHtmlNamespace(tagName, parent, parentTagName);
1926
+ }
1927
+ // For XHTML and XML documents that support custom namespaces
1928
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1929
+ return true;
1930
+ }
1931
+ // The code should never reach this place (this means
1932
+ // that the element somehow got namespace that is not
1933
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1934
+ // Return false just in case.
1935
+ return false;
1936
+ };
1937
+ /**
1938
+ * _forceRemove
1939
+ *
1940
+ * @param node a DOM node
1941
+ */
1942
+ const _forceRemove = function _forceRemove(node) {
1943
+ arrayPush(DOMPurify.removed, {
1944
+ element: node
1945
+ });
1946
+ try {
1947
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
1948
+ getParentNode(node).removeChild(node);
1949
+ } catch (_) {
1950
+ /* The normal detach failed — this is reached for a parentless node
1951
+ (getParentNode() is null, so .removeChild throws). Element.prototype
1952
+ .remove() is itself a spec no-op on a parentless node, so a recorded
1953
+ "removal" would otherwise hand the caller back an intact,
1954
+ payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
1955
+ the style-with-element-child rule decided to kill). Fail closed by
1956
+ throwing — exactly as a clobbered root does at the IN_PLACE entry —
1957
+ rather than trying to "neutralize" the node via its own methods.
1958
+ Neutralizing would mean calling getAttributeNames()/removeAttribute()
1959
+ on the node, both of which a <form> root can clobber via a named child
1960
+ (and _isClobbered does not even probe getAttributeNames), so the
1961
+ neutralize step could itself be silently defeated, leaving the payload
1962
+ intact. A throw touches only the cached, clobber-safe remove() and
1963
+ getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
1964
+ to every root-kill reason. REPORT-3.
1965
+ This lives inside the catch, so it never fires for a normally-removed
1966
+ in-tree node: those have a parent, removeChild() succeeds, and the
1967
+ catch is not entered. Only a kept (parentless) root reaches here. */
1968
+ remove(node);
1969
+ if (!getParentNode(node)) {
1970
+ throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
1971
+ }
1972
+ }
1973
+ };
1974
+ /**
1975
+ * _stripAttributeNode
1976
+ *
1977
+ * Remove a single Attr node case/namespace-exactly on an attribute-teardown
1978
+ * path. Name-based removeAttribute() ASCII-lowercases its lookup key for an
1979
+ * HTML element in an HTML document and so silently misses a case-preserved
1980
+ * handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect
1981
+ * _removeAttribute() was fixed for, which a name-based call would reintroduce
1982
+ * on these IN_PLACE teardown paths. Unlike _removeAttribute this does not
1983
+ * record into DOMPurify.removed: the neutralize passes intentionally do not
1984
+ * book-keep. A clobbered/detached node falls back to best-effort name-based
1985
+ * removal.
1986
+ *
1987
+ * @param element the element to strip the attribute from
1988
+ * @param attribute the Attr node to remove
1989
+ * @param name the attribute's name, for the fallback path
1990
+ */
1991
+ const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
1992
+ try {
1993
+ element.removeAttributeNode(attribute);
1994
+ } catch (_) {
1995
+ try {
1996
+ element.removeAttribute(name);
1997
+ } catch (_) {}
1998
+ }
1999
+ };
2000
+ /**
2001
+ * _neutralizeRoot
2002
+ *
2003
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
2004
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
2005
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
2006
+ * parentless guard throws, or any other re-entrant engine mutation — would
2007
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
2008
+ * after the abort point still carrying its handlers. There is no safe way
2009
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
2010
+ * remove every child and every attribute, then let the caller's catch see
2011
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
2012
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
2013
+ *
2014
+ * @param root the in-place root to empty
2015
+ */
2016
+ const _neutralizeRoot = function _neutralizeRoot(root) {
2017
+ /* Strip every disallowed attribute (on* handlers included) off the whole
2018
+ subtree BEFORE detaching anything. Detaching first would hand back
2019
+ handler-bearing originals (e.g. an already-loading `<img onerror>`)
2020
+ whose queued resource event still fires in page scope after we throw.
2021
+ Clobber-safe reads; a doomed clobbered node's own attributes are
2022
+ irrelevant while its non-clobbered descendants are reached and scrubbed. */
2023
+ _neutralizeSubtree(root);
2024
+ const childNodes = getChildNodes(root);
2025
+ if (childNodes) {
2026
+ const snapshot = [];
2027
+ arrayForEach(childNodes, child => {
2028
+ arrayPush(snapshot, child);
2029
+ });
2030
+ arrayForEach(snapshot, child => {
2031
+ try {
2032
+ remove(child);
2033
+ } catch (_) {
2034
+ /* Best-effort teardown; a still-attached child is handled below */
2035
+ }
2036
+ });
2037
+ }
2038
+ const attributes = getAttributes(root);
2039
+ if (attributes) {
2040
+ for (let i = attributes.length - 1; i >= 0; --i) {
2041
+ const attribute = attributes[i];
2042
+ const name = attribute && attribute.name;
2043
+ if (typeof name === 'string') {
2044
+ _stripAttributeNode(root, attribute, name);
2045
+ }
2046
+ }
2047
+ }
2048
+ };
2049
+ /**
2050
+ * _removeAttribute
2051
+ *
2052
+ * Name-based getAttributeNode()/removeAttribute() ASCII-lowercase their
2053
+ * lookup key for HTML elements in an HTML document, so they silently miss an
2054
+ * attribute whose stored qualified name still contains uppercase ASCII
2055
+ * letters. That happens when the node came from a case-preserving source
2056
+ * (an XML/XHTML document imported via importNode(), or createAttributeNS()),
2057
+ * where e.g. `ONERROR` survives the walk: the policy check lowercases to
2058
+ * `onerror` and rejects it, but `removeAttribute('ONERROR')` looks up
2059
+ * `onerror` and finds nothing. Remove the exact Attr node instead, which is
2060
+ * case- and namespace-exact, and fall back to name-based removal only when
2061
+ * the caller could not supply the node.
2062
+ *
2063
+ * @param name an Attribute name
2064
+ * @param element a DOM node
2065
+ * @param attr the exact Attr node to remove, when the caller has it
2066
+ */
2067
+ const _removeAttribute = function _removeAttribute(name, element, attr) {
2068
+ if (!attr) {
2069
+ try {
2070
+ attr = element.getAttributeNode(name);
2071
+ } catch (_) {
2072
+ attr = null;
2073
+ }
2074
+ }
2075
+ arrayPush(DOMPurify.removed, {
2076
+ attribute: attr || null,
2077
+ from: element
2078
+ });
2079
+ try {
2080
+ if (attr) {
2081
+ element.removeAttributeNode(attr);
2082
+ } else {
2083
+ element.removeAttribute(name);
2084
+ }
2085
+ } catch (_) {
2086
+ /* Clobbered or already-detached node - best-effort fall back to a
2087
+ name-based removal so the "is" handling below still runs. */
2088
+ try {
2089
+ element.removeAttribute(name);
2090
+ } catch (_) {}
2091
+ }
2092
+ // We void attribute values for unremovable "is" attributes
2093
+ if (name === 'is') {
2094
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
2095
+ try {
2096
+ _forceRemove(element);
2097
+ } catch (_) {}
2098
+ } else {
2099
+ try {
2100
+ element.setAttribute(name, '');
2101
+ } catch (_) {}
2102
+ }
2103
+ }
2104
+ };
2105
+ /**
2106
+ * _stripDisallowedAttributes
2107
+ *
2108
+ * Removes every attribute the active configuration does not allow from a
2109
+ * single element, using the same allowlist as the main attribute pass (so
2110
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
2111
+ * neutralise nodes that are being discarded from an in-place tree.
2112
+ *
2113
+ * @param element the element to strip
2114
+ */
2115
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
2116
+ const attributes = getAttributes(element);
2117
+ if (!attributes) {
2118
+ return;
2119
+ }
2120
+ for (let i = attributes.length - 1; i >= 0; --i) {
2121
+ const attribute = attributes[i];
2122
+ const name = attribute && attribute.name;
2123
+ if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
2124
+ continue;
2125
+ }
2126
+ _stripAttributeNode(element, attribute, name);
2127
+ }
2128
+ };
2129
+ /**
2130
+ * _neutralizeSubtree
2131
+ *
2132
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
2133
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
2134
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
2135
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
2136
+ * those dropped nodes are detached from the caller's LIVE tree but a
2137
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
2138
+ * loading) keeps its queued resource event, which fires in page scope after
2139
+ * sanitize returns. This walks a removed subtree and strips every attribute
2140
+ * the active configuration does not allow — so `on*` handlers are cancelled
2141
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
2142
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
2143
+ * queued event can fire. Hook-free by design: these nodes leave the output,
2144
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
2145
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
2146
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
2147
+ * the `<img>`, are reached and scrubbed).
2148
+ *
2149
+ * @param root the root of a removed subtree to neutralise
2150
+ */
2151
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
2152
+ const stack = [root];
2153
+ while (stack.length > 0) {
2154
+ const node = stack.pop();
2155
+ const nodeType = _readNodeType(node);
2156
+ if (nodeType === NODE_TYPE.element) {
2157
+ _stripDisallowedAttributes(node);
2158
+ }
2159
+ const childNodes = getChildNodes(node);
2160
+ if (childNodes) {
2161
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2162
+ stack.push(childNodes[i]);
2163
+ }
2164
+ }
2165
+ }
2166
+ };
2167
+ /**
2168
+ * _neutralizePatchLinkage
2169
+ *
2170
+ * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
2171
+ * hardening, https://github.com/WICG/declarative-partial-updates).
2172
+ *
2173
+ * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
2174
+ * markers (PIs / markup comments) node-by-node, in document order, AS it
2175
+ * reaches each node. On a live in-place root that leaves a window: from the
2176
+ * moment the root is connected until the walk arrives at a given node, that
2177
+ * node's linkage is live. A patch applied on connection/stream can fire as
2178
+ * a microtask during the walk and inject or teleport an unsanitized DOM
2179
+ * range into a region the iterator has already passed and will not revisit,
2180
+ * so the post-return "tree is sanitized" contract is violated. Sweep the
2181
+ * whole tree once up front and sever every linkage before the walk begins,
2182
+ * closing that window.
2183
+ *
2184
+ * This CANNOT undo a patch that already fired before sanitize ran — that is
2185
+ * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
2186
+ * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
2187
+ * to group with the rest of the declarative-partial-updates handling and
2188
+ * stay overridable, consistent with the codebase.
2189
+ *
2190
+ * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
2191
+ * clobbered root cannot defeat the sweep of its non-clobbered descendants.
2192
+ *
2193
+ * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
2194
+ * .html Q1): this mirrors the existing policy of keeping `for` on
2195
+ * <label>/<output>. If the shipping feature can drive a patch through a
2196
+ * surviving `for`-on-label/output + `id` pair, this pre-pass and the
2197
+ * attribute check at _isBasicCustomElement's caller must additionally drop
2198
+ * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
2199
+ *
2200
+ * @param root the in-place root to sweep
2201
+ */
2202
+ /**
2203
+ * Central policy for declarative-partial-updates patch-linkage attributes,
2204
+ * shared by the _neutralizePatchLinkage pre-pass and _isValidAttribute so
2205
+ * the two sites cannot drift: `patchsrc` always links, `for` links
2206
+ * everywhere except on <label>/<output>, and the whole policy is gated on
2207
+ * SAFE_FOR_XML (see the rationale block in _isValidAttribute).
2208
+ *
2209
+ * @param lcName the transformCaseFunc'd attribute name
2210
+ * @param lcTag the transformCaseFunc'd tag name of the carrying element
2211
+ * @return true if the attribute is patch linkage and must be dropped
2212
+ */
2213
+ const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
2214
+ if (!SAFE_FOR_XML) {
2215
+ return false;
2216
+ }
2217
+ if (lcName === 'patchsrc') {
2218
+ return true;
2219
+ }
2220
+ return lcName === 'for' && lcTag !== 'label' && lcTag !== 'output';
2221
+ };
2222
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
2223
+ if (!SAFE_FOR_XML) {
2224
+ return;
2225
+ }
2226
+ const stack = [root];
2227
+ while (stack.length > 0) {
2228
+ const node = stack.pop();
2229
+ const nodeType = _readNodeType(node);
2230
+ /* Remove range markers (the target side of a patch linkage): every
2231
+ processing instruction, and any markup-bearing comment. */
2232
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
2233
+ try {
2234
+ remove(node);
2235
+ } catch (_) {
2236
+ /* Best-effort */
2237
+ }
2238
+ continue;
2239
+ }
2240
+ /* Strip patch-source attributes (the source side) off elements. */
2241
+ if (nodeType === NODE_TYPE.element) {
2242
+ const element = node;
2243
+ const lcTag = transformCaseFunc(_readNodeName(node));
2244
+ try {
2245
+ if (element.hasAttribute && element.hasAttribute('patchsrc')) {
2246
+ element.removeAttribute('patchsrc');
2247
+ }
2248
+ if (element.hasAttribute && element.hasAttribute('for') && _isPatchLinkageAttribute('for', lcTag)) {
2249
+ element.removeAttribute('for');
2250
+ }
2251
+ } catch (_) {
2252
+ /* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */
2253
+ }
2254
+ }
2255
+ const childNodes = getChildNodes(node);
2256
+ if (childNodes) {
2257
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2258
+ stack.push(childNodes[i]);
2259
+ }
2260
+ }
2261
+ }
2262
+ };
2263
+ /**
2264
+ * _initDocument
2265
+ *
2266
+ * @param dirty - a string of dirty markup
2267
+ * @return a DOM, filled with the dirty markup
2268
+ */
2269
+ const _initDocument = function _initDocument(dirty) {
2270
+ /* Create a HTML document */
2271
+ let doc = null;
2272
+ let leadingWhitespace = null;
2273
+ if (FORCE_BODY) {
2274
+ dirty = '<remove></remove>' + dirty;
2275
+ } else {
2276
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
2277
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
2278
+ leadingWhitespace = matches && matches[0];
2279
+ }
2280
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
2281
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
2282
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
2283
+ }
2284
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
2285
+ /*
2286
+ * Use the DOMParser API by default, fallback later if needs be
2287
+ * DOMParser not work for svg when has multiple root element.
2288
+ */
2289
+ if (NAMESPACE === HTML_NAMESPACE) {
2290
+ try {
2291
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
2292
+ } catch (_) {}
2293
+ }
2294
+ /* Use createHTMLDocument in case DOMParser is not available */
2295
+ if (!doc || !doc.documentElement) {
2296
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
2297
+ try {
2298
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
2299
+ } catch (_) {
2300
+ // Syntax error if dirtyPayload is invalid xml
2301
+ }
2302
+ }
2303
+ const body = doc.body || doc.documentElement;
2304
+ if (dirty && leadingWhitespace) {
2305
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
2306
+ }
2307
+ /* Work on whole document or just its body */
2308
+ if (NAMESPACE === HTML_NAMESPACE) {
2309
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
2310
+ }
2311
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
2312
+ };
2313
+ /**
2314
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
2315
+ *
2316
+ * @param root The root element or node to start traversing on.
2317
+ * @return The created NodeIterator
2318
+ */
2319
+ const _createNodeIterator = function _createNodeIterator(root) {
2320
+ /* Read ownerDocument through the cached Node.prototype getter, never the
2321
+ direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a
2322
+ clobbering child (<input name="ownerDocument"> or a form-associated
2323
+ external input) shadows the prototype getter and makes a direct read
2324
+ return that <input>. createNodeIterator.call(<input>, ...) then throws
2325
+ "Illegal invocation", and on the IN_PLACE path that throw lands before
2326
+ the walk's fail-closed barrier - leaving the caller's live tree, with
2327
+ any already-armed handler in it, un-neutralized. The cached getter
2328
+ returns the real Document regardless of the clobber. */
2329
+ const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
2330
+ return createNodeIterator.call(doc || root, root,
2331
+ // eslint-disable-next-line no-bitwise
2332
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
2333
+ };
2334
+ /**
2335
+ * Replace template expression syntax (mustache, ERB, template
2336
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
2337
+ * sites. Order matters: mustache, then ERB, then template literal.
2338
+ *
2339
+ * @param value the string to scrub
2340
+ * @returns the scrubbed string
2341
+ */
2342
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
2343
+ value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
2344
+ value = stringReplace(value, ERB_EXPR$1, ' ');
2345
+ value = stringReplace(value, TMPLIT_EXPR$1, ' ');
2346
+ return value;
2347
+ };
2348
+ /**
2349
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
2350
+ * character data of an element subtree. Used as the final safety net for
2351
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
2352
+ * which only form after text-node normalization (e.g. fragments split across
2353
+ * stripped elements) cannot survive into a template-evaluating framework.
2354
+ *
2355
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
2356
+ * in place rather than round-tripping through innerHTML. This preserves
2357
+ * descendant node references (important for IN_PLACE callers), avoids a
2358
+ * serialize/reparse cycle, and reads literal character data — which means
2359
+ * `<%...%>` in text content matches the ERB regex against its real bytes
2360
+ * instead of the HTML-entity-escaped form innerHTML would produce.
2361
+ *
2362
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
2363
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
2364
+ *
2365
+ * @param node The root element whose character data should be scrubbed.
2366
+ */
2367
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
2368
+ var _node$querySelectorAl;
2369
+ node.normalize();
2370
+ /* Clobber-safe ownerDocument read, same reasoning as _createNodeIterator:
2371
+ under SAFE_FOR_TEMPLATES this runs on the live IN_PLACE root, which may
2372
+ carry a form-named-getter override of ownerDocument. */
2373
+ const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
2374
+ const walker = createNodeIterator.call(doc || node, node,
2375
+ // eslint-disable-next-line no-bitwise
2376
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
2377
+ let currentNode = walker.nextNode();
2378
+ while (currentNode) {
2379
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
2380
+ currentNode = walker.nextNode();
2381
+ }
2382
+ // NodeIterator does not descend into <template>.content per the DOM spec,
2383
+ // so we must explicitly recurse into each template's content fragment,
2384
+ // mirroring the approach used by _sanitizeShadowDOM.
2385
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
2386
+ if (templates) {
2387
+ arrayForEach(templates, tmpl => {
2388
+ if (_isDocumentFragment(tmpl.content)) {
2389
+ _scrubTemplateExpressions2(tmpl.content);
2390
+ }
2391
+ });
2392
+ }
2393
+ };
2394
+ /**
2395
+ * _isClobbered
2396
+ *
2397
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
2398
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
2399
+ * `name` attribute matching a prototype property shadows that property
2400
+ * on direct reads. We use this check at the IN_PLACE entry-point and
2401
+ * during attribute sanitization to refuse clobbered forms.
2402
+ *
2403
+ * @param element element to check for clobbering attacks
2404
+ * @return true if clobbered, false if safe
2405
+ */
2406
+ const _isClobbered = function _isClobbered(element) {
2407
+ // Realm-independent tag-name probe. If we can't determine the tag
2408
+ // name at all, we can't reason about clobbering — return false
2409
+ // (the caller's other defences still apply).
2410
+ const realTagName = getNodeName ? getNodeName(element) : null;
2411
+ if (typeof realTagName !== 'string') {
2412
+ return false;
2413
+ }
2414
+ if (transformCaseFunc(realTagName) !== 'form') {
2415
+ return false;
2416
+ }
2417
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
2418
+ // Realm-safe NamedNodeMap detection: equality against the cached
2419
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
2420
+ // makes the direct read diverge from the cached read; a clean form
2421
+ // (same-realm OR foreign-realm) has both reads pointing at the same
2422
+ // canonical NamedNodeMap.
2423
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
2424
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
2425
+ // returns the integer 1 for any Element regardless of realm; direct
2426
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
2427
+ // the named child element. Cheap addition — nodeType is read from
2428
+ // an internal slot, no serialization cost — and removes a residual
2429
+ // clobbering surface used by several mXSS / PI / comment branches
2430
+ // in _sanitizeElements that compare currentNode.nodeType directly.
2431
+ element.nodeType !== getNodeType(element) ||
2432
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
2433
+ // "childNodes" shadows the prototype getter. Direct reads of
2434
+ // form.childNodes from a clobbered form return the named child
2435
+ // instead of the real NodeList, so any walk that reads it directly
2436
+ // skips the form's real children. Compare the direct read to the
2437
+ // cached Node.prototype getter — when the form's named-property
2438
+ // getter intercepts the read, the two values differ and we flag
2439
+ // the form. This catches every clobbering child type (input,
2440
+ // select, etc.) regardless of whether the named child happens to
2441
+ // carry a numeric .length, which a typeof-based probe would miss
2442
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
2443
+ element.childNodes !== getChildNodes(element);
2444
+ };
2445
+ /**
2446
+ * Checks whether the given value is a DocumentFragment from any realm.
2447
+ *
2448
+ * The realm-independent replacement reads `nodeType` through the cached
2449
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
2450
+ * constant (11). nodeType is a numeric value resolved from the node's
2451
+ * internal slot, identical across realms for the same kind of node.
2452
+ *
2453
+ * @param value object to check
2454
+ * @return true if value is a DocumentFragment-shaped node from any realm
2455
+ */
2456
+ const _isDocumentFragment = function _isDocumentFragment(value) {
2457
+ if (!getNodeType || typeof value !== 'object' || value === null) {
2458
+ return false;
2459
+ }
2460
+ try {
2461
+ return getNodeType(value) === NODE_TYPE.documentFragment;
2462
+ } catch (_) {
2463
+ return false;
2464
+ }
2465
+ };
2466
+ /**
2467
+ * Checks whether the given object is a DOM node, including nodes that
2468
+ * originate from a different window/realm (e.g. an iframe's
2469
+ * contentDocument). The previous `value instanceof Node` check was
2470
+ * realm-bound: nodes from a different window failed it, causing
2471
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
2472
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
2473
+ *
2474
+ * @param value object to check whether it's a DOM node
2475
+ * @return true if value is a DOM node from any realm
2476
+ */
2477
+ const _isNode = function _isNode(value) {
2478
+ if (!getNodeType || typeof value !== 'object' || value === null) {
2479
+ return false;
2480
+ }
2481
+ try {
2482
+ return typeof getNodeType(value) === 'number';
2483
+ } catch (_) {
2484
+ return false;
2485
+ }
2486
+ };
2487
+ function _executeHooks(hooks, currentNode, data) {
2488
+ if (hooks.length === 0) {
2489
+ return;
2490
+ }
2491
+ arrayForEach(hooks, hook => {
2492
+ hook.call(DOMPurify, currentNode, data, CONFIG);
2493
+ });
2494
+ }
2495
+ /**
2496
+ * Structural-threat checks that condemn a node regardless of the
2497
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
2498
+ * processing instructions, markup-bearing comments. Pure predicate;
2499
+ * the caller removes. Check order is load-bearing.
2500
+ *
2501
+ * @param currentNode the node to inspect
2502
+ * @param tagName the node's transformCaseFunc'd tag name
2503
+ * @return true if the node must be removed
2504
+ */
2505
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
2506
+ /* Detect mXSS attempts abusing namespace confusion */
2507
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
2508
+ return true;
2509
+ }
2510
+ /* Remove rawtext/literal-text elements whose literal serialization
2511
+ re-opens markup on an HTML reparse - shapes (a) and (b) documented at
2512
+ LITERAL_TEXT_ELEMENTS. Both are invisible to rule 1 above (which
2513
+ self-disables once there is an element child, and whose second probe
2514
+ reads the innerHTML an XML/XHTML document serializes escaped), which
2515
+ is why both probes here read textContent instead. Previously only
2516
+ `style`-with-element-child was covered; every element in
2517
+ LITERAL_TEXT_ELEMENTS shares this literal serialization and is
2518
+ equally affected. */
2519
+ 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))) {
2520
+ return true;
2521
+ }
2522
+ /* Remove any occurrence of processing instructions */
2523
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
2524
+ return true;
2525
+ }
2526
+ /* Remove any kind of possibly harmful comments */
2527
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
2528
+ return true;
2529
+ }
2530
+ return false;
2531
+ };
2532
+ /**
2533
+ * Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate
2534
+ * function, per the validation in _parseConfig) against a name.
2535
+ * Additional arguments are forwarded to predicate functions - the
2536
+ * attributeNameCheck predicate receives the tag name as its second
2537
+ * argument. A null/absent check never matches.
2538
+ *
2539
+ * @param check the configured tagNameCheck / attributeNameCheck value
2540
+ * @param name the name to test
2541
+ * @param args extra arguments forwarded to a predicate function
2542
+ * @return true if the check matches the name
2543
+ */
2544
+ const _matchesNameCheck = function _matchesNameCheck(check, name) {
2545
+ if (check instanceof RegExp) {
2546
+ return regExpTest(check, name);
2547
+ }
2548
+ if (check instanceof Function) {
2549
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2550
+ args[_key - 2] = arguments[_key];
2551
+ }
2552
+ return Boolean(check(name, ...args));
2553
+ }
2554
+ return false;
2555
+ };
2556
+ /**
2557
+ * Handle a node whose tag is forbidden or not allowlisted: keep
2558
+ * allowed custom elements (false return exits _sanitizeElements
2559
+ * early - the namespace and fallback-tag removal checks are
2560
+ * intentionally skipped for kept custom elements), else hoist
2561
+ * content per KEEP_CONTENT and remove.
2562
+ *
2563
+ * A kept custom element is the ONLY case in which this function
2564
+ * returns false, so the caller uses that return value to run the
2565
+ * afterSanitizeElements hook on the kept element and keep the
2566
+ * element-hook lifecycle consistent with normal allowlisted
2567
+ * elements (GHSA-c2j3-45gr-mqc4).
2568
+ *
2569
+ * @param currentNode the disallowed node
2570
+ * @param tagName the node's transformCaseFunc'd tag name
2571
+ * @return true if the node was removed, false if kept
2572
+ */
2573
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
2574
+ /* Check if we have a custom element to handle */
2575
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2576
+ return false;
2577
+ }
2578
+ /* Keep content except for bad-listed elements.
2579
+ Use the cached prototype getters exclusively — the previous code
2580
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
2581
+ fallbacks, but the cached getters always return the canonical
2582
+ value (or null for a real parent-less node), so the fallback
2583
+ path was dead in safe cases and a clobbering surface in unsafe
2584
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
2585
+ parentNode)` check already gates correctly. */
2586
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2587
+ const parentNode = getParentNode(currentNode);
2588
+ const childNodes = getChildNodes(currentNode);
2589
+ if (childNodes && parentNode) {
2590
+ const childCount = childNodes.length;
2591
+ /* Hoist by moving each child up one level rather than deep-cloning
2592
+ it. Moving transfers every descendant exactly once, so a chain of
2593
+ nested disallowed elements costs O(n) instead of the O(n^2) that
2594
+ re-cloning the shrinking subtree at each level produced; it also
2595
+ empties the removed original, so `DOMPurify.removed` no longer
2596
+ pins whole subtrees. Moving preserves the in-place guarantee too:
2597
+ an original carrying already-queued resource events (`<img
2598
+ onerror>`, `<video>`/`<audio>` error, lazy/`onload`, …) is
2599
+ relocated and sanitised rather than left detached but still armed.
2600
+ The sole case that must clone is removing the walk root itself.
2601
+ The result is serialised from the root's subtree, so a restrictive
2602
+ ALLOWED_TAGS that strips the root (`body` on the string path) must
2603
+ leave the content inside it, which only cloning does. In IN_PLACE
2604
+ the root is pre-validated as an allowed tag and so is never removed
2605
+ here, so that path always takes the move branch.
2606
+ `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
2607
+ valid whether we move (drops the trailing entry) or clone (leaves
2608
+ the list intact). */
2609
+ for (let i = childCount - 1; i >= 0; --i) {
2610
+ const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
2611
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
2612
+ }
2613
+ }
2614
+ }
2615
+ _forceRemove(currentNode);
2616
+ return true;
2617
+ };
2618
+ /**
2619
+ * Fork a hook-mutable allowlist off its shared binding the first time a
2620
+ * (possibly lazily-installed) uponSanitize* hook is about to see it, so the
2621
+ * hook cannot widen the per-instance default or the setConfig binding by
2622
+ * reference and leak past the call. Returns the set unchanged once it is
2623
+ * already call-local, so repeated calls across elements are idempotent.
2624
+ *
2625
+ * @param hookList the uponSanitize* hook array for this event
2626
+ * @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
2627
+ * @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
2628
+ * @param setConfigSet the captured setConfig() binding, or null
2629
+ * @return a call-local clone if a hook is present and set is still shared,
2630
+ * else set unchanged
2631
+ */
2632
+ const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
2633
+ if (hookList.length === 0) {
2634
+ return set;
2635
+ }
2636
+ return set === defaultSet || set === setConfigSet ? clone(set) : set;
2637
+ };
2638
+ /**
2639
+ * Shared guard for a node that a hook has detached from the walk tree,
2640
+ * used after each element-hook site in _sanitizeElements. Detaching is a
2641
+ * long-standing user pattern (issue #469; draw.io-style foreignObject
2642
+ * filtering). Per the cached, unclobberable parentNode getter the node is
2643
+ * genuinely out of the tree, so it can reach neither the serialized
2644
+ * output nor an IN_PLACE live tree; treat it as removed and stop
2645
+ * processing it. Without this guard, the unsafe-node / namespace checks
2646
+ * would call _forceRemove on a parentless node and hit the REPORT-3
2647
+ * fail-closed throw — which exists for nodes DOMPurify wants gone but
2648
+ * *cannot* detach (clobbered / parentless roots), the opposite of a node
2649
+ * that is already safely gone. The walk root is exempt: a detached
2650
+ * IN_PLACE root is legitimate input and must still be fully sanitized,
2651
+ * and a kill-decision on it must keep hitting the REPORT-3 throw.
2652
+ *
2653
+ * Nodes detached by hooks stay the hook's responsibility for placement:
2654
+ * they are not recorded in DOMPurify.removed, so the post-walk IN_PLACE
2655
+ * pass (which iterates DOMPurify.removed) does not reach them. But a
2656
+ * hook-detached subtree can still hold a queued resource-event handler -
2657
+ * e.g. an <img onload> that began loading when the caller built the live
2658
+ * tree - which fires in page scope after sanitize returns even though the
2659
+ * handler never reached the returned tree. That is the audit-5 F1 hazard,
2660
+ * and the documented node.remove() hook pattern walks straight into it.
2661
+ * So on the IN_PLACE path we neutralize the detached subtree inline,
2662
+ * stripping its non-allow-listed attributes before returning, exactly as
2663
+ * the post-walk pass does for _forceRemove'd subtrees.
2664
+ *
2665
+ * @param currentNode the node a hook may have detached
2666
+ * @param root the current walk root
2667
+ * @return true if the node is detached and now handled, false otherwise
2668
+ */
2669
+ const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
2670
+ if (currentNode === root || getParentNode(currentNode) !== null) {
2671
+ return false;
2672
+ }
2673
+ if (IN_PLACE) {
2674
+ _neutralizeSubtree(currentNode);
2675
+ }
2676
+ return true;
2677
+ };
2678
+ /**
2679
+ * _sanitizeElements
2680
+ *
2681
+ * @protect nodeName
2682
+ * @protect textContent
2683
+ * @protect removeChild
2684
+ * @param currentNode to check for permission to exist
2685
+ * @return true if node was killed, false if left alive
2686
+ */
2687
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
2688
+ /* Execute a hook if present */
2689
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2690
+ /* A hook may have detached the node - treat it as removed (see
2691
+ _handleHookDetachedNode for the full rationale). */
2692
+ if (_handleHookDetachedNode(currentNode, root)) {
2693
+ return true;
2694
+ }
2695
+ /* Check if element is clobbered or can clobber */
2696
+ if (_isClobbered(currentNode)) {
2697
+ _forceRemove(currentNode);
2698
+ return true;
2699
+ }
2700
+ /* Now let's check the element's type and name */
2701
+ const tagName = transformCaseFunc(_readNodeName(currentNode));
2702
+ /* Close the pre-walk clone-guard's timing gap: an uponSanitizeElement
2703
+ hook may have been installed after that guard sampled the hook arrays
2704
+ (e.g. lazily from beforeSanitizeElements), leaving ALLOWED_TAGS still
2705
+ aliasing a shared binding that a widening hook would mutate by
2706
+ reference. Fork it before exposing it to the hook. */
2707
+ ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
2708
+ /* Execute a hook if present */
2709
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
2710
+ tagName,
2711
+ allowedTags: ALLOWED_TAGS
2712
+ });
2713
+ /* The uponSanitizeElement hook may have detached the node, exactly as
2714
+ above (see _handleHookDetachedNode for the full rationale). */
2715
+ if (_handleHookDetachedNode(currentNode, root)) {
2716
+ return true;
2717
+ }
2718
+ /* Remove mXSS vectors, processing instructions and risky comments */
2719
+ if (_isUnsafeNode(currentNode, tagName)) {
2720
+ _forceRemove(currentNode);
2721
+ return true;
2722
+ }
2723
+ /* Remove element if anything forbids its presence */
2724
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
2725
+ const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
2726
+ /* A false return means the node is a custom element kept via
2727
+ CUSTOM_ELEMENT_HANDLING - the only keep path through
2728
+ _sanitizeDisallowedNode. Run afterSanitizeElements on it so the
2729
+ element-hook lifecycle matches normal allowlisted elements: a
2730
+ security policy applied in this hook (e.g. stripping an attribute
2731
+ from every surviving element) must not silently skip kept custom
2732
+ elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element
2733
+ tail below - the hook runs, then the walker's subsequent
2734
+ _sanitizeAttributes pass sanitizes the element's attributes. The
2735
+ deliberately skipped namespace and fallback-tag removal checks stay
2736
+ skipped; they are removal decisions, not the hook contract. */
2737
+ if (removed === false) {
2738
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2739
+ }
2740
+ return removed;
2741
+ }
2742
+ /* Check whether element has a valid namespace.
2743
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
2744
+ nodeType getter rather than `instanceof Element`, which is realm-
2745
+ bound and short-circuits to false for any node minted in a different
2746
+ realm — letting a foreign-realm element with a forbidden namespace
2747
+ slip past the namespace check entirely. */
2748
+ const nt = _readNodeType(currentNode);
2749
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
2750
+ _forceRemove(currentNode);
2751
+ return true;
2752
+ }
2753
+ /* Make sure that older browsers don't get fallback-tag mXSS */
2754
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
2755
+ _forceRemove(currentNode);
2756
+ return true;
2757
+ }
2758
+ /* Sanitize element content to be template-safe */
2759
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2760
+ /* Get the element's text content */
2761
+ const content = _stripTemplateExpressions(currentNode.textContent);
2762
+ if (currentNode.textContent !== content) {
2763
+ arrayPush(DOMPurify.removed, {
2764
+ element: currentNode.cloneNode()
2765
+ });
2766
+ currentNode.textContent = content;
2767
+ }
2768
+ }
2769
+ /* Execute a hook if present */
2770
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2771
+ return false;
2772
+ };
2773
+ /**
2774
+ * _isValidAttribute
2775
+ *
2776
+ * @param lcTag Lowercase tag name of containing element.
2777
+ * @param lcName Lowercase attribute name.
2778
+ * @param value Attribute value.
2779
+ * @return Returns true if `value` is valid, otherwise false.
2780
+ */
2781
+ // eslint-disable-next-line complexity
2782
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
2783
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
2784
+ if (FORBID_ATTR[lcName]) {
2785
+ return false;
2786
+ }
2787
+ /* Reject declarative-partial-updates patch-linkage attributes
2788
+ (https://github.com/WICG/declarative-partial-updates).
2789
+ Empirical note (Chrome 150, verified — see
2790
+ test/declarative-patch-probe-v3.html): expansion is NOT applied after
2791
+ sanitization. For the string path it fires during sanitize()'s own
2792
+ parse, so the walk sees and sanitizes the fully materialized expanded
2793
+ tree — teleports into MathML/SVG integration points included; a
2794
+ weaponized `<template for>`->`<img onerror>` comes back with the handler
2795
+ stripped. For the IN_PLACE path it fires on connection, before the walk.
2796
+ Either way DOMPurify is NOT blind to the patch.
2797
+ This removal is therefore defense-in-depth rather than the sole barrier:
2798
+ it prevents live linkage from surviving into the OUTPUT and re-expanding
2799
+ in the caller's context, and keeps behaviour deterministic if a future
2800
+ engine defers expansion. `for` is legitimate only on <label>/<output>;
2801
+ anywhere else (notably <template for>) it links the element to a patch
2802
+ target and teleports or removes an arbitrary DOM range by id/marker name.
2803
+ `patchsrc` fetches remote markup and is treated as a script-loading
2804
+ mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the
2805
+ other structural-threat checks and stays overridable, consistent with
2806
+ the rest of the codebase. PI range markers are already removed by
2807
+ _isUnsafeNode. */
2808
+ if (_isPatchLinkageAttribute(lcName, lcTag)) {
2809
+ return false;
2810
+ }
2811
+ /* Make sure attribute cannot clobber */
2812
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
2813
+ return false;
2814
+ }
2815
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
2816
+ /* Allow valid data-* attributes: At least one character after "-"
2817
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
2818
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
2819
+ We don't need to check the value; it's always URI safe. */
2820
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) {
2821
+ return true;
2822
+ }
2823
+ /* Allow valid aria-* attributes, the value is always URI safe */
2824
+ if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) {
2825
+ return true;
2826
+ }
2827
+ /* A name outside the allowlist is acceptable on custom-element terms
2828
+ only. The value checks below are intentionally skipped in that case:
2829
+ if the user supplied a tagNameCheck we also allow derived custom
2830
+ elements using the same test, and attributes passing the configured
2831
+ attributeNameCheck are allowed as custom elements define these at
2832
+ their own discretion. */
2833
+ if (!nameIsPermitted) {
2834
+ return (
2835
+ // Condition a) covers a basically valid custom element tag name whose
2836
+ // tag passes the configured tagNameCheck and whose attribute name
2837
+ // passes the configured attributeNameCheck ...
2838
+ _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) ||
2839
+ // Condition b) covers an `is` attribute whose value passes the
2840
+ // configured tagNameCheck while customized built-in elements are
2841
+ // allowed.
2842
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)
2843
+ );
2844
+ }
2845
+ /* Check value is safe. First, is attr inert? If so, is safe */
2846
+ if (URI_SAFE_ATTRIBUTES[lcName]) {
2847
+ return true;
2848
+ }
2849
+ /* Check no script, data or unknown possibly unsafe URI
2850
+ unless we know URI values are safe for that attribute */
2851
+ if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) {
2852
+ return true;
2853
+ }
2854
+ /* Keep image data URIs alive if src/xlink:href is allowed */
2855
+ /* Further prevent gadget XSS for dynamically built script tags */
2856
+ if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) {
2857
+ return true;
2858
+ }
2859
+ /* Allow unknown protocols: This provides support for links that
2860
+ are handled by protocol handlers which may be unknown ahead of
2861
+ time, e.g. fb:, spotify: */
2862
+ if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) {
2863
+ return true;
2864
+ }
2865
+ /* Only an empty (binary) value remains safe at this point;
2866
+ anything else is presumed unsafe, do not add it back */
2867
+ return !value;
2868
+ };
2869
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
2870
+ * never be treated as basic custom elements even when a permissive
2871
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
2872
+ 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']);
2873
+ /**
2874
+ * _isBasicCustomElement
2875
+ * checks if at least one dash is included in tagName, and it's not the first char
2876
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
2877
+ *
2878
+ * @param tagName name of the tag of the node to sanitize
2879
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
2880
+ */
2881
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
2882
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
2883
+ };
2884
+ /**
2885
+ * Wrap an attribute value in the matching Trusted Types object when
2886
+ * the active policy requires it. Namespaced attributes pass through
2887
+ * unchanged (no TT support yet, see
2888
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
2889
+ *
2890
+ * @param lcTag lowercase tag name of the containing element
2891
+ * @param lcName lowercase attribute name
2892
+ * @param namespaceURI the attribute's namespace, if any
2893
+ * @param value the attribute value to wrap
2894
+ * @return the value, wrapped when Trusted Types demand it
2895
+ */
2896
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
2897
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
2898
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2899
+ case 'TrustedHTML':
2900
+ {
2901
+ return _createTrustedHTML(value);
2902
+ }
2903
+ case 'TrustedScriptURL':
2904
+ {
2905
+ return _createTrustedScriptURL(value);
2906
+ }
2907
+ }
2908
+ }
2909
+ return value;
2910
+ };
2911
+ /**
2912
+ * Write a modified attribute value back onto the element. On
2913
+ * success, re-probe for clobbering introduced by the new value and
2914
+ * remove the element when found; otherwise pop the removal entry
2915
+ * recorded by the earlier _removeAttribute (long-standing pairing
2916
+ * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
2917
+ * failure, remove the attribute instead.
2918
+ *
2919
+ * @param currentNode the element carrying the attribute
2920
+ * @param name the attribute name as present on the element
2921
+ * @param namespaceURI the attribute's namespace, if any
2922
+ * @param value the new attribute value
2923
+ */
2924
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2925
+ try {
2926
+ if (namespaceURI) {
2927
+ currentNode.setAttributeNS(namespaceURI, name, value);
2928
+ } else {
2929
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
2930
+ currentNode.setAttribute(name, value);
2931
+ }
2932
+ if (_isClobbered(currentNode)) {
2933
+ _forceRemove(currentNode);
2934
+ } else {
2935
+ arrayPop(DOMPurify.removed);
2936
+ }
2937
+ } catch (_) {
2938
+ _removeAttribute(name, currentNode);
2939
+ }
2940
+ };
2941
+ /**
2942
+ * _sanitizeAttributes
2943
+ *
2944
+ * @protect attributes
2945
+ * @protect nodeName
2946
+ * @protect removeAttribute
2947
+ * @protect setAttribute
2948
+ *
2949
+ * @param currentNode to sanitize
2950
+ */
2951
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
2952
+ /* Execute a hook if present */
2953
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2954
+ const attributes = currentNode.attributes;
2955
+ /* Check if we have attributes; if not we might have a text node */
2956
+ if (!attributes || _isClobbered(currentNode)) {
2957
+ return;
2958
+ }
2959
+ /* Same lazy-install guard as uponSanitizeElement (see there): fork the
2960
+ attribute allowlist off its shared binding before a hook can see it. */
2961
+ ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
2962
+ const hookEvent = {
2963
+ attrName: '',
2964
+ attrValue: '',
2965
+ keepAttr: true,
2966
+ allowedAttributes: ALLOWED_ATTR,
2967
+ forceKeepAttr: undefined
2968
+ };
2969
+ let l = attributes.length;
2970
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2971
+ /* Go backwards over all attributes; safely remove bad ones */
2972
+ while (l--) {
2973
+ const attr = attributes[l];
2974
+ const name = attr.name,
2975
+ namespaceURI = attr.namespaceURI,
2976
+ attrValue = attr.value;
2977
+ const lcName = transformCaseFunc(name);
2978
+ const initValue = attrValue;
2979
+ let value = name === 'value' ? initValue : stringTrim(initValue);
2980
+ /* Execute a hook if present */
2981
+ hookEvent.attrName = lcName;
2982
+ hookEvent.attrValue = value;
2983
+ hookEvent.keepAttr = true;
2984
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
2985
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2986
+ value = hookEvent.attrValue;
2987
+ /* Full DOM Clobbering protection via namespace isolation,
2988
+ * Prefix id and name attributes with `user-content-`
2989
+ */
2990
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2991
+ // Remove the attribute with this value
2992
+ _removeAttribute(name, currentNode, attr);
2993
+ // Prefix the value and later re-create the attribute with the sanitized value
2994
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2995
+ }
2996
+ // Else: already prefixed, leave the attribute alone — the prefix is
2997
+ // itself the clobbering protection, and re-applying it is incorrect.
2998
+ /* Work around a security issue with comments inside attributes */
2999
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3000
+ _removeAttribute(name, currentNode, attr);
3001
+ continue;
3002
+ }
3003
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
3004
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
3005
+ _removeAttribute(name, currentNode, attr);
3006
+ continue;
3007
+ }
3008
+ /* Did the hooks force-keep the attribute? */
3009
+ if (hookEvent.forceKeepAttr) {
3010
+ continue;
3011
+ }
3012
+ /* Did the hooks approve of the attribute? */
3013
+ if (!hookEvent.keepAttr) {
3014
+ _removeAttribute(name, currentNode, attr);
3015
+ continue;
3016
+ }
3017
+ /* Work around a security issue in jQuery 3.0 */
3018
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
3019
+ _removeAttribute(name, currentNode, attr);
3020
+ continue;
3021
+ }
3022
+ /* Sanitize attribute content to be template-safe */
3023
+ if (SAFE_FOR_TEMPLATES) {
3024
+ value = _stripTemplateExpressions(value);
3025
+ }
3026
+ /* Is `value` valid for this attribute? */
3027
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3028
+ _removeAttribute(name, currentNode, attr);
3029
+ continue;
3030
+ }
3031
+ /* Handle attributes that require Trusted Types */
3032
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
3033
+ /* Handle invalid data-* attribute set by try-catching it */
3034
+ if (value !== initValue) {
3035
+ _setAttributeValue(currentNode, name, namespaceURI, value);
3036
+ }
3037
+ }
3038
+ /* Execute a hook if present */
3039
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3040
+ };
3041
+ /**
3042
+ * _sanitizeShadowDOM
3043
+ *
3044
+ * @param fragment to iterate over recursively
3045
+ */
3046
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3047
+ let shadowNode = null;
3048
+ const shadowIterator = _createNodeIterator(fragment);
3049
+ /* Execute a hook if present */
3050
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3051
+ while (shadowNode = shadowIterator.nextNode()) {
3052
+ /* Execute a hook if present */
3053
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3054
+ /* Sanitize tags and elements */
3055
+ _sanitizeElements(shadowNode, fragment);
3056
+ /* Check attributes next */
3057
+ _sanitizeAttributes(shadowNode);
3058
+ /* Deep shadow DOM detected.
3059
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
3060
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
3061
+ recurse into <template>.content from foreign realms too. */
3062
+ if (_isDocumentFragment(shadowNode.content)) {
3063
+ _sanitizeShadowDOM2(shadowNode.content);
3064
+ }
3065
+ /* An element iterated here may itself host an attached
3066
+ shadow root. The default NodeIterator does not enter shadow
3067
+ trees, so a shadow root nested inside template.content was
3068
+ previously reached by no walk at all (the pre-pass at
3069
+ _sanitizeAttachedShadowRoots descends via childNodes, which
3070
+ doesn't enter template.content; the template-content recursion
3071
+ above iterates the content but never inspected shadowRoot).
3072
+ Walk it explicitly. The nodeType guard avoids reading
3073
+ shadowRoot off text / comment / CDATA / PI nodes that the
3074
+ iterator also surfaces. */
3075
+ if (_readNodeType(shadowNode) === NODE_TYPE.element) {
3076
+ const innerSr = getShadowRoot(shadowNode);
3077
+ if (_isDocumentFragment(innerSr)) {
3078
+ _sanitizeAttachedShadowRoots(innerSr);
3079
+ _sanitizeShadowDOM2(innerSr);
3080
+ }
3081
+ }
3082
+ }
3083
+ /* Execute a hook if present */
3084
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3085
+ };
3086
+ /**
3087
+ * _sanitizeAttachedShadowRoots
3088
+ *
3089
+ * Walks `root` and feeds every attached shadow root we encounter into
3090
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
3091
+ * does not descend into shadow trees, so nodes inside an attached
3092
+ * shadow root would otherwise be skipped entirely.
3093
+ *
3094
+ * Two real input paths put attached shadow roots in front of us:
3095
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
3096
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
3097
+ * shadow root because it was created with `clonable: true`.
3098
+ *
3099
+ * This pass runs once, up front, so the main iteration loop (and the
3100
+ * existing _sanitizeShadowDOM template-content recursion) stay
3101
+ * untouched — string-input paths are not affected.
3102
+ *
3103
+ * @param root the subtree root to walk for attached shadow roots
3104
+ */
3105
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
3106
+ /* Iterative (explicit stack) rather than per-child recursion. DOM APIs
3107
+ impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
3108
+ built straight into the DOM — the IN_PLACE surface) deeper than the JS
3109
+ call-stack budget would otherwise overflow native recursion here and
3110
+ throw at the IN_PLACE entry pre-pass, before a single node is
3111
+ sanitized, leaving the caller's live tree untouched (fail-open). See
3112
+ campaign-3 F4. A heap stack keeps depth off the call stack.
3113
+ Each work item is either a node to descend into, or a deferred
3114
+ `_sanitizeShadowDOM` for an already-walked shadow root. The deferred
3115
+ form preserves the original post-order discipline: a shadow root's
3116
+ nested shadow roots are discovered before the outer shadow is
3117
+ sanitized (which may remove hosts). Pushes are in reverse of the
3118
+ desired processing order (LIFO): template content, then children, then
3119
+ the shadow-sanitize, then the shadow walk — so the order matches the
3120
+ previous recursion exactly. */
3121
+ const stack = [{
3122
+ node: root,
3123
+ shadow: null
3124
+ }];
3125
+ while (stack.length > 0) {
3126
+ const item = stack.pop();
3127
+ /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
3128
+ if (item.shadow) {
3129
+ _sanitizeShadowDOM2(item.shadow);
3130
+ continue;
3131
+ }
3132
+ const node = item.node;
3133
+ const nodeType = _readNodeType(node);
3134
+ const isElement = nodeType === NODE_TYPE.element;
3135
+ /* (pushed last → processed first) Children, snapshotted in reverse so
3136
+ the first child is processed first. Snapshotting matters because a
3137
+ hook may detach siblings mid-walk. */
3138
+ const childNodes = getChildNodes(node);
3139
+ if (childNodes) {
3140
+ for (let i = childNodes.length - 1; i >= 0; --i) {
3141
+ stack.push({
3142
+ node: childNodes[i],
3143
+ shadow: null
3144
+ });
3145
+ }
3146
+ }
3147
+ /* (pushed before children → processed after them, matching the old
3148
+ "template content last" order) When the node is a <template>,
3149
+ descend into its content. */
3150
+ if (isElement) {
3151
+ const rootName = getNodeName ? getNodeName(node) : null;
3152
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
3153
+ const content = node.content;
3154
+ if (_isDocumentFragment(content)) {
3155
+ stack.push({
3156
+ node: content,
3157
+ shadow: null
3158
+ });
3159
+ }
3160
+ }
3161
+ }
3162
+ /* Shadow root (processed first): walk its subtree, then sanitise it.
3163
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
3164
+ rather than `instanceof DocumentFragment`, which is realm-bound and
3165
+ silently skipped foreign-realm shadow roots (e.g.
3166
+ iframe.contentDocument attachShadow). */
3167
+ if (isElement) {
3168
+ const sr = getShadowRoot(node);
3169
+ if (_isDocumentFragment(sr)) {
3170
+ /* Push the deferred sanitise first so it pops after the shadow
3171
+ walk we push next, i.e. nested shadow roots are discovered
3172
+ before this one is sanitised. */
3173
+ stack.push({
3174
+ node: null,
3175
+ shadow: sr
3176
+ }, {
3177
+ node: sr,
3178
+ shadow: null
3179
+ });
3180
+ }
3181
+ }
3182
+ }
3183
+ };
3184
+ // eslint-disable-next-line complexity
3185
+ DOMPurify.sanitize = function (dirty) {
3186
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3187
+ let body = null;
3188
+ let importedNode = null;
3189
+ let currentNode = null;
3190
+ let returnNode = null;
3191
+ /* Make sure we have a string to sanitize.
3192
+ DO NOT return early, as this will return the wrong type if
3193
+ the user has requested a DOM object rather than a string */
3194
+ IS_EMPTY_INPUT = !dirty;
3195
+ if (IS_EMPTY_INPUT) {
3196
+ dirty = '<!-->';
3197
+ }
3198
+ /* Stringify, in case dirty is an object */
3199
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
3200
+ dirty = stringifyValue(dirty);
3201
+ if (typeof dirty !== 'string') {
3202
+ throw typeErrorCreate('dirty is not a string, aborting');
3203
+ }
3204
+ }
3205
+ /* Return dirty HTML if DOMPurify cannot run */
3206
+ if (!DOMPurify.isSupported) {
3207
+ return dirty;
3208
+ }
3209
+ /* Assign config vars */
3210
+ if (SET_CONFIG) {
3211
+ /* Persistent setConfig() path: _parseConfig is skipped, so the sets are
3212
+ * not re-derived per call. Restore them from the pristine bindings
3213
+ * captured at setConfig() time so a previous call's hook clone (mutated
3214
+ * below) does not carry over. */
3215
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
3216
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
595
3217
  } else {
596
- setPost(unreadcount);
3218
+ _parseConfig(cfg);
3219
+ }
3220
+ /* Clone the hook-mutable allowlists before the walk whenever an
3221
+ * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
3222
+ * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
3223
+ * a hook that widens them would otherwise mutate the shared set
3224
+ * permanently: across later calls and across every element. Cloning per
3225
+ * walk keeps documented in-call widening working while scoping it to the
3226
+ * call. A single guard for both config paths - the per-call path rebinds
3227
+ * the sets in _parseConfig each call, the persistent path restores them
3228
+ * from the captured bindings just above - so the two cannot diverge. */
3229
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
3230
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
3231
+ }
3232
+ if (hooks.uponSanitizeAttribute.length > 0) {
3233
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
3234
+ }
3235
+ /* Clean up removed elements */
3236
+ DOMPurify.removed = [];
3237
+ /* Resolve IN_PLACE for this call without mutating persistent config.
3238
+ Writing the IN_PLACE closure variable here leaks under setConfig(),
3239
+ where _parseConfig is skipped on later calls: a single string call would
3240
+ disable in-place mode for every subsequent node call, returning a
3241
+ sanitized copy while leaving the caller's node — which in-place callers
3242
+ keep using and whose return value they ignore — unsanitized. REPORT-2. */
3243
+ const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
3244
+ if (inPlace) {
3245
+ /* Declarative-partial-updates / streaming pre-pass: sever every patch
3246
+ linkage across the live tree BEFORE the walk, so no patch can fire
3247
+ mid-walk and inject into an already-processed region. Runs first, so
3248
+ it also covers the forbidden/clobbered roots that throw below. */
3249
+ _neutralizePatchLinkage(dirty);
3250
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
3251
+ Read nodeName through the cached prototype getter — a clobbering
3252
+ child named "nodeName" on the form root would otherwise shadow
3253
+ the property and let this check skip the root-allowlist
3254
+ validation entirely. */
3255
+ const nn = _readNodeName(dirty);
3256
+ if (typeof nn === 'string') {
3257
+ const tagName = transformCaseFunc(nn);
3258
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3259
+ /* Fail closed on a live root: neutralize handlers/children before
3260
+ throwing, exactly as the mid-walk abort path does. */
3261
+ _neutralizeRoot(dirty);
3262
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
3263
+ }
3264
+ }
3265
+ /* Pre-flight the root through _isClobbered. The iterator-driven
3266
+ removal path can not detach a parent-less root: _forceRemove
3267
+ falls through to Element.prototype.remove(), which per spec
3268
+ is a no-op on a node with no parent. A clobbered root would
3269
+ then survive the main loop with its attributes uninspected,
3270
+ because _sanitizeAttributes early-returns on _isClobbered. The
3271
+ result would be an attacker-controlled form, complete with any
3272
+ event-handler attributes the caller passed in, handed back to
3273
+ the application unsanitized. Refuse to sanitize such a root
3274
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
3275
+ if (_isClobbered(dirty)) {
3276
+ /* Fail closed on a live clobbered root before throwing.
3277
+ _neutralizeRoot's reads are clobber-safe (cached getters); the
3278
+ form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */
3279
+ _neutralizeRoot(dirty);
3280
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
3281
+ }
3282
+ /* Sanitize attached shadow roots before the main iterator runs.
3283
+ The iterator does not descend into shadow trees. Same fail-closed
3284
+ barrier as the main walk (campaign-3 F2): a custom-element reaction
3285
+ inside a shadow root could abort this pre-pass before the walk runs,
3286
+ which would otherwise leave the entire live tree unsanitized. */
3287
+ try {
3288
+ _sanitizeAttachedShadowRoots(dirty);
3289
+ } catch (error) {
3290
+ _neutralizeRoot(dirty);
3291
+ throw error;
3292
+ }
3293
+ } else if (_isNode(dirty)) {
3294
+ /* If dirty is a DOM element, append to an empty document to avoid
3295
+ elements being stripped by the parser */
3296
+ body = _initDocument('<!---->');
3297
+ importedNode = body.ownerDocument.importNode(dirty, true);
3298
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
3299
+ /* Node is already a body, use as is */
3300
+ body = importedNode;
3301
+ } else if (importedNode.nodeName === 'HTML') {
3302
+ body = importedNode;
3303
+ } else {
3304
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
3305
+ body.appendChild(importedNode);
3306
+ }
3307
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
3308
+ them before the main iterator runs, since the iterator does not
3309
+ descend into shadow trees. The walk routes every read through a
3310
+ cached prototype getter so clobbering descendants on a form root
3311
+ cannot hide a shadow host from this pass. */
3312
+ _sanitizeAttachedShadowRoots(importedNode);
3313
+ } else {
3314
+ /* Exit directly if we have nothing to do */
3315
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
3316
+ // eslint-disable-next-line unicorn/prefer-includes
3317
+ dirty.indexOf('<') === -1) {
3318
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
3319
+ }
3320
+ /* Initialize the document to work on */
3321
+ body = _initDocument(dirty);
3322
+ /* Check we have a DOM node from the data */
3323
+ if (!body) {
3324
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
3325
+ }
597
3326
  }
598
- logConsole(configLogs, 'data', '', unreadcount);
599
- const favoriteValue = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
600
- if (type === 'get' && favoriteValue === true) {
601
- setColor('#ffcd38');
602
- } else if (type === 'set') {
603
- setColor('#ffcd38');
604
- localStorage.setItem('favoritessynch01', 'true');
605
- localStorage.setItem('favoritessynch02', 'true');
606
- window.dispatchEvent(new Event('favorites'));
607
- } else if (type === 'del') {
608
- setColor('');
609
- localStorage.setItem('favoritessynch01', 'true');
610
- localStorage.setItem('favoritessynch02', 'true');
611
- window.dispatchEvent(new Event('favorites'));
3327
+ /* Remove first element node (ours) if FORCE_BODY is set */
3328
+ if (body && FORCE_BODY) {
3329
+ _forceRemove(body.firstChild);
3330
+ }
3331
+ /* Get node iterator */
3332
+ const walkRoot = inPlace ? dirty : body;
3333
+ /* Now start iterating over the created document.
3334
+ The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
3335
+ engine/custom-element mutation can detach a node mid-walk so
3336
+ `_forceRemove`'s parentless guard throws, aborting the loop. Without the
3337
+ barrier the caller's in-place tree would be left half-sanitized with the
3338
+ unvisited tail still armed. _createNodeIterator itself is inside the
3339
+ barrier too: constructing the iterator dereferences the root's document,
3340
+ and any failure there (e.g. an exotic/clobbered root) must still fail
3341
+ closed rather than skip the neutralize. On any throw we fail closed -
3342
+ strip the in-place root bare - then rethrow so the existing throw
3343
+ contract is preserved. (String/DOM-copy paths never return the partial
3344
+ body, so the propagating throw is already fail-closed there.) */
3345
+ try {
3346
+ const nodeIterator = _createNodeIterator(walkRoot);
3347
+ while (currentNode = nodeIterator.nextNode()) {
3348
+ /* Sanitize tags and elements */
3349
+ _sanitizeElements(currentNode, walkRoot);
3350
+ /* Check attributes next */
3351
+ _sanitizeAttributes(currentNode);
3352
+ /* Shadow DOM detected, sanitize it.
3353
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
3354
+ instead of instanceof, so foreign-realm <template>.content is
3355
+ walked correctly. */
3356
+ if (_isDocumentFragment(currentNode.content)) {
3357
+ _sanitizeShadowDOM2(currentNode.content);
3358
+ }
3359
+ }
3360
+ } catch (error) {
3361
+ if (inPlace) {
3362
+ _neutralizeRoot(dirty);
3363
+ /* Nodes _forceRemove'd earlier in the aborted walk are already
3364
+ detached from the root, so _neutralizeRoot's subtree pass does not
3365
+ reach them. Defuse them too, mirroring the success-path loop below. */
3366
+ arrayForEach(DOMPurify.removed, entry => {
3367
+ if (entry.element) {
3368
+ _neutralizeSubtree(entry.element);
3369
+ }
3370
+ });
3371
+ }
3372
+ throw error;
612
3373
  }
613
- setIsError(false);
614
- } catch (err) {
615
- setError(true);
616
- handleError$3(err, t, configLogs, setIsError, setMessageerror);
617
- } finally {
618
- setLoading(false);
619
- }
620
- };
621
- const serviceGetFavorites = async (fpHash = '', sessionID, postURL, cxauthxc, t, setPost, setIsError, setError, setMessageerror, setLoading, configLogs, ...rest) => {
622
- const visitorIdHash = await getOrSetFingerprint(fpHash);
623
- try {
624
- const requestData = {
625
- ...rest[0],
626
- sessionID,
627
- cxauthxc,
628
- postServerURL: postURL,
629
- authorization: true,
630
- fingerprint: visitorIdHash
631
- };
632
- const unreadcount = await getservice(requestData, configLogs);
633
- const responseData = unreadcount && typeof unreadcount === 'object' && 'data' in unreadcount && !Array.isArray(unreadcount) ? unreadcount.data : unreadcount;
634
- setPost(responseData);
635
- localStorage.setItem('favoritessynch03', JSON.stringify(responseData));
636
- logConsole(configLogs, 'data', '', unreadcount);
637
- setIsError(false);
638
- } catch (err) {
639
- setError(true);
640
- handleError$3(err, t, configLogs, setIsError, setMessageerror);
641
- } finally {
642
- setLoading(false);
643
- }
644
- };
645
-
646
- const defaultConfig$3 = {
647
- enableLogs: false,
648
- enableLogsError: false,
649
- enableLogsWarning: false,
650
- enableLogsInfo: false,
651
- enableLogsData: false,
652
- enableLogsDebug: false,
653
- developmentMode: false
654
- };
655
- const ConexysConfigContext = /*#__PURE__*/React.createContext(defaultConfig$3);
656
- const ConexysConfigProvider = ({
657
- children,
658
- config = {}
659
- }) => {
660
- const mergedConfig = {
661
- ...defaultConfig$3,
662
- ...config
3374
+ /* If we sanitized `dirty` in-place, return it. */
3375
+ if (inPlace) {
3376
+ /* Fail-closed completion of the audit-5 F1 fix: every node removed from
3377
+ the caller's live tree is detached but may still hold a queued
3378
+ resource-event handler that fires in page scope after we return. The
3379
+ move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
3380
+ non-allow-listed attributes off every other removed subtree (clobber,
3381
+ mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
3382
+ cancelled before any event can fire. Runs synchronously, pre-return. */
3383
+ arrayForEach(DOMPurify.removed, entry => {
3384
+ if (entry.element) {
3385
+ _neutralizeSubtree(entry.element);
3386
+ }
3387
+ });
3388
+ if (SAFE_FOR_TEMPLATES) {
3389
+ _scrubTemplateExpressions2(dirty);
3390
+ }
3391
+ return dirty;
3392
+ }
3393
+ /* Return sanitized string or DOM */
3394
+ if (RETURN_DOM) {
3395
+ if (SAFE_FOR_TEMPLATES) {
3396
+ _scrubTemplateExpressions2(body);
3397
+ }
3398
+ if (RETURN_DOM_FRAGMENT) {
3399
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3400
+ while (body.firstChild) {
3401
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
3402
+ returnNode.appendChild(body.firstChild);
3403
+ }
3404
+ } else {
3405
+ returnNode = body;
3406
+ }
3407
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3408
+ /*
3409
+ AdoptNode() is not used because internal state is not reset
3410
+ (e.g. the past names map of a HTMLFormElement), this is safe
3411
+ in theory but we would rather not risk another attack vector.
3412
+ The state that is cloned by importNode() is explicitly defined
3413
+ by the specs.
3414
+ */
3415
+ returnNode = importNode.call(originalDocument, returnNode, true);
3416
+ }
3417
+ return returnNode;
3418
+ }
3419
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3420
+ /* Serialize doctype if allowed */
3421
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3422
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
3423
+ }
3424
+ /* Sanitize final string template-safe */
3425
+ if (SAFE_FOR_TEMPLATES) {
3426
+ serializedHTML = _stripTemplateExpressions(serializedHTML);
3427
+ }
3428
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
3429
+ };
3430
+ DOMPurify.setConfig = function () {
3431
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3432
+ _parseConfig(cfg);
3433
+ SET_CONFIG = true;
3434
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
3435
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
3436
+ };
3437
+ DOMPurify.clearConfig = function () {
3438
+ CONFIG = null;
3439
+ SET_CONFIG = false;
3440
+ SET_CONFIG_ALLOWED_TAGS = null;
3441
+ SET_CONFIG_ALLOWED_ATTR = null;
3442
+ // Drop any caller-supplied Trusted Types policy so it cannot poison later
3443
+ // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
3444
+ // never recreated — Trusted Types throws on duplicate names) is restored by
3445
+ // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
3446
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
3447
+ emptyHTML = '';
3448
+ };
3449
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
3450
+ /* Initialize shared config vars if necessary. */
3451
+ if (!CONFIG) {
3452
+ _parseConfig({});
3453
+ }
3454
+ const lcTag = transformCaseFunc(tag);
3455
+ const lcName = transformCaseFunc(attr);
3456
+ return _isValidAttribute(lcTag, lcName, value);
3457
+ };
3458
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
3459
+ if (typeof hookFunction !== 'function') {
3460
+ return;
3461
+ }
3462
+ /* Reject unknown entry points. Without this, a non-hook key (e.g.
3463
+ * '__proto__') indexes off the prototype chain rather than a real
3464
+ * hook array, and arrayPush then writes to Object.prototype. Guard
3465
+ * with an own-property check against the known hook names. */
3466
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3467
+ return;
3468
+ }
3469
+ arrayPush(hooks[entryPoint], hookFunction);
663
3470
  };
664
- return /*#__PURE__*/React.createElement(ConexysConfigContext.Provider, {
665
- value: mergedConfig
666
- }, children);
667
- };
668
- const useConexysConfig = () => {
669
- return React.useContext(ConexysConfigContext);
670
- };
671
- const isDevelopmentMode = config => {
672
- return config.developmentMode;
673
- };
674
-
675
- const config$3 = {
676
- headers: {
677
- 'Content-Type': 'application/json'
678
- }
679
- };
680
- function AppDataSettings({
681
- keys
682
- }) {
683
- const configLogs = useConexysConfig();
684
- const postURL = Url + 'getsettings';
685
- const [post, setPost] = React.useState(null);
686
- const [error, setError] = React.useState(false);
687
- const hasFetched = React.useRef(false);
688
- const fetchData = React.useCallback(async () => {
689
- if (hasFetched.current) return;
690
- hasFetched.current = true;
691
- try {
692
- await serviceData(postURL, {
693
- keys: keys
694
- }, config$3, setPost, configLogs);
695
- } catch (err) {
696
- setError(true);
697
- logConsole(configLogs, 'error', 'Error fetching data:', err);
698
- console.error('Error fetching data:', err);
3471
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
3472
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3473
+ return undefined;
699
3474
  }
700
- }, []);
701
- React.useEffect(() => {
702
- fetchData();
703
- }, [fetchData]);
704
- if (!post) return null;
705
- return /*#__PURE__*/React.createElement(React.Fragment, null, error ? /*#__PURE__*/React.createElement("div", null, "Error loading data") : post);
3475
+ if (hookFunction !== undefined) {
3476
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3477
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
3478
+ }
3479
+ return arrayPop(hooks[entryPoint]);
3480
+ };
3481
+ DOMPurify.removeHooks = function (entryPoint) {
3482
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3483
+ return;
3484
+ }
3485
+ hooks[entryPoint] = [];
3486
+ };
3487
+ DOMPurify.removeAllHooks = function () {
3488
+ hooks = _createHooksMap();
3489
+ };
3490
+ return DOMPurify;
3491
+ }
3492
+ var purify = createDOMPurify();
3493
+
3494
+ function sanitizeHtml(html) {
3495
+ if (!html) return '';
3496
+ return purify.sanitize(html);
706
3497
  }
707
3498
 
708
3499
  const config$2 = {
@@ -737,7 +3528,7 @@ function AppDataSettingsHTML({
737
3528
  if (!htmlString) return null;
738
3529
  return /*#__PURE__*/React.createElement(React.Fragment, null, error ? (/*#__PURE__*/React.createElement("div", null, "Error loading data")) : (/*#__PURE__*/React.createElement("div", {
739
3530
  dangerouslySetInnerHTML: {
740
- __html: htmlString
3531
+ __html: sanitizeHtml(htmlString)
741
3532
  }
742
3533
  })));
743
3534
  }
@@ -831,14 +3622,18 @@ const postFormService = async (datauser, configLogs) => {
831
3622
  }
832
3623
  }
833
3624
  const dataload = [restData, valueToPush];
3625
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
834
3626
  let config;
835
3627
  let datasend;
836
3628
  if (authorization === true) {
837
3629
  config = {
3630
+ withCredentials: true,
838
3631
  headers: {
839
3632
  Authorization: `Bearer ${datauser.cxauthxc}`,
3633
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
840
3634
  'X-Session-ID': datauser.sessionID || '',
841
3635
  'X-Fingerprint': datauser.fingerprint || '',
3636
+ 'X-Session-Type': xSessionType,
842
3637
  'Content-Type': 'application/json'
843
3638
  }
844
3639
  };
@@ -858,7 +3653,9 @@ const postFormService = async (datauser, configLogs) => {
858
3653
  }
859
3654
  } else {
860
3655
  config = {
3656
+ withCredentials: true,
861
3657
  headers: {
3658
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
862
3659
  'Content-Type': 'application/json'
863
3660
  }
864
3661
  };
@@ -912,14 +3709,18 @@ const patchFormService = async (datauser, configLogs) => {
912
3709
  }
913
3710
  }
914
3711
  const dataload = [restData, valueToPush];
3712
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
915
3713
  let config;
916
3714
  let datasend;
917
3715
  if (authorization === true) {
918
3716
  config = {
3717
+ withCredentials: true,
919
3718
  headers: {
920
3719
  Authorization: `Bearer ${datauser.cxauthxc}`,
3720
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
921
3721
  'X-Session-ID': datauser.sessionID || '',
922
3722
  'X-Fingerprint': datauser.fingerprint || '',
3723
+ 'X-Session-Type': xSessionType,
923
3724
  'Content-Type': 'application/json'
924
3725
  }
925
3726
  };
@@ -939,7 +3740,9 @@ const patchFormService = async (datauser, configLogs) => {
939
3740
  }
940
3741
  } else {
941
3742
  config = {
3743
+ withCredentials: true,
942
3744
  headers: {
3745
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
943
3746
  'Content-Type': 'application/json'
944
3747
  }
945
3748
  };
@@ -976,11 +3779,15 @@ const deleteFormService = async (datauser, configLogs) => {
976
3779
  ...datasend
977
3780
  } = datauser;
978
3781
  const logs = configLogs || defaultConfig$2;
3782
+ const xSessionType = authStorage.getSessionTypeValue(logs);
979
3783
  const config = {
3784
+ withCredentials: true,
980
3785
  headers: {
981
3786
  Authorization: `Bearer ${cxauthxc}`,
3787
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
982
3788
  'X-Session-ID': datauser.sessionID || '',
983
3789
  'X-Fingerprint': datauser.fingerprint || '',
3790
+ 'X-Session-Type': xSessionType,
984
3791
  'Content-Type': 'application/json'
985
3792
  }
986
3793
  };
@@ -1019,11 +3826,15 @@ const restoreFormService = async (datauser, configLogs) => {
1019
3826
  ...datasend
1020
3827
  } = datauser;
1021
3828
  const logs = configLogs || defaultConfig$1;
3829
+ const xSessionType = authStorage.getSessionTypeValue(logs);
1022
3830
  const config = {
3831
+ withCredentials: true,
1023
3832
  headers: {
1024
3833
  Authorization: `Bearer ${cxauthxc}`,
3834
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
1025
3835
  'X-Session-ID': datauser.sessionID || '',
1026
3836
  'X-Fingerprint': datauser.fingerprint || '',
3837
+ 'X-Session-Type': xSessionType,
1027
3838
  'Content-Type': 'application/json'
1028
3839
  }
1029
3840
  };
@@ -1042,7 +3853,7 @@ var restoreFormService$1 = {
1042
3853
  restoreFormService
1043
3854
  };
1044
3855
 
1045
- const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, id, restoreServerURL, feedback, method = 'post', restoreMethod = 'post', fetchMethod = 'post') => {
3856
+ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, id, restoreServerURL, feedback, method = 'post', restoreMethod = 'post', fetchMethod = 'post', allowEmptyIdFetch = false) => {
1046
3857
  const configLogs = useConexysConfig();
1047
3858
  const [t] = reactI18next.useTranslation('global');
1048
3859
  const MySwal = withReactContent(SweetAlert2);
@@ -1054,16 +3865,19 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1054
3865
  const [error, setError] = React.useState(false);
1055
3866
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
1056
3867
  const sessionID = authStorage.getSessionId(configLogs) || '';
3868
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1057
3869
  const iditem = id;
1058
3870
  const authorization = true;
1059
3871
  const updateDataUser = async visitorIdHash => {
1060
3872
  const getProfile = Url + 'getprofile';
1061
3873
  try {
1062
3874
  const response = await axios.get(getProfile, {
3875
+ withCredentials: true,
1063
3876
  headers: {
1064
3877
  Authorization: `Bearer ${cxauthxc}`,
1065
3878
  'X-Session-ID': sessionID,
1066
3879
  'X-Fingerprint': visitorIdHash,
3880
+ 'X-Session-Type': xSessionType,
1067
3881
  'Content-Type': 'application/json'
1068
3882
  }
1069
3883
  });
@@ -1209,6 +4023,7 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1209
4023
  Authorization: `Bearer ${cxauthxc}`,
1210
4024
  'X-Session-ID': sessionID,
1211
4025
  'X-Fingerprint': fpHash,
4026
+ 'X-Session-Type': xSessionType,
1212
4027
  'Content-Type': 'application/json'
1213
4028
  }
1214
4029
  }), [cxauthxc, sessionID, fpHash]);
@@ -1221,7 +4036,7 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1221
4036
  React.useEffect(() => {
1222
4037
  const setFp = async () => {
1223
4038
  setCheckdata(false);
1224
- if (id !== '') {
4039
+ if (id !== '' || allowEmptyIdFetch) {
1225
4040
  const visitorIdHash = await getOrSetFingerprint(fpHash, configLogs);
1226
4041
  const key = {
1227
4042
  sessionID: sessionID,
@@ -1231,11 +4046,21 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1231
4046
  try {
1232
4047
  let response;
1233
4048
  if (fetchMethod === 'get') {
1234
- const url = getServerURL + id;
1235
- response = await axios.get(url, config);
4049
+ const url = id !== '' ? getServerURL + id : getServerURL;
4050
+ response = await axios.get(url, {
4051
+ ...config,
4052
+ withCredentials: true
4053
+ });
1236
4054
  logConsole(configLogs, 'info', '[Request] ', url);
1237
4055
  } else {
1238
- response = await axios.post(getServerURL, key, config);
4056
+ response = await axios.post(getServerURL, key, {
4057
+ ...config,
4058
+ withCredentials: true,
4059
+ headers: {
4060
+ ...(config?.headers || {}),
4061
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
4062
+ }
4063
+ });
1239
4064
  logConsole(configLogs, 'info', '[Request] ', getServerURL);
1240
4065
  }
1241
4066
  const responseData = response.data;
@@ -1251,7 +4076,7 @@ const useCustomForm$3 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
1251
4076
  }
1252
4077
  };
1253
4078
  setFp();
1254
- }, [id]);
4079
+ }, [id, allowEmptyIdFetch]);
1255
4080
  return {
1256
4081
  handleFormSubmit,
1257
4082
  handleInputChange,
@@ -1280,17 +4105,20 @@ function AppFormFields({
1280
4105
  permission,
1281
4106
  show,
1282
4107
  feedback,
1283
- method = 'post'
4108
+ method = 'post',
4109
+ allowEmptyIdFetch = false
1284
4110
  }) {
1285
4111
  const configLogs = useConexysConfig();
1286
4112
  const [t] = reactI18next.useTranslation('global');
1287
4113
  const authTokens = authStorage.getAuthToken(configLogs) || '';
1288
4114
  const authTokensSes = authStorage.getSessionId(configLogs) || '';
4115
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1289
4116
  const config = React.useMemo(() => ({
1290
4117
  headers: {
1291
4118
  Authorization: `Bearer ${authTokens}`,
1292
4119
  'X-Session-ID': authTokensSes,
1293
4120
  'X-Fingerprint': fpHash,
4121
+ 'X-Session-Type': xSessionType,
1294
4122
  'Content-Type': 'application/json'
1295
4123
  }
1296
4124
  }), [authTokens, authTokensSes, fpHash]);
@@ -1317,7 +4145,7 @@ function AppFormFields({
1317
4145
  formInputs,
1318
4146
  handleInputChange,
1319
4147
  handleFormSubmit
1320
- } = useCustomForm$3(fpHash, postServerURL1, getServerURL1, deleteServerURL1, id1, '', feedback, method, 'post', 'get');
4148
+ } = useCustomForm$3(fpHash, postServerURL1, getServerURL1, deleteServerURL1, id1, '', feedback, method, 'post', 'get', allowEmptyIdFetch);
1321
4149
  if (!post) return null;
1322
4150
  const dataform = JSON.parse(post.data);
1323
4151
  let permissionstatus;
@@ -1363,6 +4191,7 @@ function AppFormFields({
1363
4191
  maxLength: block.maxlength,
1364
4192
  pattern: block.pattern
1365
4193
  },
4194
+ showPasswordToggle: block.showPasswordToggle,
1366
4195
  items: block.items
1367
4196
  }, 'form')), additionalfields1.content.body.map(block => RenderForm({
1368
4197
  component: block.component,
@@ -1386,6 +4215,7 @@ function AppFormFields({
1386
4215
  maxLength: block.maxlength,
1387
4216
  pattern: block.pattern
1388
4217
  },
4218
+ showPasswordToggle: block.showPasswordToggle,
1389
4219
  items: block.items
1390
4220
  }, 'form')), children);
1391
4221
  }
@@ -1460,6 +4290,7 @@ function AppFormFieldsFromConfig({
1460
4290
  maxLength: block.maxlength || block.validate && block.validate.maxLength,
1461
4291
  pattern: block.pattern || block.validate && block.validate.pattern
1462
4292
  },
4293
+ showPasswordToggle: block.showPasswordToggle,
1463
4294
  items: block.items || []
1464
4295
  }, nouser || 'user')));
1465
4296
  }
@@ -1480,6 +4311,7 @@ const useCustomForm$2 = (postServerURL, setAuth, message, dependencies = {}) =>
1480
4311
  const {
1481
4312
  setAuthTokens
1482
4313
  } = typeof externalUseAuth === 'function' ? externalUseAuth() : externalUseAuth || useAuth();
4314
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1483
4315
  const [t] = reactI18next.useTranslation('global');
1484
4316
  const MySwal = withReactContent(SweetAlert2);
1485
4317
  const [formInputs, setFormInputs] = React.useState({});
@@ -1536,11 +4368,14 @@ const useCustomForm$2 = (postServerURL, setAuth, message, dependencies = {}) =>
1536
4368
  try {
1537
4369
  const postServerURL2 = Url + 'authTwostep';
1538
4370
  const config = {
4371
+ withCredentials: true,
1539
4372
  headers: {
1540
4373
  Authorization: `Bearer ${dataform.auth}`,
1541
4374
  'X-Session-ID': dataform.sessionid,
1542
4375
  'X-Fingerprint': dataform.fingerprint || visitorId,
1543
- 'Content-Type': 'application/json'
4376
+ 'X-Session-Type': xSessionType,
4377
+ 'Content-Type': 'application/json',
4378
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
1544
4379
  }
1545
4380
  };
1546
4381
  const dataload = [dataform, visitorId, login];
@@ -1656,11 +4491,17 @@ const getServiceBasic = async (fpHash = '', sessionID, baseURL, config, setData,
1656
4491
  sessionID,
1657
4492
  fingerprint: visitorIdHash
1658
4493
  };
4494
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1659
4495
  logConsole(configLogs, 'debug', '[Params] ', key);
1660
4496
  try {
1661
4497
  const response = await axios.get(baseURL, {
1662
4498
  ...config,
1663
- params: key
4499
+ withCredentials: true,
4500
+ params: key,
4501
+ headers: {
4502
+ ...(config?.headers || {}),
4503
+ 'X-Session-Type': xSessionType
4504
+ }
1664
4505
  });
1665
4506
  logConsole(configLogs, 'info', '[Request] ', baseURL);
1666
4507
  logConsole(configLogs, 'data', '', response.data);
@@ -1700,7 +4541,12 @@ const getServiceData = async (baseURL, params, config, setData, configLogs) => {
1700
4541
  try {
1701
4542
  const response = await axios.get(baseURL, {
1702
4543
  ...config,
1703
- params
4544
+ withCredentials: true,
4545
+ params,
4546
+ headers: {
4547
+ ...(config?.headers || {}),
4548
+ 'X-Session-Type': authStorage.getSessionTypeValue(configLogs)
4549
+ }
1704
4550
  });
1705
4551
  logConsole(configLogs, 'debug', '[Params] ', params);
1706
4552
  logConsole(configLogs, 'info', '[Request] ', baseURL);
@@ -1730,11 +4576,13 @@ function AppFormFieldsNoUser({
1730
4576
  const [fingerprint, setFingerprint] = React.useState('');
1731
4577
  const authTokens = authStorage.getAuthToken(configLogs) || '';
1732
4578
  const authTokensSes = authStorage.getSessionId(configLogs) || '';
4579
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1733
4580
  const config = React.useMemo(() => ({
1734
4581
  headers: {
1735
4582
  Authorization: `Bearer ${authTokens}`,
1736
4583
  'X-Session-ID': authTokensSes,
1737
4584
  'X-Fingerprint': fingerprint,
4585
+ 'X-Session-Type': xSessionType,
1738
4586
  'Content-Type': 'application/json'
1739
4587
  }
1740
4588
  }), [authTokens, authTokensSes, fingerprint]);
@@ -1802,6 +4650,7 @@ function AppFormFieldsNoUser({
1802
4650
  maxLength: block.maxlength,
1803
4651
  pattern: block.pattern
1804
4652
  },
4653
+ showPasswordToggle: block.showPasswordToggle,
1805
4654
  items: block.items
1806
4655
  }, 'nouser')), additionalfields1.content.body.map(block => RenderForm({
1807
4656
  component: block.component,
@@ -1825,6 +4674,7 @@ function AppFormFieldsNoUser({
1825
4674
  maxLength: block.maxlength,
1826
4675
  pattern: block.pattern
1827
4676
  },
4677
+ showPasswordToggle: block.showPasswordToggle,
1828
4678
  items: block.items
1829
4679
  }, 'nouser')), children);
1830
4680
  }
@@ -1848,11 +4698,13 @@ function AppFormFieldsTable({
1848
4698
  const [t] = reactI18next.useTranslation('global');
1849
4699
  const authTokens = authStorage.getAuthToken(configLogs) || '';
1850
4700
  const authTokensSes = authStorage.getSessionId(configLogs) || '';
4701
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
1851
4702
  React.useMemo(() => ({
1852
4703
  headers: {
1853
4704
  Authorization: `Bearer ${authTokens}`,
1854
4705
  'X-Session-ID': authTokensSes,
1855
4706
  'X-Fingerprint': fpHash,
4707
+ 'X-Session-Type': xSessionType,
1856
4708
  'Content-Type': 'application/json'
1857
4709
  }
1858
4710
  }), [authTokens, authTokensSes, fpHash]);
@@ -1976,7 +4828,10 @@ function AppFormFieldsTable({
1976
4828
  maxLength: block.maxlength || block.validate && block.validate.maxLength,
1977
4829
  pattern: block.pattern || block.validate && block.validate.pattern
1978
4830
  },
1979
- items: block.items || []
4831
+ showPasswordToggle: block.showPasswordToggle,
4832
+ items: block.items || [],
4833
+ itemID: id1,
4834
+ adminCheck: show === 'admin'
1980
4835
  }, nouser || '')), additionalfields1.content.body.map(block => RenderForm({
1981
4836
  component: block.component,
1982
4837
  type: block.type,
@@ -2005,7 +4860,10 @@ function AppFormFieldsTable({
2005
4860
  maxLength: block.maxlength || block.validate && block.validate.maxLength,
2006
4861
  pattern: block.pattern || block.validate && block.validate.pattern
2007
4862
  },
2008
- items: block.items || []
4863
+ showPasswordToggle: block.showPasswordToggle,
4864
+ items: block.items || [],
4865
+ itemID: id1,
4866
+ adminCheck: show === 'admin'
2009
4867
  }, nouser || '')));
2010
4868
  }
2011
4869
 
@@ -5824,11 +8682,9 @@ function GenIcon(data) {
5824
8682
  }
5825
8683
  function IconBase(props) {
5826
8684
  var elem = conf => {
5827
- var {
5828
- attr,
5829
- size,
5830
- title
5831
- } = props,
8685
+ var attr = props.attr,
8686
+ size = props.size,
8687
+ title = props.title,
5832
8688
  svgProps = _objectWithoutProperties(props, _excluded);
5833
8689
  var computedSize = size || conf.size || "1em";
5834
8690
  var className;
@@ -6172,6 +9028,9 @@ function Mailbox({
6172
9028
  theObj,
6173
9029
  t
6174
9030
  }) {
9031
+ const safeObj = {
9032
+ __html: sanitizeHtml(theObj.__html)
9033
+ };
6175
9034
  return /*#__PURE__*/React.createElement("div", {
6176
9035
  className: "mailbox-email",
6177
9036
  style: {
@@ -6198,7 +9057,7 @@ function Mailbox({
6198
9057
  }), ' ', msgTarget)), /*#__PURE__*/React.createElement("div", {
6199
9058
  className: "card-body"
6200
9059
  }, /*#__PURE__*/React.createElement("div", {
6201
- dangerouslySetInnerHTML: theObj
9060
+ dangerouslySetInnerHTML: safeObj
6202
9061
  })), /*#__PURE__*/React.createElement("div", {
6203
9062
  className: "card-footer"
6204
9063
  }, /*#__PURE__*/React.createElement("p", {
@@ -6250,7 +9109,7 @@ function MailTemplateWidget({
6250
9109
  setIsError(false);
6251
9110
  }, []);
6252
9111
  const theObj = {
6253
- __html: getthemedata.html || ''
9112
+ __html: sanitizeHtml(getthemedata.html) || ''
6254
9113
  };
6255
9114
  logConsole(configLogs, 'data', '', getthemedata);
6256
9115
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
@@ -6789,7 +9648,7 @@ function UserWidget({
6789
9648
  setIsError(false);
6790
9649
  };
6791
9650
  const theObj = {
6792
- __html: datauserdata.biography || ''
9651
+ __html: sanitizeHtml(datauserdata.biography) || ''
6793
9652
  };
6794
9653
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Loading, {
6795
9654
  error: error,
@@ -6806,7 +9665,7 @@ function UserWidget({
6806
9665
  className: "solid short"
6807
9666
  }), /*#__PURE__*/React.createElement("ul", {
6808
9667
  className: "simple-todo-list mt-3"
6809
- }, /*#__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, {
9668
+ }, /*#__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, {
6810
9669
  open: isError,
6811
9670
  autoHideDuration: 6000,
6812
9671
  onClose: handleClose,
@@ -6841,16 +9700,32 @@ const AppHeaderPage = ({
6841
9700
  const [color, setColor] = React.useState('');
6842
9701
  const [getfavorites, setFavoritesList] = React.useState('');
6843
9702
  const hasFetched = React.useRef(false);
6844
- const cxauthxc = authStorage.getAuthToken(configLogs) || '';
6845
- const sessionID = authStorage.getSessionId(configLogs) || '';
9703
+ const [token, setToken] = React.useState('');
9704
+ const [sessionId, setSessionId] = React.useState('');
9705
+ const [authReady, setAuthReady] = React.useState(false);
9706
+ React.useEffect(() => {
9707
+ let cancelled = false;
9708
+ authStorage.initialize(configLogs).then(() => {
9709
+ if (cancelled) return;
9710
+ setToken(authStorage.getAuthToken(configLogs) || '');
9711
+ setSessionId(authStorage.getSessionId(configLogs) || '');
9712
+ setAuthReady(true);
9713
+ });
9714
+ return () => {
9715
+ cancelled = true;
9716
+ };
9717
+ }, []);
9718
+ const cxauthxc = token;
9719
+ const sessionID = sessionId;
6846
9720
  const hash = window.location.pathname;
6847
9721
  React.useEffect(() => {
9722
+ if (!authReady) return;
6848
9723
  if (hasFetched.current) return;
6849
9724
  hasFetched.current = true;
6850
9725
  serviceFavorites('get', fpHash, sessionID, 'getfavorites', cxauthxc, t, setFavoritesList, setIsError, setError, setMessageerror, setLoading, setColor, configLogs, {
6851
9726
  url: hash
6852
9727
  });
6853
- }, []);
9728
+ }, [authReady, fpHash, sessionID, cxauthxc, t, hash, configLogs]);
6854
9729
  const handleClickMenuRigth = React.useCallback(() => {
6855
9730
  setOpenMenuRigth(prev => !prev);
6856
9731
  const themeElement = document.getElementById('themeclass');
@@ -7447,6 +10322,11 @@ const FormLogin = ({
7447
10322
  const [trigger1, setTrigger1] = React.useState(0);
7448
10323
  const [trigger2, setTrigger2] = React.useState(0);
7449
10324
  const [isChecked, setIsChecked] = React.useState(false);
10325
+ const showToggle = block.showPasswordToggle === true;
10326
+ const [showPassword, setShowPassword] = React.useState(false);
10327
+ const [showConfirmation, setShowConfirmation] = React.useState(false);
10328
+ const handleTogglePassword = () => setShowPassword(v => !v);
10329
+ const handleToggleConfirmation = () => setShowConfirmation(v => !v);
7450
10330
  const handleChange = () => {
7451
10331
  setIsChecked(current => !current);
7452
10332
  };
@@ -7495,7 +10375,7 @@ const FormLogin = ({
7495
10375
  }, block.label)), /*#__PURE__*/React.createElement("div", {
7496
10376
  className: "input-group"
7497
10377
  }, /*#__PURE__*/React.createElement("input", {
7498
- type: block.type,
10378
+ type: showToggle && showPassword ? 'text' : block.type,
7499
10379
  value: block.value || '',
7500
10380
  name: block.name,
7501
10381
  onChange: block.onChange,
@@ -7505,7 +10385,13 @@ const FormLogin = ({
7505
10385
  className: "input-group-text"
7506
10386
  }, /*#__PURE__*/React.createElement("i", {
7507
10387
  className: "bx bx-lock text-4"
7508
- }))), /*#__PURE__*/React.createElement(reactRouterDom.NavLink, {
10388
+ })), showToggle && (/*#__PURE__*/React.createElement("button", {
10389
+ type: "button",
10390
+ className: "input-group-text password-toggle-btn",
10391
+ onClick: handleTogglePassword,
10392
+ "aria-label": t('System.show_password'),
10393
+ tabIndex: -1
10394
+ }, showPassword ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null)))), /*#__PURE__*/React.createElement(reactRouterDom.NavLink, {
7509
10395
  to: forgot_passworddir,
7510
10396
  className: "float-end"
7511
10397
  }, t('login.recover_password')));
@@ -7609,15 +10495,23 @@ const FormLogin = ({
7609
10495
  className: "col-sm-6 mb-3"
7610
10496
  }, /*#__PURE__*/React.createElement("label", null, labels[1]), /*#__PURE__*/React.createElement("span", {
7611
10497
  className: "required"
7612
- }, "*"), /*#__PURE__*/React.createElement("input", {
10498
+ }, "*"), /*#__PURE__*/React.createElement("div", {
10499
+ className: "input-group"
10500
+ }, /*#__PURE__*/React.createElement("input", {
7613
10501
  id: ids[1],
7614
- type: "password",
10502
+ type: showToggle && showPassword ? 'text' : 'password',
7615
10503
  className: errors.password ? 'form-control form-control-lg is-invalid' : 'form-control form-control-lg',
7616
10504
  ...register('password', {
7617
10505
  required: true,
7618
10506
  minLength: 5
7619
10507
  })
7620
- }), errors.password?.type === 'required' && (/*#__PURE__*/React.createElement("em", {
10508
+ }), showToggle && (/*#__PURE__*/React.createElement("button", {
10509
+ type: "button",
10510
+ className: "input-group-text password-toggle-btn",
10511
+ onClick: handleTogglePassword,
10512
+ "aria-label": t('System.show_password'),
10513
+ tabIndex: -1
10514
+ }, showPassword ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null)))), errors.password?.type === 'required' && (/*#__PURE__*/React.createElement("em", {
7621
10515
  className: "error invalid-feedback"
7622
10516
  }, t('error.please_enter_password'))), errors.password?.type === 'minLength' && (/*#__PURE__*/React.createElement("em", {
7623
10517
  className: "error invalid-feedback"
@@ -7625,16 +10519,24 @@ const FormLogin = ({
7625
10519
  className: "col-sm-6 mb-3"
7626
10520
  }, /*#__PURE__*/React.createElement("label", null, labels[2]), /*#__PURE__*/React.createElement("span", {
7627
10521
  className: "required"
7628
- }, "*"), /*#__PURE__*/React.createElement("input", {
10522
+ }, "*"), /*#__PURE__*/React.createElement("div", {
10523
+ className: "input-group"
10524
+ }, /*#__PURE__*/React.createElement("input", {
7629
10525
  id: ids[2],
7630
- type: "password",
10526
+ type: showToggle && showConfirmation ? 'text' : 'password',
7631
10527
  className: errors.password_confirmation ? 'form-control form-control-lg is-invalid' : 'form-control form-control-lg',
7632
10528
  ...register('password_confirmation', {
7633
10529
  required: true,
7634
10530
  minLength: 5,
7635
10531
  validate: value => value === password.current || t('error.passwords_do_not_match')
7636
10532
  })
7637
- }), errors.password_confirmation?.type === 'required' && (/*#__PURE__*/React.createElement("em", {
10533
+ }), showToggle && (/*#__PURE__*/React.createElement("button", {
10534
+ type: "button",
10535
+ className: "input-group-text password-toggle-btn",
10536
+ onClick: handleToggleConfirmation,
10537
+ "aria-label": t('System.show_password'),
10538
+ tabIndex: -1
10539
+ }, showConfirmation ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null)))), errors.password_confirmation?.type === 'required' && (/*#__PURE__*/React.createElement("em", {
7638
10540
  className: "error invalid-feedback"
7639
10541
  }, t('error.repeat_password'))), errors.password_confirmation?.type === 'minLength' && (/*#__PURE__*/React.createElement("em", {
7640
10542
  className: "error invalid-feedback"
@@ -7707,7 +10609,7 @@ const Info = ({
7707
10609
  texthtml
7708
10610
  } = block;
7709
10611
  const theObj = {
7710
- __html: texthtml
10612
+ __html: sanitizeHtml(texthtml)
7711
10613
  };
7712
10614
  return /*#__PURE__*/React.createElement("div", {
7713
10615
  className: ref
@@ -7723,9 +10625,9 @@ const Info = ({
7723
10625
 
7724
10626
  // THIS FILE IS AUTO GENERATED
7725
10627
  function MdCloudUpload (props) {
7726
- 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);
10628
+ 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);
7727
10629
  }function MdDelete (props) {
7728
- 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);
10630
+ 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);
7729
10631
  }
7730
10632
 
7731
10633
  // THIS FILE IS AUTO GENERATED
@@ -7918,6 +10820,11 @@ const InputPassword = ({
7918
10820
  inParagraph = false
7919
10821
  }) => {
7920
10822
  const [t] = reactI18next.useTranslation('global');
10823
+ const showToggle = block.showPasswordToggle === true;
10824
+ const [showPassword, setShowPassword] = React.useState(false);
10825
+ const [showConfirmation, setShowConfirmation] = React.useState(false);
10826
+ const handleTogglePassword = () => setShowPassword(v => !v);
10827
+ const handleToggleConfirmation = () => setShowConfirmation(v => !v);
7921
10828
  const {
7922
10829
  register,
7923
10830
  formState: {
@@ -7951,7 +10858,7 @@ const InputPassword = ({
7951
10858
  }, block.label, block.validate.required && /*#__PURE__*/React.createElement("span", {
7952
10859
  className: "required"
7953
10860
  }, "*")), /*#__PURE__*/React.createElement("input", {
7954
- type: "password",
10861
+ type: showToggle && showPassword ? 'text' : 'password',
7955
10862
  id: block.id,
7956
10863
  className: errors.password ? `${block.className} is-invalid` : block.className,
7957
10864
  ...register(block.name, {
@@ -7960,7 +10867,13 @@ const InputPassword = ({
7960
10867
  maxLength: block.validate.maxLength
7961
10868
  }),
7962
10869
  required: true
7963
- }), errors.password && (/*#__PURE__*/React.createElement("span", {
10870
+ }), showToggle && (/*#__PURE__*/React.createElement("button", {
10871
+ type: "button",
10872
+ className: "password-toggle-btn",
10873
+ onClick: handleTogglePassword,
10874
+ "aria-label": t('System.show_password'),
10875
+ tabIndex: -1
10876
+ }, showPassword ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null))), errors.password && (/*#__PURE__*/React.createElement("span", {
7964
10877
  className: "error invalid-feedback"
7965
10878
  }, errors.password.type === 'required' && t('error.please_enter_password'), errors.password.type === 'minLength' && `${t('error.password_minimum')} ${block.validate.minLength} ${t('characters')}`, errors.password.type === 'maxLength' && `${t('error.password_maximum')} ${block.validate.maxLength} ${t('characters')}`)))) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputLabel, {
7966
10879
  htmlFor: block.id
@@ -7970,7 +10883,7 @@ const InputPassword = ({
7970
10883
  hiddenLabel: true,
7971
10884
  size: "small",
7972
10885
  id: block.id,
7973
- type: "password",
10886
+ type: showToggle && showPassword ? 'text' : 'password',
7974
10887
  value: resetvalue,
7975
10888
  className: errors.password ? `${block.className} is-invalid` : block.className,
7976
10889
  ...register(block.name, {
@@ -7978,7 +10891,19 @@ const InputPassword = ({
7978
10891
  minLength: block.validate.minLength,
7979
10892
  maxLength: block.validate.maxLength
7980
10893
  }),
7981
- required: true
10894
+ required: true,
10895
+ slotProps: showToggle ? {
10896
+ input: {
10897
+ endAdornment: (/*#__PURE__*/React.createElement(InputAdornment, {
10898
+ position: "end"
10899
+ }, /*#__PURE__*/React.createElement(IconButton, {
10900
+ "aria-label": t('System.show_password'),
10901
+ onClick: handleTogglePassword,
10902
+ edge: "end",
10903
+ tabIndex: -1
10904
+ }, showPassword ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null))))
10905
+ }
10906
+ } : undefined
7982
10907
  }), errors.password?.type === 'required' && (/*#__PURE__*/React.createElement("em", {
7983
10908
  className: "error invalid-feedback"
7984
10909
  }, t('error.please_enter_password'))), errors.password?.type === 'minLength' && (/*#__PURE__*/React.createElement("em", {
@@ -7992,7 +10917,7 @@ const InputPassword = ({
7992
10917
  }, t('System.repeat'), " ", block.label, block.validate.required && /*#__PURE__*/React.createElement("span", {
7993
10918
  className: "required"
7994
10919
  }, "*")), /*#__PURE__*/React.createElement("input", {
7995
- type: "password",
10920
+ type: showToggle && showConfirmation ? 'text' : 'password',
7996
10921
  id: block.id + 100,
7997
10922
  className: errors.password_confirmation ? `${block.className} is-invalid` : block.className,
7998
10923
  ...register(`${block.name}_confirmation`, {
@@ -8002,7 +10927,13 @@ const InputPassword = ({
8002
10927
  validate: value => value === password.current || t('error.passwords_do_not_match')
8003
10928
  }),
8004
10929
  required: true
8005
- }), errors.password_confirmation && (/*#__PURE__*/React.createElement("span", {
10930
+ }), showToggle && (/*#__PURE__*/React.createElement("button", {
10931
+ type: "button",
10932
+ className: "password-toggle-btn",
10933
+ onClick: handleToggleConfirmation,
10934
+ "aria-label": t('System.show_password'),
10935
+ tabIndex: -1
10936
+ }, showConfirmation ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null))), errors.password_confirmation && (/*#__PURE__*/React.createElement("span", {
8006
10937
  className: "error invalid-feedback"
8007
10938
  }, errors.password_confirmation.type === 'required' && t('error.repeat_password'), errors.password_confirmation.type === 'minLength' && `${t('error.password_minimum')} ${block.validate.minLength} ${t('characters')}`, errors.password_confirmation.type === 'maxLength' && `${t('error.password_maximum')} ${block.validate.maxLength} ${t('characters')}`, errors.password_confirmation.type === 'validate' && t('error.password_not_match'))))) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputLabel, {
8008
10939
  htmlFor: block.id + 100
@@ -8012,7 +10943,7 @@ const InputPassword = ({
8012
10943
  hiddenLabel: true,
8013
10944
  size: "small",
8014
10945
  id: block.id + 100,
8015
- type: "password",
10946
+ type: showToggle && showConfirmation ? 'text' : 'password',
8016
10947
  value: resetvalue,
8017
10948
  className: errors.password_confirmation ? `${block.className} is-invalid` : block.className,
8018
10949
  ...register(`${block.name}_confirmation`, {
@@ -8021,7 +10952,19 @@ const InputPassword = ({
8021
10952
  maxLength: block.validate.maxLength,
8022
10953
  validate: value => value === password.current || t('error.passwords_do_not_match')
8023
10954
  }),
8024
- required: true
10955
+ required: true,
10956
+ slotProps: showToggle ? {
10957
+ input: {
10958
+ endAdornment: (/*#__PURE__*/React.createElement(InputAdornment, {
10959
+ position: "end"
10960
+ }, /*#__PURE__*/React.createElement(IconButton, {
10961
+ "aria-label": t('System.show_password'),
10962
+ onClick: handleToggleConfirmation,
10963
+ edge: "end",
10964
+ tabIndex: -1
10965
+ }, showConfirmation ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null))))
10966
+ }
10967
+ } : undefined
8025
10968
  }), errors.password_confirmation?.type === 'required' && (/*#__PURE__*/React.createElement("em", {
8026
10969
  className: "error invalid-feedback"
8027
10970
  }, t('error.repeat_password'))), errors.password_confirmation?.type === 'minLength' && (/*#__PURE__*/React.createElement("em", {
@@ -8037,6 +10980,8 @@ const InputPassword = ({
8037
10980
 
8038
10981
  const postURLusername = Url + 'checkusername';
8039
10982
  const postURLmail = Url + 'checkmail';
10983
+ const postURLAdminUsername = Url + 'admincheckusername';
10984
+ const postURLAdminMail = Url + 'admincheckmail';
8040
10985
  const config$1 = {
8041
10986
  headers: {
8042
10987
  'Content-Type': 'application/json'
@@ -8054,7 +10999,14 @@ const checkExistsUsername = async ({
8054
10999
  try {
8055
11000
  const {
8056
11001
  data
8057
- } = await axios.post(postURLusername, requestData, config$1);
11002
+ } = await axios.post(postURLusername, requestData, {
11003
+ ...config$1,
11004
+ withCredentials: true,
11005
+ headers: {
11006
+ ...(config$1?.headers || {}),
11007
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
11008
+ }
11009
+ });
8058
11010
  logConsole(configLogs, 'info', '[Request] ', postURLusername);
8059
11011
  logConsole(configLogs, 'data', '', data.result);
8060
11012
  return data.result === 'Valid';
@@ -8076,7 +11028,14 @@ const checkExistsMail = async ({
8076
11028
  try {
8077
11029
  const {
8078
11030
  data
8079
- } = await axios.post(postURLmail, requestData, config$1);
11031
+ } = await axios.post(postURLmail, requestData, {
11032
+ ...config$1,
11033
+ withCredentials: true,
11034
+ headers: {
11035
+ ...(config$1?.headers || {}),
11036
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
11037
+ }
11038
+ });
8080
11039
  logConsole(configLogs, 'info', '[Request] ', postURLmail);
8081
11040
  logConsole(configLogs, 'data', '', data.result);
8082
11041
  return data.result === 'Valid';
@@ -8086,6 +11045,70 @@ const checkExistsMail = async ({
8086
11045
  return false;
8087
11046
  }
8088
11047
  };
11048
+ const checkExistsUsernameAdmin = async ({
11049
+ username,
11050
+ itemID
11051
+ }, configLogs) => {
11052
+ const requestData = {
11053
+ username,
11054
+ itemID
11055
+ };
11056
+ logConsole(configLogs, 'debug', '[Payload admincheckusername] ', requestData);
11057
+ try {
11058
+ const {
11059
+ data
11060
+ } = await axios.post(postURLAdminUsername, requestData, {
11061
+ ...config$1,
11062
+ withCredentials: true,
11063
+ headers: {
11064
+ ...(config$1?.headers || {}),
11065
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
11066
+ }
11067
+ });
11068
+ logConsole(configLogs, 'info', '[Request] ', postURLAdminUsername);
11069
+ logConsole(configLogs, 'data', '', data);
11070
+ return data;
11071
+ } catch (err) {
11072
+ logConsole(configLogs, 'error', '', err);
11073
+ console.error(err);
11074
+ return {
11075
+ available: false,
11076
+ isCurrent: false
11077
+ };
11078
+ }
11079
+ };
11080
+ const checkExistsMailAdmin = async ({
11081
+ email,
11082
+ itemID
11083
+ }, configLogs) => {
11084
+ const requestData = {
11085
+ email,
11086
+ itemID
11087
+ };
11088
+ logConsole(configLogs, 'debug', '[Payload admincheckmail] ', requestData);
11089
+ try {
11090
+ const {
11091
+ data
11092
+ } = await axios.post(postURLAdminMail, requestData, {
11093
+ ...config$1,
11094
+ withCredentials: true,
11095
+ headers: {
11096
+ ...(config$1?.headers || {}),
11097
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
11098
+ }
11099
+ });
11100
+ logConsole(configLogs, 'info', '[Request] ', postURLAdminMail);
11101
+ logConsole(configLogs, 'data', '', data);
11102
+ return data;
11103
+ } catch (err) {
11104
+ logConsole(configLogs, 'error', '', err);
11105
+ console.error(err);
11106
+ return {
11107
+ available: false,
11108
+ isCurrent: false
11109
+ };
11110
+ }
11111
+ };
8089
11112
 
8090
11113
  const InputText = /*#__PURE__*/React.memo(({
8091
11114
  block
@@ -8094,8 +11117,11 @@ const InputText = /*#__PURE__*/React.memo(({
8094
11117
  const [t] = reactI18next.useTranslation('global');
8095
11118
  const [errors, setError] = React.useState(false);
8096
11119
  const [texterror, setTextError] = React.useState('');
11120
+ const showToggle = block.showPasswordToggle === true;
11121
+ const [showPassword, setShowPassword] = React.useState(false);
11122
+ const handleTogglePassword = () => setShowPassword(v => !v);
8097
11123
  const handleInputBlur = React.useCallback(async event => {
8098
- const session = localStorage.getItem('cx_session') || '';
11124
+ const session = authStorage.getSessionId(configLogs) || '';
8099
11125
  const value = event.target.value;
8100
11126
  const setErrorState = (error, message) => {
8101
11127
  setError(error);
@@ -8104,22 +11130,44 @@ const InputText = /*#__PURE__*/React.memo(({
8104
11130
  };
8105
11131
  try {
8106
11132
  if (block.validate.check === 'email' && value) {
8107
- const mailexist = await checkExistsMail({
8108
- email: value,
8109
- sessionID: session
8110
- }, configLogs);
8111
- if (!mailexist) {
8112
- setErrorState(true, t('error.email_already_exists'));
8113
- return;
11133
+ if (block.adminCheck) {
11134
+ const mailAdmin = await checkExistsMailAdmin({
11135
+ email: value,
11136
+ itemID: block.itemID
11137
+ }, configLogs);
11138
+ if (!mailAdmin.available && !mailAdmin.isCurrent) {
11139
+ setErrorState(true, t('error.email_already_exists'));
11140
+ return;
11141
+ }
11142
+ } else {
11143
+ const mailexist = await checkExistsMail({
11144
+ email: value,
11145
+ sessionID: session
11146
+ }, configLogs);
11147
+ if (!mailexist) {
11148
+ setErrorState(true, t('error.email_already_exists'));
11149
+ return;
11150
+ }
8114
11151
  }
8115
11152
  } else if (block.validate.check === 'username' && value) {
8116
- const usernameExist = await checkExistsUsername({
8117
- username: value,
8118
- sessionID: session
8119
- }, configLogs);
8120
- if (!usernameExist) {
8121
- setErrorState(true, t('error.username_is_not_valid'));
8122
- return;
11153
+ if (block.adminCheck) {
11154
+ const usernameAdmin = await checkExistsUsernameAdmin({
11155
+ username: value,
11156
+ itemID: block.itemID
11157
+ }, configLogs);
11158
+ if (!usernameAdmin.available && !usernameAdmin.isCurrent) {
11159
+ setErrorState(true, t('error.username_already_exists'));
11160
+ return;
11161
+ }
11162
+ } else {
11163
+ const usernameExist = await checkExistsUsername({
11164
+ username: value,
11165
+ sessionID: session
11166
+ }, configLogs);
11167
+ if (!usernameExist) {
11168
+ setErrorState(true, t('error.username_is_not_valid'));
11169
+ return;
11170
+ }
8123
11171
  }
8124
11172
  }
8125
11173
  if (block.validate.minLength && value.length < block.validate.minLength) {
@@ -8163,14 +11211,26 @@ const InputText = /*#__PURE__*/React.memo(({
8163
11211
  size: "small",
8164
11212
  name: block.name,
8165
11213
  id: block.id,
8166
- type: block.type,
11214
+ type: showToggle && showPassword ? 'text' : block.type,
8167
11215
  placeholder: block.placeholder,
8168
11216
  value: block.value || '',
8169
11217
  onChange: block.onChange,
8170
11218
  onBlur: handleInputBlur,
8171
11219
  autoComplete: block.autocomplete,
8172
11220
  className: errors ? `${block.className} is-invalid` : block.className,
8173
- required: block.validate.required
11221
+ required: block.validate.required,
11222
+ slotProps: showToggle ? {
11223
+ input: {
11224
+ endAdornment: (/*#__PURE__*/React.createElement(InputAdornment, {
11225
+ position: "end"
11226
+ }, /*#__PURE__*/React.createElement(IconButton, {
11227
+ "aria-label": t('System.show_password'),
11228
+ onClick: handleTogglePassword,
11229
+ edge: "end",
11230
+ tabIndex: -1
11231
+ }, showPassword ? /*#__PURE__*/React.createElement(VisibilityOff, null) : /*#__PURE__*/React.createElement(Visibility, null))))
11232
+ }
11233
+ } : undefined
8174
11234
  }));
8175
11235
  if (block.style === 'login') {
8176
11236
  return /*#__PURE__*/React.createElement("div", {
@@ -8218,6 +11278,8 @@ const InputWYSIWYG = /*#__PURE__*/React.memo(({
8218
11278
  const editor = React.useRef(null);
8219
11279
  const config = React.useMemo(() => ({
8220
11280
  readonly: false,
11281
+ toolbarAdaptive: false,
11282
+ 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'],
8221
11283
  placeholder: textEditor && textEditor !== '<p><br></p>' || block.value && block.value !== '<p><br></p>' ? '' : t('general.start_typings') || 'Start typings...',
8222
11284
  language: t('language.name')
8223
11285
  }), [t, textEditor, block.value]);
@@ -8651,7 +11713,10 @@ const LanguageSet = () => {
8651
11713
  hasFetched.current = true;
8652
11714
  const fetchLanguages = async () => {
8653
11715
  try {
8654
- const response = await axios.get(postURL, config);
11716
+ const response = await axios.get(postURL, {
11717
+ ...config,
11718
+ withCredentials: true
11719
+ });
8655
11720
  logConsole(configLogs, 'info', '[Request] ', postURL);
8656
11721
  const langData = Array.isArray(response.data) ? {
8657
11722
  data: response.data
@@ -9714,19 +12779,25 @@ const postFormServiceGetPost = async (datauser, configLogs) => {
9714
12779
  formData.append('iditem', iditem);
9715
12780
  formData.append('sessionID', sessionID);
9716
12781
  formData.append('fingerprint', fingerprint);
12782
+ const xSessionType = authStorage.getSessionTypeValue(configLogs || defaultConfig);
9717
12783
  let config;
9718
12784
  if (authorization === true) {
9719
12785
  config = {
12786
+ withCredentials: true,
9720
12787
  headers: {
9721
12788
  Authorization: `Bearer ${cxauthxc}`,
12789
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
9722
12790
  'X-Session-ID': sessionID,
9723
12791
  'X-Fingerprint': fingerprint,
12792
+ 'X-Session-Type': xSessionType,
9724
12793
  'Content-Type': 'multipart/form-data'
9725
12794
  }
9726
12795
  };
9727
12796
  } else {
9728
12797
  config = {
12798
+ withCredentials: true,
9729
12799
  headers: {
12800
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
9730
12801
  'Content-Type': 'multipart/form-data'
9731
12802
  }
9732
12803
  };
@@ -9762,6 +12833,7 @@ const useCustomForm$1 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
9762
12833
  const [error, setError] = React.useState(false);
9763
12834
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
9764
12835
  const sessionID = authStorage.getSessionId(configLogs) || '';
12836
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
9765
12837
  const iditem = id;
9766
12838
  const authorization = true;
9767
12839
  const handleFormSubmit = async event => {
@@ -9883,6 +12955,7 @@ const useCustomForm$1 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
9883
12955
  Authorization: `Bearer ${cxauthxc}`,
9884
12956
  'X-Session-ID': sessionID,
9885
12957
  'X-Fingerprint': fpHash,
12958
+ 'X-Session-Type': xSessionType,
9886
12959
  'Content-Type': 'application/json'
9887
12960
  }
9888
12961
  }), [cxauthxc, sessionID, fpHash]);
@@ -9899,6 +12972,7 @@ const useCustomForm$1 = (fpHash, postServerURL, getServerURL, deleteServerURL, i
9899
12972
  await getOrSetFingerprint(fpHash, configLogs);
9900
12973
  try {
9901
12974
  const response = await axios.get(getServerURL, {
12975
+ withCredentials: true,
9902
12976
  headers: config.headers,
9903
12977
  params: {
9904
12978
  itemID: id
@@ -10191,19 +13265,25 @@ const patchservice = async (datauser, configLogs) => {
10191
13265
  cxauthxc,
10192
13266
  ...requestData
10193
13267
  } = datauser;
13268
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
10194
13269
  let config;
10195
13270
  if (authorization === true || authorization === 'true') {
10196
13271
  config = {
13272
+ withCredentials: true,
10197
13273
  headers: {
10198
13274
  Authorization: `Bearer ${cxauthxc}`,
13275
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
10199
13276
  'X-Session-ID': datauser.sessionID || '',
10200
13277
  'X-Fingerprint': datauser.fingerprint || '',
13278
+ 'X-Session-Type': xSessionType,
10201
13279
  'Content-Type': 'application/json'
10202
13280
  }
10203
13281
  };
10204
13282
  } else {
10205
13283
  config = {
13284
+ withCredentials: true,
10206
13285
  headers: {
13286
+ 'X-CSRF-Token': authStorage.getCsrfToken() || '',
10207
13287
  'Content-Type': 'application/json'
10208
13288
  }
10209
13289
  };
@@ -10314,9 +13394,8 @@ const serviceDelete2 = async (fpHash = '', sessionID, deleteURL, cxauthxc, t, se
10314
13394
  };
10315
13395
 
10316
13396
  const checkAuth = configLogs => {
10317
- const cxauthxc = authStorage.getAuthToken(configLogs) || '';
10318
- const sessionID = authStorage.getSessionId(configLogs) || '';
10319
- if (cxauthxc === '' || sessionID === '' || cxauthxc === null || sessionID === null) {
13397
+ const hasSession = authStorage.hasActiveSession(configLogs);
13398
+ if (!hasSession) {
10320
13399
  localStorage.removeItem('datauser');
10321
13400
  localStorage.removeItem('sidebarleft');
10322
13401
  localStorage.removeItem('cxl0k2mw');
@@ -10357,6 +13436,7 @@ const useCustomForm = (fpHash, getServerURL, postServerURL, feedback, id, reset
10357
13436
  const [error, setError] = React.useState(false);
10358
13437
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
10359
13438
  const sessionID = authStorage.getSessionId(configLogs) || '';
13439
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
10360
13440
  const authorization = true;
10361
13441
  const handleFormSubmit = async event => {
10362
13442
  const visitorIdHash = await getOrSetFingerprint(fpHash, configLogs);
@@ -10453,6 +13533,7 @@ const useCustomForm = (fpHash, getServerURL, postServerURL, feedback, id, reset
10453
13533
  Authorization: `Bearer ${cxauthxc}`,
10454
13534
  'X-Session-ID': sessionID,
10455
13535
  'X-Fingerprint': fpHash,
13536
+ 'X-Session-Type': xSessionType,
10456
13537
  'Content-Type': 'application/json'
10457
13538
  }
10458
13539
  }), [cxauthxc, sessionID, fpHash]);
@@ -10465,7 +13546,14 @@ const useCustomForm = (fpHash, getServerURL, postServerURL, feedback, id, reset
10465
13546
  fingerprint: visitorIdHash
10466
13547
  };
10467
13548
  try {
10468
- const response = await axios.post(getServerURL, key, config);
13549
+ const response = await axios.post(getServerURL, key, {
13550
+ ...config,
13551
+ withCredentials: true,
13552
+ headers: {
13553
+ ...(config?.headers || {}),
13554
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
13555
+ }
13556
+ });
10469
13557
  logConsole(configLogs, 'info', '[Request] ', getServerURL);
10470
13558
  const responseData = response.data;
10471
13559
  const formData = Array.isArray(responseData) ? responseData[0] : typeof responseData?.data === 'object' && responseData.data !== null ? Array.isArray(responseData.data) ? responseData.data[0] : responseData.data : responseData;
@@ -10500,6 +13588,7 @@ const useCustomFormPatch = (fpHash, getServerURL, patchServerURL, feedback, id,
10500
13588
  const [error, setError] = React.useState(false);
10501
13589
  const cxauthxc = authStorage.getAuthToken(configLogs) || '';
10502
13590
  const sessionID = authStorage.getSessionId(configLogs) || '';
13591
+ const xSessionType = authStorage.getSessionTypeValue(configLogs);
10503
13592
  const authorization = true;
10504
13593
  const handleFormSubmit = async event => {
10505
13594
  const visitorIdHash = await getOrSetFingerprint(fpHash, configLogs);
@@ -10596,6 +13685,7 @@ const useCustomFormPatch = (fpHash, getServerURL, patchServerURL, feedback, id,
10596
13685
  Authorization: `Bearer ${cxauthxc}`,
10597
13686
  'X-Session-ID': sessionID,
10598
13687
  'X-Fingerprint': fpHash,
13688
+ 'X-Session-Type': xSessionType,
10599
13689
  'Content-Type': 'application/json'
10600
13690
  }
10601
13691
  }), [cxauthxc, sessionID, fpHash]);
@@ -10608,7 +13698,14 @@ const useCustomFormPatch = (fpHash, getServerURL, patchServerURL, feedback, id,
10608
13698
  fingerprint: visitorIdHash
10609
13699
  };
10610
13700
  try {
10611
- const response = await axios.post(getServerURL, key, config);
13701
+ const response = await axios.post(getServerURL, key, {
13702
+ ...config,
13703
+ withCredentials: true,
13704
+ headers: {
13705
+ ...(config?.headers || {}),
13706
+ 'X-CSRF-Token': authStorage.getCsrfToken() || ''
13707
+ }
13708
+ });
10612
13709
  logConsole(configLogs, 'info', '[Request] ', getServerURL);
10613
13710
  const responseData = response.data;
10614
13711
  const formData = Array.isArray(responseData) ? responseData[0] : typeof responseData?.data === 'object' && responseData.data !== null ? Array.isArray(responseData.data) ? responseData.data[0] : responseData.data : responseData;
@@ -10716,7 +13813,7 @@ const useZoomPrevention = () => {
10716
13813
  };
10717
13814
 
10718
13815
  const getWsBaseUrl = () => {
10719
- const restApi = window.restAPI || 'http://localhost:3001/restapi/';
13816
+ const restApi = Url || 'http://localhost:3001/restapi/';
10720
13817
  return restApi.replace(/\/restapi\/?$/, '');
10721
13818
  };
10722
13819
  const useSocket = () => {
@@ -10733,12 +13830,16 @@ const useSocket = () => {
10733
13830
  logConsole(configLogs, 'warn', '[WS] ', 'No hay token, no se conecta WebSocket');
10734
13831
  return;
10735
13832
  }
13833
+ const isCookieMode = authStorage.getSessionTypeValue(configLogs) === 'cookie';
10736
13834
  const wsUrl = getWsBaseUrl();
10737
13835
  logConsole(configLogs, 'info', '[WS] ', `Conectando a ${wsUrl}...`);
10738
13836
  const socket = socket_ioClient.io(wsUrl, {
10739
- auth: {
10740
- token
10741
- },
13837
+ ...(isCookieMode ? {} : {
13838
+ auth: {
13839
+ token
13840
+ }
13841
+ }),
13842
+ withCredentials: true,
10742
13843
  transports: ['websocket', 'polling'],
10743
13844
  reconnection: true,
10744
13845
  reconnectionAttempts: Infinity,
@@ -11001,6 +14102,7 @@ exports.patchFormService = patchFormService$1;
11001
14102
  exports.patchservice = patchservice;
11002
14103
  exports.postFormService = postFormService$1;
11003
14104
  exports.postservice = postservice;
14105
+ exports.sanitizeHtml = sanitizeHtml;
11004
14106
  exports.serviceData = serviceData;
11005
14107
  exports.serviceDelete2 = serviceDelete2;
11006
14108
  exports.serviceFavorites = serviceFavorites;