@bigbinary/neeto-payments-frontend 2.5.7 → 3.0.1

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 (148) hide show
  1. package/dist/AccountsDashboard.js +5 -5
  2. package/dist/AccountsDashboard.js.map +1 -1
  3. package/dist/Dashboard.js +15 -16
  4. package/dist/Dashboard.js.map +1 -1
  5. package/dist/{ExportModal-2ea7a200.js → ExportModal-9c9960e6.js} +11 -11
  6. package/dist/ExportModal-9c9960e6.js.map +1 -0
  7. package/dist/PaymentKindRestrictionAlert.js +2 -2
  8. package/dist/PaymentsDashboard.js +6 -6
  9. package/dist/PaymentsDashboard.js.map +1 -1
  10. package/dist/PayoutsDashboard.js +11 -12
  11. package/dist/PayoutsDashboard.js.map +1 -1
  12. package/dist/PayoutsPage.js +13 -14
  13. package/dist/PayoutsPage.js.map +1 -1
  14. package/dist/RazorpayDashboard.js +8 -8
  15. package/dist/RazorpayDashboard.js.map +1 -1
  16. package/dist/RazorpayPaymentButton.js +5 -5
  17. package/dist/RazorpayPaymentButton.js.map +1 -1
  18. package/dist/RefundsDashboard.js +5 -5
  19. package/dist/RefundsDashboard.js.map +1 -1
  20. package/dist/SplitTransfersDashboard.js +5 -5
  21. package/dist/SplitTransfersDashboard.js.map +1 -1
  22. package/dist/StripeConnect.js +6 -1614
  23. package/dist/StripeConnect.js.map +1 -1
  24. package/dist/UpiConnect.js +1 -1
  25. package/dist/UpiConnect.js.map +1 -1
  26. package/dist/UpiMarkAsPaidButton.js +2 -2
  27. package/dist/UpiPayment.js +863 -4
  28. package/dist/UpiPayment.js.map +1 -1
  29. package/dist/V2PaymentsDashboard.js +8 -8
  30. package/dist/V2PaymentsDashboard.js.map +1 -1
  31. package/dist/buildStripeTransactionLink.js +2 -2
  32. package/dist/cjs/AccountsDashboard.js +22 -19
  33. package/dist/cjs/AccountsDashboard.js.map +1 -1
  34. package/dist/cjs/Dashboard.js +35 -32
  35. package/dist/cjs/Dashboard.js.map +1 -1
  36. package/dist/cjs/{ExportModal-3fb40e07.js → ExportModal-a1eb2ad9.js} +16 -14
  37. package/dist/cjs/ExportModal-a1eb2ad9.js.map +1 -0
  38. package/dist/cjs/PaymentKindRestrictionAlert.js +6 -4
  39. package/dist/cjs/PaymentKindRestrictionAlert.js.map +1 -1
  40. package/dist/cjs/PaymentsDashboard.js +17 -14
  41. package/dist/cjs/PaymentsDashboard.js.map +1 -1
  42. package/dist/cjs/PayoutsDashboard.js +27 -25
  43. package/dist/cjs/PayoutsDashboard.js.map +1 -1
  44. package/dist/cjs/PayoutsPage.js +17 -16
  45. package/dist/cjs/PayoutsPage.js.map +1 -1
  46. package/dist/cjs/RazorpayDashboard.js +13 -11
  47. package/dist/cjs/RazorpayDashboard.js.map +1 -1
  48. package/dist/cjs/RazorpayPaymentButton.js +8 -6
  49. package/dist/cjs/RazorpayPaymentButton.js.map +1 -1
  50. package/dist/cjs/RefundsDashboard.js +16 -13
  51. package/dist/cjs/RefundsDashboard.js.map +1 -1
  52. package/dist/cjs/SplitTransfersDashboard.js +16 -13
  53. package/dist/cjs/SplitTransfersDashboard.js.map +1 -1
  54. package/dist/cjs/StripeConnect.js +16 -1621
  55. package/dist/cjs/StripeConnect.js.map +1 -1
  56. package/dist/cjs/UpiConnect.js +4 -3
  57. package/dist/cjs/UpiConnect.js.map +1 -1
  58. package/dist/cjs/UpiMarkAsPaidButton.js +2 -2
  59. package/dist/cjs/UpiPayment.js +866 -6
  60. package/dist/cjs/UpiPayment.js.map +1 -1
  61. package/dist/cjs/V2PaymentsDashboard.js +12 -11
  62. package/dist/cjs/V2PaymentsDashboard.js.map +1 -1
  63. package/dist/cjs/buildStripeTransactionLink.js +1 -1
  64. package/dist/cjs/exportChannel-9f32f02e.js.map +1 -1
  65. package/dist/cjs/{index-191f7895.js → index-45e09f9d.js} +5 -1
  66. package/dist/cjs/index-45e09f9d.js.map +1 -0
  67. package/dist/cjs/{index-992aa86f.js → index-60a3da61.js} +6 -6
  68. package/dist/cjs/index-60a3da61.js.map +1 -0
  69. package/dist/cjs/index.js +17 -17
  70. package/dist/cjs/{renderFunctions-f6285a11.js → renderFunctions-2ce71130.js} +7 -6
  71. package/dist/cjs/renderFunctions-2ce71130.js.map +1 -0
  72. package/dist/cjs/useConnectApi-7e80fd40.js +160 -0
  73. package/dist/cjs/useConnectApi-7e80fd40.js.map +1 -0
  74. package/dist/cjs/{useFiltersAndPagination-3d039b56.js → useFiltersAndPagination-66137df0.js} +19 -17
  75. package/dist/cjs/useFiltersAndPagination-66137df0.js.map +1 -0
  76. package/dist/cjs/{usePaymentApi-17cf6687.js → usePaymentApi-aed31b4b.js} +4 -3
  77. package/dist/cjs/{usePaymentApi-17cf6687.js.map → usePaymentApi-aed31b4b.js.map} +1 -1
  78. package/dist/cjs/{usePaymentsApi-59b5870a.js → usePaymentsApi-d6117d06.js} +4 -3
  79. package/dist/cjs/usePaymentsApi-d6117d06.js.map +1 -0
  80. package/dist/cjs/{usePlatformApi-240aa284.js → usePlatformApi-2e36e5b0.js} +9 -7
  81. package/dist/cjs/usePlatformApi-2e36e5b0.js.map +1 -0
  82. package/dist/cjs/useRazorpayPayment.js +11 -6
  83. package/dist/cjs/useRazorpayPayment.js.map +1 -1
  84. package/dist/cjs/useStripePromise.js +9 -4
  85. package/dist/cjs/useStripePromise.js.map +1 -1
  86. package/dist/exportChannel-8d03ef0f.js.map +1 -1
  87. package/dist/{index-ef5ddc63.js → index-92fd4865.js} +5 -2
  88. package/dist/index-92fd4865.js.map +1 -0
  89. package/dist/{index-7e2564a0.js → index-d1905044.js} +6 -6
  90. package/dist/index-d1905044.js.map +1 -0
  91. package/dist/index.js +17 -17
  92. package/dist/{renderFunctions-c96ac465.js → renderFunctions-c701a29b.js} +3 -3
  93. package/dist/renderFunctions-c701a29b.js.map +1 -0
  94. package/dist/useConnectApi-ff01fe01.js +145 -0
  95. package/dist/useConnectApi-ff01fe01.js.map +1 -0
  96. package/dist/{useFiltersAndPagination-feaeccbe.js → useFiltersAndPagination-0e673dac.js} +9 -9
  97. package/dist/useFiltersAndPagination-0e673dac.js.map +1 -0
  98. package/dist/{usePaymentApi-71f4e76c.js → usePaymentApi-6b31f3b2.js} +2 -2
  99. package/dist/{usePaymentApi-71f4e76c.js.map → usePaymentApi-6b31f3b2.js.map} +1 -1
  100. package/dist/{usePaymentsApi-2d8a9fe1.js → usePaymentsApi-6387b978.js} +2 -2
  101. package/dist/{usePaymentsApi-2d8a9fe1.js.map → usePaymentsApi-6387b978.js.map} +1 -1
  102. package/dist/{usePlatformApi-03288ea2.js → usePlatformApi-825e78cf.js} +3 -3
  103. package/dist/{usePlatformApi-03288ea2.js.map → usePlatformApi-825e78cf.js.map} +1 -1
  104. package/dist/useRazorpayPayment.js +5 -5
  105. package/dist/useRazorpayPayment.js.map +1 -1
  106. package/dist/useStripePromise.js +3 -3
  107. package/dist/useStripePromise.js.map +1 -1
  108. package/package.json +97 -80
  109. package/dist/ExportModal-2ea7a200.js.map +0 -1
  110. package/dist/_commonjsHelpers-1789f0cf.js +0 -8
  111. package/dist/_commonjsHelpers-1789f0cf.js.map +0 -1
  112. package/dist/cjs/ExportModal-3fb40e07.js.map +0 -1
  113. package/dist/cjs/_commonjsHelpers-b3309d7b.js +0 -11
  114. package/dist/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
  115. package/dist/cjs/defineProperty-f3094d6c.js +0 -45
  116. package/dist/cjs/defineProperty-f3094d6c.js.map +0 -1
  117. package/dist/cjs/index-191f7895.js.map +0 -1
  118. package/dist/cjs/index-6894d1e0.js +0 -387
  119. package/dist/cjs/index-6894d1e0.js.map +0 -1
  120. package/dist/cjs/index-992aa86f.js.map +0 -1
  121. package/dist/cjs/objectWithoutProperties-2fed2d7d.js +0 -33
  122. package/dist/cjs/objectWithoutProperties-2fed2d7d.js.map +0 -1
  123. package/dist/cjs/renderFunctions-f6285a11.js.map +0 -1
  124. package/dist/cjs/slicedToArray-f320d9e7.js +0 -61
  125. package/dist/cjs/slicedToArray-f320d9e7.js.map +0 -1
  126. package/dist/cjs/toConsumableArray-9abb3858.js +0 -22
  127. package/dist/cjs/toConsumableArray-9abb3858.js.map +0 -1
  128. package/dist/cjs/useConnectApi-3efe6336.js +0 -3877
  129. package/dist/cjs/useConnectApi-3efe6336.js.map +0 -1
  130. package/dist/cjs/useFiltersAndPagination-3d039b56.js.map +0 -1
  131. package/dist/cjs/usePaymentsApi-59b5870a.js.map +0 -1
  132. package/dist/cjs/usePlatformApi-240aa284.js.map +0 -1
  133. package/dist/defineProperty-e90a259c.js +0 -43
  134. package/dist/defineProperty-e90a259c.js.map +0 -1
  135. package/dist/index-7e2564a0.js.map +0 -1
  136. package/dist/index-d02e7a6d.js +0 -384
  137. package/dist/index-d02e7a6d.js.map +0 -1
  138. package/dist/index-ef5ddc63.js.map +0 -1
  139. package/dist/objectWithoutProperties-a0edb288.js +0 -31
  140. package/dist/objectWithoutProperties-a0edb288.js.map +0 -1
  141. package/dist/renderFunctions-c96ac465.js.map +0 -1
  142. package/dist/slicedToArray-b4278ecd.js +0 -57
  143. package/dist/slicedToArray-b4278ecd.js.map +0 -1
  144. package/dist/toConsumableArray-1cc38429.js +0 -20
  145. package/dist/toConsumableArray-1cc38429.js.map +0 -1
  146. package/dist/useConnectApi-af01d09a.js +0 -3862
  147. package/dist/useConnectApi-af01d09a.js.map +0 -1
  148. package/dist/useFiltersAndPagination-feaeccbe.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var defineProperty = require('./defineProperty-f3094d6c.js');
4
- var slicedToArray = require('./slicedToArray-f320d9e7.js');
3
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
5
  var React = require('react');
6
6
  var neetoCist = require('@bigbinary/neeto-cist');
7
7
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
8
8
  var neetointegrations = require('neetointegrations');
9
- var useConnectApi = require('./useConnectApi-3efe6336.js');
9
+ var useConnectApi = require('./useConnectApi-7e80fd40.js');
10
10
  var Label = require('@bigbinary/neetoui/Label');
11
11
  var Typography = require('@bigbinary/neetoui/Typography');
12
12
  var reactI18next = require('react-i18next');
@@ -25,10 +25,10 @@ require('ramda');
25
25
  var jsxRuntime = require('react/jsx-runtime');
26
26
  var Alert = require('@bigbinary/neetoui/Alert');
27
27
  var Button = require('@bigbinary/neetoui/Button');
28
+ var DOMPurify = require('dompurify');
28
29
  var Radio = require('@bigbinary/neetoui/Radio');
29
30
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
30
- require('./_commonjsHelpers-b3309d7b.js');
31
- require('util');
31
+ require('qs');
32
32
  require('@bigbinary/neeto-commons-frontend/constants');
33
33
 
34
34
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -51,6 +51,8 @@ function _interopNamespace(e) {
51
51
  return Object.freeze(n);
52
52
  }
53
53
 
54
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
55
+ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
54
56
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
55
57
  var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
56
58
  var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
@@ -62,6 +64,7 @@ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
62
64
  var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
63
65
  var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
64
66
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
67
+ var DOMPurify__default = /*#__PURE__*/_interopDefaultLegacy(DOMPurify);
65
68
  var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
66
69
 
67
70
  var _path, _path2, _path3;
@@ -131,7 +134,6 @@ var INTEGRATION_STEPS = [{
131
134
  }
132
135
  // { step: "4", label: "demo", isActive: false, isCompleted: false },
133
136
  ];
134
-
135
137
  var INTEGRATION_METHOD = {
136
138
  useExistingAccount: "use_existing_account",
137
139
  createNewAccount: "create_new_account"
@@ -158,7 +160,7 @@ var AccountForm = function AccountForm(_ref) {
158
160
  t = _useTranslation.t;
159
161
  var history = reactRouterDom.useHistory();
160
162
  var _useState = React.useState(false),
161
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
163
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
162
164
  isPolling = _useState2[0],
163
165
  setIsPolling = _useState2[1];
164
166
  var submitButtonLabel = isPolling ? t("neetoPayments.integrationModal.creating") : t("neetoPayments.common.connect");
@@ -283,11 +285,11 @@ var AccountProcessing = function AccountProcessing(_ref) {
283
285
  var _useQueryParams = reactUtils.useQueryParams(),
284
286
  app = _useQueryParams.app;
285
287
  var _useState = React.useState(false),
286
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
288
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
287
289
  isAlertOpen = _useState2[0],
288
290
  setIsAlertOpen = _useState2[1];
289
291
  var _useState3 = React.useState(false),
290
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
292
+ _useState4 = _slicedToArray__default["default"](_useState3, 2),
291
293
  isPolling = _useState4[0],
292
294
  setIsPolling = _useState4[1];
293
295
  var _useTranslation = reactI18next.useTranslation(),
@@ -413,1613 +415,6 @@ var Configure = function Configure(_ref) {
413
415
  });
414
416
  };
415
417
 
416
- /*! @license DOMPurify 3.1.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.3/LICENSE */
417
-
418
- const {
419
- entries,
420
- setPrototypeOf,
421
- isFrozen,
422
- getPrototypeOf,
423
- getOwnPropertyDescriptor
424
- } = Object;
425
- let {
426
- freeze,
427
- seal,
428
- create
429
- } = Object; // eslint-disable-line import/no-mutable-exports
430
- let {
431
- apply,
432
- construct
433
- } = typeof Reflect !== 'undefined' && Reflect;
434
- if (!freeze) {
435
- freeze = function freeze(x) {
436
- return x;
437
- };
438
- }
439
- if (!seal) {
440
- seal = function seal(x) {
441
- return x;
442
- };
443
- }
444
- if (!apply) {
445
- apply = function apply(fun, thisValue, args) {
446
- return fun.apply(thisValue, args);
447
- };
448
- }
449
- if (!construct) {
450
- construct = function construct(Func, args) {
451
- return new Func(...args);
452
- };
453
- }
454
- const arrayForEach = unapply(Array.prototype.forEach);
455
- const arrayPop = unapply(Array.prototype.pop);
456
- const arrayPush = unapply(Array.prototype.push);
457
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
458
- const stringToString = unapply(String.prototype.toString);
459
- const stringMatch = unapply(String.prototype.match);
460
- const stringReplace = unapply(String.prototype.replace);
461
- const stringIndexOf = unapply(String.prototype.indexOf);
462
- const stringTrim = unapply(String.prototype.trim);
463
- const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
464
- const regExpTest = unapply(RegExp.prototype.test);
465
- const typeErrorCreate = unconstruct(TypeError);
466
- const numberIsNaN = unapply(Number.isNaN);
467
-
468
- /**
469
- * Creates a new function that calls the given function with a specified thisArg and arguments.
470
- *
471
- * @param {Function} func - The function to be wrapped and called.
472
- * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.
473
- */
474
- function unapply(func) {
475
- return function (thisArg) {
476
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
477
- args[_key - 1] = arguments[_key];
478
- }
479
- return apply(func, thisArg, args);
480
- };
481
- }
482
-
483
- /**
484
- * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
485
- *
486
- * @param {Function} func - The constructor function to be wrapped and called.
487
- * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.
488
- */
489
- function unconstruct(func) {
490
- return function () {
491
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
492
- args[_key2] = arguments[_key2];
493
- }
494
- return construct(func, args);
495
- };
496
- }
497
-
498
- /**
499
- * Add properties to a lookup table
500
- *
501
- * @param {Object} set - The set to which elements will be added.
502
- * @param {Array} array - The array containing elements to be added to the set.
503
- * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
504
- * @returns {Object} The modified set with added elements.
505
- */
506
- function addToSet(set, array) {
507
- let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
508
- if (setPrototypeOf) {
509
- // Make 'in' and truthy checks like Boolean(set.constructor)
510
- // independent of any properties defined on Object.prototype.
511
- // Prevent prototype setters from intercepting set as a this value.
512
- setPrototypeOf(set, null);
513
- }
514
- let l = array.length;
515
- while (l--) {
516
- let element = array[l];
517
- if (typeof element === 'string') {
518
- const lcElement = transformCaseFunc(element);
519
- if (lcElement !== element) {
520
- // Config presets (e.g. tags.js, attrs.js) are immutable.
521
- if (!isFrozen(array)) {
522
- array[l] = lcElement;
523
- }
524
- element = lcElement;
525
- }
526
- }
527
- set[element] = true;
528
- }
529
- return set;
530
- }
531
-
532
- /**
533
- * Clean up an array to harden against CSPP
534
- *
535
- * @param {Array} array - The array to be cleaned.
536
- * @returns {Array} The cleaned version of the array
537
- */
538
- function cleanArray(array) {
539
- for (let index = 0; index < array.length; index++) {
540
- const isPropertyExist = objectHasOwnProperty(array, index);
541
- if (!isPropertyExist) {
542
- array[index] = null;
543
- }
544
- }
545
- return array;
546
- }
547
-
548
- /**
549
- * Shallow clone an object
550
- *
551
- * @param {Object} object - The object to be cloned.
552
- * @returns {Object} A new object that copies the original.
553
- */
554
- function clone(object) {
555
- const newObject = create(null);
556
- for (const [property, value] of entries(object)) {
557
- const isPropertyExist = objectHasOwnProperty(object, property);
558
- if (isPropertyExist) {
559
- if (Array.isArray(value)) {
560
- newObject[property] = cleanArray(value);
561
- } else if (value && typeof value === 'object' && value.constructor === Object) {
562
- newObject[property] = clone(value);
563
- } else {
564
- newObject[property] = value;
565
- }
566
- }
567
- }
568
- return newObject;
569
- }
570
-
571
- /**
572
- * This method automatically checks if the prop is function or getter and behaves accordingly.
573
- *
574
- * @param {Object} object - The object to look up the getter function in its prototype chain.
575
- * @param {String} prop - The property name for which to find the getter function.
576
- * @returns {Function} The getter function found in the prototype chain or a fallback function.
577
- */
578
- function lookupGetter(object, prop) {
579
- while (object !== null) {
580
- const desc = getOwnPropertyDescriptor(object, prop);
581
- if (desc) {
582
- if (desc.get) {
583
- return unapply(desc.get);
584
- }
585
- if (typeof desc.value === 'function') {
586
- return unapply(desc.value);
587
- }
588
- }
589
- object = getPrototypeOf(object);
590
- }
591
- function fallbackValue() {
592
- return null;
593
- }
594
- return fallbackValue;
595
- }
596
-
597
- 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', 'section', 'select', 'shadow', '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']);
598
-
599
- // SVG
600
- const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
601
- 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']);
602
-
603
- // List of SVG elements that are disallowed by default.
604
- // We still need to know them so that we can do namespace
605
- // checks properly in case one wants to add them to
606
- // allow-list.
607
- 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']);
608
- 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']);
609
-
610
- // Similarly to SVG, we want to know all MathML elements,
611
- // even those that we disallow by default.
612
- const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
613
- const text = freeze(['#text']);
614
-
615
- const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', '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', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
616
- const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', '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', 'dur', 'edgemode', 'elevation', 'end', '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', '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', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', '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', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', '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']);
617
- const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', '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']);
618
- const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
619
-
620
- // eslint-disable-next-line unicorn/better-regex
621
- const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
622
- const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
623
- const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
624
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
625
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
626
- const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
627
- );
628
-
629
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
630
- const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
631
- );
632
-
633
- const DOCTYPE_NAME = seal(/^html$/i);
634
- const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
635
-
636
- var EXPRESSIONS = /*#__PURE__*/Object.freeze({
637
- __proto__: null,
638
- MUSTACHE_EXPR: MUSTACHE_EXPR,
639
- ERB_EXPR: ERB_EXPR,
640
- TMPLIT_EXPR: TMPLIT_EXPR,
641
- DATA_ATTR: DATA_ATTR,
642
- ARIA_ATTR: ARIA_ATTR,
643
- IS_ALLOWED_URI: IS_ALLOWED_URI,
644
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
645
- ATTR_WHITESPACE: ATTR_WHITESPACE,
646
- DOCTYPE_NAME: DOCTYPE_NAME,
647
- CUSTOM_ELEMENT: CUSTOM_ELEMENT
648
- });
649
-
650
- // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
651
- const NODE_TYPE = {
652
- element: 1,
653
- attribute: 2,
654
- text: 3,
655
- cdataSection: 4,
656
- entityReference: 5,
657
- // Deprecated
658
- entityNode: 6,
659
- // Deprecated
660
- progressingInstruction: 7,
661
- comment: 8,
662
- document: 9,
663
- documentType: 10,
664
- documentFragment: 11,
665
- notation: 12 // Deprecated
666
- };
667
-
668
- const getGlobal = function getGlobal() {
669
- return typeof window === 'undefined' ? null : window;
670
- };
671
-
672
- /**
673
- * Creates a no-op policy for internal use only.
674
- * Don't export this function outside this module!
675
- * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
676
- * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
677
- * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
678
- * are not supported or creating the policy failed).
679
- */
680
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
681
- if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
682
- return null;
683
- }
684
-
685
- // Allow the callers to control the unique policy name
686
- // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
687
- // Policy creation with duplicate names throws in Trusted Types.
688
- let suffix = null;
689
- const ATTR_NAME = 'data-tt-policy-suffix';
690
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
691
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
692
- }
693
- const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
694
- try {
695
- return trustedTypes.createPolicy(policyName, {
696
- createHTML(html) {
697
- return html;
698
- },
699
- createScriptURL(scriptUrl) {
700
- return scriptUrl;
701
- }
702
- });
703
- } catch (_) {
704
- // Policy creation failed (most likely another DOMPurify script has
705
- // already run). Skip creating the policy, as this will only cause errors
706
- // if TT are enforced.
707
- console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
708
- return null;
709
- }
710
- };
711
- function createDOMPurify() {
712
- let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
713
- const DOMPurify = root => createDOMPurify(root);
714
-
715
- /**
716
- * Version label, exposed for easier checks
717
- * if DOMPurify is up to date or not
718
- */
719
- DOMPurify.version = '3.1.3';
720
-
721
- /**
722
- * Array of elements that DOMPurify removed during sanitation.
723
- * Empty if nothing was removed.
724
- */
725
- DOMPurify.removed = [];
726
- if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) {
727
- // Not running in a browser, provide a factory function
728
- // so that you can pass your own Window
729
- DOMPurify.isSupported = false;
730
- return DOMPurify;
731
- }
732
- let {
733
- document
734
- } = window;
735
- const originalDocument = document;
736
- const currentScript = originalDocument.currentScript;
737
- const {
738
- DocumentFragment,
739
- HTMLTemplateElement,
740
- Node,
741
- Element,
742
- NodeFilter,
743
- NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
744
- HTMLFormElement,
745
- DOMParser,
746
- trustedTypes
747
- } = window;
748
- const ElementPrototype = Element.prototype;
749
- const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
750
- const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
751
- const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
752
- const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
753
-
754
- // As per issue #47, the web-components registry is inherited by a
755
- // new document created via createHTMLDocument. As per the spec
756
- // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
757
- // a new empty registry is used when creating a template contents owner
758
- // document, so we use that as our parent document to ensure nothing
759
- // is inherited.
760
- if (typeof HTMLTemplateElement === 'function') {
761
- const template = document.createElement('template');
762
- if (template.content && template.content.ownerDocument) {
763
- document = template.content.ownerDocument;
764
- }
765
- }
766
- let trustedTypesPolicy;
767
- let emptyHTML = '';
768
- const {
769
- implementation,
770
- createNodeIterator,
771
- createDocumentFragment,
772
- getElementsByTagName
773
- } = document;
774
- const {
775
- importNode
776
- } = originalDocument;
777
- let hooks = {};
778
-
779
- /**
780
- * Expose whether this browser supports running the full DOMPurify.
781
- */
782
- DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
783
- const {
784
- MUSTACHE_EXPR,
785
- ERB_EXPR,
786
- TMPLIT_EXPR,
787
- DATA_ATTR,
788
- ARIA_ATTR,
789
- IS_SCRIPT_OR_DATA,
790
- ATTR_WHITESPACE,
791
- CUSTOM_ELEMENT
792
- } = EXPRESSIONS;
793
- let {
794
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
795
- } = EXPRESSIONS;
796
-
797
- /**
798
- * We consider the elements and attributes below to be safe. Ideally
799
- * don't add any new ones but feel free to remove unwanted ones.
800
- */
801
-
802
- /* allowed element names */
803
- let ALLOWED_TAGS = null;
804
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
805
-
806
- /* Allowed attribute names */
807
- let ALLOWED_ATTR = null;
808
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
809
-
810
- /*
811
- * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
812
- * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
813
- * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
814
- * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
815
- */
816
- let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
817
- tagNameCheck: {
818
- writable: true,
819
- configurable: false,
820
- enumerable: true,
821
- value: null
822
- },
823
- attributeNameCheck: {
824
- writable: true,
825
- configurable: false,
826
- enumerable: true,
827
- value: null
828
- },
829
- allowCustomizedBuiltInElements: {
830
- writable: true,
831
- configurable: false,
832
- enumerable: true,
833
- value: false
834
- }
835
- }));
836
-
837
- /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
838
- let FORBID_TAGS = null;
839
-
840
- /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
841
- let FORBID_ATTR = null;
842
-
843
- /* Decide if ARIA attributes are okay */
844
- let ALLOW_ARIA_ATTR = true;
845
-
846
- /* Decide if custom data attributes are okay */
847
- let ALLOW_DATA_ATTR = true;
848
-
849
- /* Decide if unknown protocols are okay */
850
- let ALLOW_UNKNOWN_PROTOCOLS = false;
851
-
852
- /* Decide if self-closing tags in attributes are allowed.
853
- * Usually removed due to a mXSS issue in jQuery 3.0 */
854
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
855
-
856
- /* Output should be safe for common template engines.
857
- * This means, DOMPurify removes data attributes, mustaches and ERB
858
- */
859
- let SAFE_FOR_TEMPLATES = false;
860
-
861
- /* Output should be safe even for XML used within HTML and alike.
862
- * This means, DOMPurify removes comments when containing risky content.
863
- */
864
- let SAFE_FOR_XML = true;
865
-
866
- /* Decide if document with <html>... should be returned */
867
- let WHOLE_DOCUMENT = false;
868
-
869
- /* Track whether config is already set on this instance of DOMPurify. */
870
- let SET_CONFIG = false;
871
-
872
- /* Decide if all elements (e.g. style, script) must be children of
873
- * document.body. By default, browsers might move them to document.head */
874
- let FORCE_BODY = false;
875
-
876
- /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
877
- * string (or a TrustedHTML object if Trusted Types are supported).
878
- * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
879
- */
880
- let RETURN_DOM = false;
881
-
882
- /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
883
- * string (or a TrustedHTML object if Trusted Types are supported) */
884
- let RETURN_DOM_FRAGMENT = false;
885
-
886
- /* Try to return a Trusted Type object instead of a string, return a string in
887
- * case Trusted Types are not supported */
888
- let RETURN_TRUSTED_TYPE = false;
889
-
890
- /* Output should be free from DOM clobbering attacks?
891
- * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
892
- */
893
- let SANITIZE_DOM = true;
894
-
895
- /* Achieve full DOM Clobbering protection by isolating the namespace of named
896
- * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
897
- *
898
- * HTML/DOM spec rules that enable DOM Clobbering:
899
- * - Named Access on Window (§7.3.3)
900
- * - DOM Tree Accessors (§3.1.5)
901
- * - Form Element Parent-Child Relations (§4.10.3)
902
- * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
903
- * - HTMLCollection (§4.2.10.2)
904
- *
905
- * Namespace isolation is implemented by prefixing `id` and `name` attributes
906
- * with a constant string, i.e., `user-content-`
907
- */
908
- let SANITIZE_NAMED_PROPS = false;
909
- const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
910
-
911
- /* Keep element content when removing element? */
912
- let KEEP_CONTENT = true;
913
-
914
- /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
915
- * of importing it into a new Document and returning a sanitized copy */
916
- let IN_PLACE = false;
917
-
918
- /* Allow usage of profiles like html, svg and mathMl */
919
- let USE_PROFILES = {};
920
-
921
- /* Tags to ignore content of when KEEP_CONTENT is true */
922
- let FORBID_CONTENTS = null;
923
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
924
-
925
- /* Tags that are safe for data: URIs */
926
- let DATA_URI_TAGS = null;
927
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
928
-
929
- /* Attributes safe for values like "javascript:" */
930
- let URI_SAFE_ATTRIBUTES = null;
931
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
932
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
933
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
934
- const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
935
- /* Document namespace */
936
- let NAMESPACE = HTML_NAMESPACE;
937
- let IS_EMPTY_INPUT = false;
938
-
939
- /* Allowed XHTML+XML namespaces */
940
- let ALLOWED_NAMESPACES = null;
941
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
942
-
943
- /* Parsing of strict XHTML documents */
944
- let PARSER_MEDIA_TYPE = null;
945
- const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
946
- const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
947
- let transformCaseFunc = null;
948
-
949
- /* Keep a reference to config to pass to hooks */
950
- let CONFIG = null;
951
-
952
- /* Specify the maximum element nesting depth to prevent mXSS */
953
- const MAX_NESTING_DEPTH = 255;
954
-
955
- /* Ideally, do not touch anything below this line */
956
- /* ______________________________________________ */
957
-
958
- const formElement = document.createElement('form');
959
- const isRegexOrFunction = function isRegexOrFunction(testValue) {
960
- return testValue instanceof RegExp || testValue instanceof Function;
961
- };
962
-
963
- /**
964
- * _parseConfig
965
- *
966
- * @param {Object} cfg optional config literal
967
- */
968
- // eslint-disable-next-line complexity
969
- const _parseConfig = function _parseConfig() {
970
- let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
971
- if (CONFIG && CONFIG === cfg) {
972
- return;
973
- }
974
-
975
- /* Shield configuration object from tampering */
976
- if (!cfg || typeof cfg !== 'object') {
977
- cfg = {};
978
- }
979
-
980
- /* Shield configuration object from prototype pollution */
981
- cfg = clone(cfg);
982
- PARSER_MEDIA_TYPE =
983
- // eslint-disable-next-line unicorn/prefer-includes
984
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
985
-
986
- // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
987
- transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
988
-
989
- /* Set configuration parameters */
990
- ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
991
- ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
992
- ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
993
- URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
994
- // eslint-disable-line indent
995
- cfg.ADD_URI_SAFE_ATTR,
996
- // eslint-disable-line indent
997
- transformCaseFunc // eslint-disable-line indent
998
- ) // eslint-disable-line indent
999
- : DEFAULT_URI_SAFE_ATTRIBUTES;
1000
- DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
1001
- // eslint-disable-line indent
1002
- cfg.ADD_DATA_URI_TAGS,
1003
- // eslint-disable-line indent
1004
- transformCaseFunc // eslint-disable-line indent
1005
- ) // eslint-disable-line indent
1006
- : DEFAULT_DATA_URI_TAGS;
1007
- FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
1008
- FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
1009
- FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
1010
- USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
1011
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1012
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1013
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1014
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1015
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1016
- SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
1017
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1018
- RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1019
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1020
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1021
- FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1022
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1023
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1024
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1025
- IN_PLACE = cfg.IN_PLACE || false; // Default false
1026
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
1027
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
1028
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
1029
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
1030
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
1031
- }
1032
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
1033
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
1034
- }
1035
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
1036
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
1037
- }
1038
- if (SAFE_FOR_TEMPLATES) {
1039
- ALLOW_DATA_ATTR = false;
1040
- }
1041
- if (RETURN_DOM_FRAGMENT) {
1042
- RETURN_DOM = true;
1043
- }
1044
-
1045
- /* Parse profile info */
1046
- if (USE_PROFILES) {
1047
- ALLOWED_TAGS = addToSet({}, text);
1048
- ALLOWED_ATTR = [];
1049
- if (USE_PROFILES.html === true) {
1050
- addToSet(ALLOWED_TAGS, html$1);
1051
- addToSet(ALLOWED_ATTR, html);
1052
- }
1053
- if (USE_PROFILES.svg === true) {
1054
- addToSet(ALLOWED_TAGS, svg$1);
1055
- addToSet(ALLOWED_ATTR, svg);
1056
- addToSet(ALLOWED_ATTR, xml);
1057
- }
1058
- if (USE_PROFILES.svgFilters === true) {
1059
- addToSet(ALLOWED_TAGS, svgFilters);
1060
- addToSet(ALLOWED_ATTR, svg);
1061
- addToSet(ALLOWED_ATTR, xml);
1062
- }
1063
- if (USE_PROFILES.mathMl === true) {
1064
- addToSet(ALLOWED_TAGS, mathMl$1);
1065
- addToSet(ALLOWED_ATTR, mathMl);
1066
- addToSet(ALLOWED_ATTR, xml);
1067
- }
1068
- }
1069
-
1070
- /* Merge configuration parameters */
1071
- if (cfg.ADD_TAGS) {
1072
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1073
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
1074
- }
1075
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1076
- }
1077
- if (cfg.ADD_ATTR) {
1078
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1079
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
1080
- }
1081
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1082
- }
1083
- if (cfg.ADD_URI_SAFE_ATTR) {
1084
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1085
- }
1086
- if (cfg.FORBID_CONTENTS) {
1087
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1088
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
1089
- }
1090
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1091
- }
1092
-
1093
- /* Add #text in case KEEP_CONTENT is set to true */
1094
- if (KEEP_CONTENT) {
1095
- ALLOWED_TAGS['#text'] = true;
1096
- }
1097
-
1098
- /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1099
- if (WHOLE_DOCUMENT) {
1100
- addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1101
- }
1102
-
1103
- /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1104
- if (ALLOWED_TAGS.table) {
1105
- addToSet(ALLOWED_TAGS, ['tbody']);
1106
- delete FORBID_TAGS.tbody;
1107
- }
1108
- if (cfg.TRUSTED_TYPES_POLICY) {
1109
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1110
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1111
- }
1112
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1113
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1114
- }
1115
-
1116
- // Overwrite existing TrustedTypes policy.
1117
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1118
-
1119
- // Sign local variables required by `sanitize`.
1120
- emptyHTML = trustedTypesPolicy.createHTML('');
1121
- } else {
1122
- // Uninitialized policy, attempt to initialize the internal dompurify policy.
1123
- if (trustedTypesPolicy === undefined) {
1124
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1125
- }
1126
-
1127
- // If creating the internal policy succeeded sign internal variables.
1128
- if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
1129
- emptyHTML = trustedTypesPolicy.createHTML('');
1130
- }
1131
- }
1132
-
1133
- // Prevent further manipulation of configuration.
1134
- // Not available in IE8, Safari 5, etc.
1135
- if (freeze) {
1136
- freeze(cfg);
1137
- }
1138
- CONFIG = cfg;
1139
- };
1140
- const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
1141
- const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
1142
-
1143
- // Certain elements are allowed in both SVG and HTML
1144
- // namespace. We need to specify them explicitly
1145
- // so that they don't get erroneously deleted from
1146
- // HTML namespace.
1147
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1148
-
1149
- /* Keep track of all possible SVG and MathML tags
1150
- * so that we can perform the namespace checks
1151
- * correctly. */
1152
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1153
- const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1154
-
1155
- /**
1156
- * @param {Element} element a DOM element whose namespace is being checked
1157
- * @returns {boolean} Return false if the element has a
1158
- * namespace that a spec-compliant parser would never
1159
- * return. Return true otherwise.
1160
- */
1161
- const _checkValidNamespace = function _checkValidNamespace(element) {
1162
- let parent = getParentNode(element);
1163
-
1164
- // In JSDOM, if we're inside shadow DOM, then parentNode
1165
- // can be null. We just simulate parent in this case.
1166
- if (!parent || !parent.tagName) {
1167
- parent = {
1168
- namespaceURI: NAMESPACE,
1169
- tagName: 'template'
1170
- };
1171
- }
1172
- const tagName = stringToLowerCase(element.tagName);
1173
- const parentTagName = stringToLowerCase(parent.tagName);
1174
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1175
- return false;
1176
- }
1177
- if (element.namespaceURI === SVG_NAMESPACE) {
1178
- // The only way to switch from HTML namespace to SVG
1179
- // is via <svg>. If it happens via any other tag, then
1180
- // it should be killed.
1181
- if (parent.namespaceURI === HTML_NAMESPACE) {
1182
- return tagName === 'svg';
1183
- }
1184
-
1185
- // The only way to switch from MathML to SVG is via`
1186
- // svg if parent is either <annotation-xml> or MathML
1187
- // text integration points.
1188
- if (parent.namespaceURI === MATHML_NAMESPACE) {
1189
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1190
- }
1191
-
1192
- // We only allow elements that are defined in SVG
1193
- // spec. All others are disallowed in SVG namespace.
1194
- return Boolean(ALL_SVG_TAGS[tagName]);
1195
- }
1196
- if (element.namespaceURI === MATHML_NAMESPACE) {
1197
- // The only way to switch from HTML namespace to MathML
1198
- // is via <math>. If it happens via any other tag, then
1199
- // it should be killed.
1200
- if (parent.namespaceURI === HTML_NAMESPACE) {
1201
- return tagName === 'math';
1202
- }
1203
-
1204
- // The only way to switch from SVG to MathML is via
1205
- // <math> and HTML integration points
1206
- if (parent.namespaceURI === SVG_NAMESPACE) {
1207
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1208
- }
1209
-
1210
- // We only allow elements that are defined in MathML
1211
- // spec. All others are disallowed in MathML namespace.
1212
- return Boolean(ALL_MATHML_TAGS[tagName]);
1213
- }
1214
- if (element.namespaceURI === HTML_NAMESPACE) {
1215
- // The only way to switch from SVG to HTML is via
1216
- // HTML integration points, and from MathML to HTML
1217
- // is via MathML text integration points
1218
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1219
- return false;
1220
- }
1221
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1222
- return false;
1223
- }
1224
-
1225
- // We disallow tags that are specific for MathML
1226
- // or SVG and should never appear in HTML namespace
1227
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1228
- }
1229
-
1230
- // For XHTML and XML documents that support custom namespaces
1231
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1232
- return true;
1233
- }
1234
-
1235
- // The code should never reach this place (this means
1236
- // that the element somehow got namespace that is not
1237
- // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1238
- // Return false just in case.
1239
- return false;
1240
- };
1241
-
1242
- /**
1243
- * _forceRemove
1244
- *
1245
- * @param {Node} node a DOM node
1246
- */
1247
- const _forceRemove = function _forceRemove(node) {
1248
- arrayPush(DOMPurify.removed, {
1249
- element: node
1250
- });
1251
- try {
1252
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
1253
- node.parentNode.removeChild(node);
1254
- } catch (_) {
1255
- node.remove();
1256
- }
1257
- };
1258
-
1259
- /**
1260
- * _removeAttribute
1261
- *
1262
- * @param {String} name an Attribute name
1263
- * @param {Node} node a DOM node
1264
- */
1265
- const _removeAttribute = function _removeAttribute(name, node) {
1266
- try {
1267
- arrayPush(DOMPurify.removed, {
1268
- attribute: node.getAttributeNode(name),
1269
- from: node
1270
- });
1271
- } catch (_) {
1272
- arrayPush(DOMPurify.removed, {
1273
- attribute: null,
1274
- from: node
1275
- });
1276
- }
1277
- node.removeAttribute(name);
1278
-
1279
- // We void attribute values for unremovable "is"" attributes
1280
- if (name === 'is' && !ALLOWED_ATTR[name]) {
1281
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1282
- try {
1283
- _forceRemove(node);
1284
- } catch (_) {}
1285
- } else {
1286
- try {
1287
- node.setAttribute(name, '');
1288
- } catch (_) {}
1289
- }
1290
- }
1291
- };
1292
-
1293
- /**
1294
- * _initDocument
1295
- *
1296
- * @param {String} dirty a string of dirty markup
1297
- * @return {Document} a DOM, filled with the dirty markup
1298
- */
1299
- const _initDocument = function _initDocument(dirty) {
1300
- /* Create a HTML document */
1301
- let doc = null;
1302
- let leadingWhitespace = null;
1303
- if (FORCE_BODY) {
1304
- dirty = '<remove></remove>' + dirty;
1305
- } else {
1306
- /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1307
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1308
- leadingWhitespace = matches && matches[0];
1309
- }
1310
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1311
- // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1312
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1313
- }
1314
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
1315
- /*
1316
- * Use the DOMParser API by default, fallback later if needs be
1317
- * DOMParser not work for svg when has multiple root element.
1318
- */
1319
- if (NAMESPACE === HTML_NAMESPACE) {
1320
- try {
1321
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1322
- } catch (_) {}
1323
- }
1324
-
1325
- /* Use createHTMLDocument in case DOMParser is not available */
1326
- if (!doc || !doc.documentElement) {
1327
- doc = implementation.createDocument(NAMESPACE, 'template', null);
1328
- try {
1329
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1330
- } catch (_) {
1331
- // Syntax error if dirtyPayload is invalid xml
1332
- }
1333
- }
1334
- const body = doc.body || doc.documentElement;
1335
- if (dirty && leadingWhitespace) {
1336
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1337
- }
1338
-
1339
- /* Work on whole document or just its body */
1340
- if (NAMESPACE === HTML_NAMESPACE) {
1341
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1342
- }
1343
- return WHOLE_DOCUMENT ? doc.documentElement : body;
1344
- };
1345
-
1346
- /**
1347
- * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1348
- *
1349
- * @param {Node} root The root element or node to start traversing on.
1350
- * @return {NodeIterator} The created NodeIterator
1351
- */
1352
- const _createNodeIterator = function _createNodeIterator(root) {
1353
- return createNodeIterator.call(root.ownerDocument || root, root,
1354
- // eslint-disable-next-line no-bitwise
1355
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1356
- };
1357
-
1358
- /**
1359
- * _isClobbered
1360
- *
1361
- * @param {Node} elm element to check for clobbering attacks
1362
- * @return {Boolean} true if clobbered, false if safe
1363
- */
1364
- const _isClobbered = function _isClobbered(elm) {
1365
- return elm instanceof HTMLFormElement && (
1366
- // eslint-disable-next-line unicorn/no-typeof-undefined
1367
- typeof elm.__depth !== 'undefined' && typeof elm.__depth !== 'number' ||
1368
- // eslint-disable-next-line unicorn/no-typeof-undefined
1369
- typeof elm.__removalCount !== 'undefined' && typeof elm.__removalCount !== 'number' || typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
1370
- };
1371
-
1372
- /**
1373
- * Checks whether the given object is a DOM node.
1374
- *
1375
- * @param {Node} object object to check whether it's a DOM node
1376
- * @return {Boolean} true is object is a DOM node
1377
- */
1378
- const _isNode = function _isNode(object) {
1379
- return typeof Node === 'function' && object instanceof Node;
1380
- };
1381
-
1382
- /**
1383
- * _executeHook
1384
- * Execute user configurable hooks
1385
- *
1386
- * @param {String} entryPoint Name of the hook's entry point
1387
- * @param {Node} currentNode node to work on with the hook
1388
- * @param {Object} data additional hook parameters
1389
- */
1390
- const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1391
- if (!hooks[entryPoint]) {
1392
- return;
1393
- }
1394
- arrayForEach(hooks[entryPoint], hook => {
1395
- hook.call(DOMPurify, currentNode, data, CONFIG);
1396
- });
1397
- };
1398
-
1399
- /**
1400
- * _sanitizeElements
1401
- *
1402
- * @protect nodeName
1403
- * @protect textContent
1404
- * @protect removeChild
1405
- *
1406
- * @param {Node} currentNode to check for permission to exist
1407
- * @return {Boolean} true if node was killed, false if left alive
1408
- */
1409
- const _sanitizeElements = function _sanitizeElements(currentNode) {
1410
- let content = null;
1411
-
1412
- /* Execute a hook if present */
1413
- _executeHook('beforeSanitizeElements', currentNode, null);
1414
-
1415
- /* Check if element is clobbered or can clobber */
1416
- if (_isClobbered(currentNode)) {
1417
- _forceRemove(currentNode);
1418
- return true;
1419
- }
1420
-
1421
- /* Now let's check the element's type and name */
1422
- const tagName = transformCaseFunc(currentNode.nodeName);
1423
-
1424
- /* Execute a hook if present */
1425
- _executeHook('uponSanitizeElement', currentNode, {
1426
- tagName,
1427
- allowedTags: ALLOWED_TAGS
1428
- });
1429
-
1430
- /* Detect mXSS attempts abusing namespace confusion */
1431
- if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1432
- _forceRemove(currentNode);
1433
- return true;
1434
- }
1435
-
1436
- /* Remove any ocurrence of processing instructions */
1437
- if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1438
- _forceRemove(currentNode);
1439
- return true;
1440
- }
1441
-
1442
- /* Remove any kind of possibly harmful comments */
1443
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
1444
- _forceRemove(currentNode);
1445
- return true;
1446
- }
1447
-
1448
- /* Remove element if anything forbids its presence */
1449
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1450
- /* Check if we have a custom element to handle */
1451
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1452
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1453
- return false;
1454
- }
1455
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1456
- return false;
1457
- }
1458
- }
1459
-
1460
- /* Keep content except for bad-listed elements */
1461
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1462
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1463
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1464
- if (childNodes && parentNode) {
1465
- const childCount = childNodes.length;
1466
- for (let i = childCount - 1; i >= 0; --i) {
1467
- const childClone = cloneNode(childNodes[i], true);
1468
- childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
1469
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
1470
- }
1471
- }
1472
- }
1473
- _forceRemove(currentNode);
1474
- return true;
1475
- }
1476
-
1477
- /* Check whether element has a valid namespace */
1478
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1479
- _forceRemove(currentNode);
1480
- return true;
1481
- }
1482
-
1483
- /* Make sure that older browsers don't get fallback-tag mXSS */
1484
- if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1485
- _forceRemove(currentNode);
1486
- return true;
1487
- }
1488
-
1489
- /* Sanitize element content to be template-safe */
1490
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1491
- /* Get the element's text content */
1492
- content = currentNode.textContent;
1493
- arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1494
- content = stringReplace(content, expr, ' ');
1495
- });
1496
- if (currentNode.textContent !== content) {
1497
- arrayPush(DOMPurify.removed, {
1498
- element: currentNode.cloneNode()
1499
- });
1500
- currentNode.textContent = content;
1501
- }
1502
- }
1503
-
1504
- /* Execute a hook if present */
1505
- _executeHook('afterSanitizeElements', currentNode, null);
1506
- return false;
1507
- };
1508
-
1509
- /**
1510
- * _isValidAttribute
1511
- *
1512
- * @param {string} lcTag Lowercase tag name of containing element.
1513
- * @param {string} lcName Lowercase attribute name.
1514
- * @param {string} value Attribute value.
1515
- * @return {Boolean} Returns true if `value` is valid, otherwise false.
1516
- */
1517
- // eslint-disable-next-line complexity
1518
- const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1519
- /* Make sure attribute cannot clobber */
1520
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement || value === '__depth' || value === '__removalCount')) {
1521
- return false;
1522
- }
1523
-
1524
- /* Allow valid data-* attributes: At least one character after "-"
1525
- (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1526
- XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1527
- We don't need to check the value; it's always URI safe. */
1528
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1529
- if (
1530
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1531
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1532
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1533
- _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
1534
- // Alternative, second condition checks if it's an `is`-attribute, AND
1535
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1536
- lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
1537
- return false;
1538
- }
1539
- /* Check value is safe. First, is attr inert? If so, is safe */
1540
- } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
1541
- return false;
1542
- } else ;
1543
- return true;
1544
- };
1545
-
1546
- /**
1547
- * _isBasicCustomElement
1548
- * checks if at least one dash is included in tagName, and it's not the first char
1549
- * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1550
- *
1551
- * @param {string} tagName name of the tag of the node to sanitize
1552
- * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1553
- */
1554
- const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1555
- return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
1556
- };
1557
-
1558
- /**
1559
- * _sanitizeAttributes
1560
- *
1561
- * @protect attributes
1562
- * @protect nodeName
1563
- * @protect removeAttribute
1564
- * @protect setAttribute
1565
- *
1566
- * @param {Node} currentNode to sanitize
1567
- */
1568
- const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1569
- /* Execute a hook if present */
1570
- _executeHook('beforeSanitizeAttributes', currentNode, null);
1571
- const {
1572
- attributes
1573
- } = currentNode;
1574
-
1575
- /* Check if we have attributes; if not we might have a text node */
1576
- if (!attributes) {
1577
- return;
1578
- }
1579
- const hookEvent = {
1580
- attrName: '',
1581
- attrValue: '',
1582
- keepAttr: true,
1583
- allowedAttributes: ALLOWED_ATTR
1584
- };
1585
- let l = attributes.length;
1586
-
1587
- /* Go backwards over all attributes; safely remove bad ones */
1588
- while (l--) {
1589
- const attr = attributes[l];
1590
- const {
1591
- name,
1592
- namespaceURI,
1593
- value: attrValue
1594
- } = attr;
1595
- const lcName = transformCaseFunc(name);
1596
- let value = name === 'value' ? attrValue : stringTrim(attrValue);
1597
-
1598
- /* Execute a hook if present */
1599
- hookEvent.attrName = lcName;
1600
- hookEvent.attrValue = value;
1601
- hookEvent.keepAttr = true;
1602
- hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1603
- _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1604
- value = hookEvent.attrValue;
1605
- /* Did the hooks approve of the attribute? */
1606
- if (hookEvent.forceKeepAttr) {
1607
- continue;
1608
- }
1609
-
1610
- /* Remove attribute */
1611
- _removeAttribute(name, currentNode);
1612
-
1613
- /* Did the hooks approve of the attribute? */
1614
- if (!hookEvent.keepAttr) {
1615
- continue;
1616
- }
1617
-
1618
- /* Work around a security issue in jQuery 3.0 */
1619
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1620
- _removeAttribute(name, currentNode);
1621
- continue;
1622
- }
1623
-
1624
- /* Work around a security issue with comments inside attributes */
1625
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1626
- _removeAttribute(name, currentNode);
1627
- continue;
1628
- }
1629
-
1630
- /* Sanitize attribute content to be template-safe */
1631
- if (SAFE_FOR_TEMPLATES) {
1632
- arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1633
- value = stringReplace(value, expr, ' ');
1634
- });
1635
- }
1636
-
1637
- /* Is `value` valid for this attribute? */
1638
- const lcTag = transformCaseFunc(currentNode.nodeName);
1639
- if (!_isValidAttribute(lcTag, lcName, value)) {
1640
- continue;
1641
- }
1642
-
1643
- /* Full DOM Clobbering protection via namespace isolation,
1644
- * Prefix id and name attributes with `user-content-`
1645
- */
1646
- if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1647
- // Remove the attribute with this value
1648
- _removeAttribute(name, currentNode);
1649
-
1650
- // Prefix the value and later re-create the attribute with the sanitized value
1651
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
1652
- }
1653
-
1654
- /* Handle attributes that require Trusted Types */
1655
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1656
- if (namespaceURI) ; else {
1657
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1658
- case 'TrustedHTML':
1659
- {
1660
- value = trustedTypesPolicy.createHTML(value);
1661
- break;
1662
- }
1663
- case 'TrustedScriptURL':
1664
- {
1665
- value = trustedTypesPolicy.createScriptURL(value);
1666
- break;
1667
- }
1668
- }
1669
- }
1670
- }
1671
-
1672
- /* Handle invalid data-* attribute set by try-catching it */
1673
- try {
1674
- if (namespaceURI) {
1675
- currentNode.setAttributeNS(namespaceURI, name, value);
1676
- } else {
1677
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1678
- currentNode.setAttribute(name, value);
1679
- }
1680
- if (_isClobbered(currentNode)) {
1681
- _forceRemove(currentNode);
1682
- } else {
1683
- arrayPop(DOMPurify.removed);
1684
- }
1685
- } catch (_) {}
1686
- }
1687
-
1688
- /* Execute a hook if present */
1689
- _executeHook('afterSanitizeAttributes', currentNode, null);
1690
- };
1691
-
1692
- /**
1693
- * _sanitizeShadowDOM
1694
- *
1695
- * @param {DocumentFragment} fragment to iterate over recursively
1696
- */
1697
- const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1698
- let shadowNode = null;
1699
- const shadowIterator = _createNodeIterator(fragment);
1700
-
1701
- /* Execute a hook if present */
1702
- _executeHook('beforeSanitizeShadowDOM', fragment, null);
1703
- while (shadowNode = shadowIterator.nextNode()) {
1704
- /* Execute a hook if present */
1705
- _executeHook('uponSanitizeShadowNode', shadowNode, null);
1706
-
1707
- /* Sanitize tags and elements */
1708
- if (_sanitizeElements(shadowNode)) {
1709
- continue;
1710
- }
1711
- const parentNode = getParentNode(shadowNode);
1712
-
1713
- /* Set the nesting depth of an element */
1714
- if (shadowNode.nodeType === NODE_TYPE.element) {
1715
- if (parentNode && parentNode.__depth) {
1716
- /*
1717
- We want the depth of the node in the original tree, which can
1718
- change when it's removed from its parent.
1719
- */
1720
- shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
1721
- } else {
1722
- shadowNode.__depth = 1;
1723
- }
1724
- }
1725
-
1726
- /*
1727
- * Remove an element if nested too deeply to avoid mXSS
1728
- * or if the __depth might have been tampered with
1729
- */
1730
- if (shadowNode.__depth >= MAX_NESTING_DEPTH || shadowNode.__depth < 0 || numberIsNaN(shadowNode.__depth)) {
1731
- _forceRemove(shadowNode);
1732
- }
1733
-
1734
- /* Deep shadow DOM detected */
1735
- if (shadowNode.content instanceof DocumentFragment) {
1736
- shadowNode.content.__depth = shadowNode.__depth;
1737
- _sanitizeShadowDOM(shadowNode.content);
1738
- }
1739
-
1740
- /* Check attributes, sanitize if necessary */
1741
- _sanitizeAttributes(shadowNode);
1742
- }
1743
-
1744
- /* Execute a hook if present */
1745
- _executeHook('afterSanitizeShadowDOM', fragment, null);
1746
- };
1747
-
1748
- /**
1749
- * Sanitize
1750
- * Public method providing core sanitation functionality
1751
- *
1752
- * @param {String|Node} dirty string or DOM node
1753
- * @param {Object} cfg object
1754
- */
1755
- // eslint-disable-next-line complexity
1756
- DOMPurify.sanitize = function (dirty) {
1757
- let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1758
- let body = null;
1759
- let importedNode = null;
1760
- let currentNode = null;
1761
- let returnNode = null;
1762
- /* Make sure we have a string to sanitize.
1763
- DO NOT return early, as this will return the wrong type if
1764
- the user has requested a DOM object rather than a string */
1765
- IS_EMPTY_INPUT = !dirty;
1766
- if (IS_EMPTY_INPUT) {
1767
- dirty = '<!-->';
1768
- }
1769
-
1770
- /* Stringify, in case dirty is an object */
1771
- if (typeof dirty !== 'string' && !_isNode(dirty)) {
1772
- if (typeof dirty.toString === 'function') {
1773
- dirty = dirty.toString();
1774
- if (typeof dirty !== 'string') {
1775
- throw typeErrorCreate('dirty is not a string, aborting');
1776
- }
1777
- } else {
1778
- throw typeErrorCreate('toString is not a function');
1779
- }
1780
- }
1781
-
1782
- /* Return dirty HTML if DOMPurify cannot run */
1783
- if (!DOMPurify.isSupported) {
1784
- return dirty;
1785
- }
1786
-
1787
- /* Assign config vars */
1788
- if (!SET_CONFIG) {
1789
- _parseConfig(cfg);
1790
- }
1791
-
1792
- /* Clean up removed elements */
1793
- DOMPurify.removed = [];
1794
-
1795
- /* Check if dirty is correctly typed for IN_PLACE */
1796
- if (typeof dirty === 'string') {
1797
- IN_PLACE = false;
1798
- }
1799
- if (IN_PLACE) {
1800
- /* Do some early pre-sanitization to avoid unsafe root nodes */
1801
- if (dirty.nodeName) {
1802
- const tagName = transformCaseFunc(dirty.nodeName);
1803
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1804
- throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1805
- }
1806
- }
1807
- } else if (dirty instanceof Node) {
1808
- /* If dirty is a DOM element, append to an empty document to avoid
1809
- elements being stripped by the parser */
1810
- body = _initDocument('<!---->');
1811
- importedNode = body.ownerDocument.importNode(dirty, true);
1812
- if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
1813
- /* Node is already a body, use as is */
1814
- body = importedNode;
1815
- } else if (importedNode.nodeName === 'HTML') {
1816
- body = importedNode;
1817
- } else {
1818
- // eslint-disable-next-line unicorn/prefer-dom-node-append
1819
- body.appendChild(importedNode);
1820
- }
1821
- } else {
1822
- /* Exit directly if we have nothing to do */
1823
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1824
- // eslint-disable-next-line unicorn/prefer-includes
1825
- dirty.indexOf('<') === -1) {
1826
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1827
- }
1828
-
1829
- /* Initialize the document to work on */
1830
- body = _initDocument(dirty);
1831
-
1832
- /* Check we have a DOM node from the data */
1833
- if (!body) {
1834
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1835
- }
1836
- }
1837
-
1838
- /* Remove first element node (ours) if FORCE_BODY is set */
1839
- if (body && FORCE_BODY) {
1840
- _forceRemove(body.firstChild);
1841
- }
1842
-
1843
- /* Get node iterator */
1844
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1845
-
1846
- /* Now start iterating over the created document */
1847
- while (currentNode = nodeIterator.nextNode()) {
1848
- /* Sanitize tags and elements */
1849
- if (_sanitizeElements(currentNode)) {
1850
- continue;
1851
- }
1852
- const parentNode = getParentNode(currentNode);
1853
-
1854
- /* Set the nesting depth of an element */
1855
- if (currentNode.nodeType === NODE_TYPE.element) {
1856
- if (parentNode && parentNode.__depth) {
1857
- /*
1858
- We want the depth of the node in the original tree, which can
1859
- change when it's removed from its parent.
1860
- */
1861
- currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
1862
- } else {
1863
- currentNode.__depth = 1;
1864
- }
1865
- }
1866
-
1867
- /*
1868
- * Remove an element if nested too deeply to avoid mXSS
1869
- * or if the __depth might have been tampered with
1870
- */
1871
- if (currentNode.__depth >= MAX_NESTING_DEPTH || currentNode.__depth < 0 || numberIsNaN(currentNode.__depth)) {
1872
- _forceRemove(currentNode);
1873
- }
1874
-
1875
- /* Shadow DOM detected, sanitize it */
1876
- if (currentNode.content instanceof DocumentFragment) {
1877
- currentNode.content.__depth = currentNode.__depth;
1878
- _sanitizeShadowDOM(currentNode.content);
1879
- }
1880
-
1881
- /* Check attributes, sanitize if necessary */
1882
- _sanitizeAttributes(currentNode);
1883
- }
1884
-
1885
- /* If we sanitized `dirty` in-place, return it. */
1886
- if (IN_PLACE) {
1887
- return dirty;
1888
- }
1889
-
1890
- /* Return sanitized string or DOM */
1891
- if (RETURN_DOM) {
1892
- if (RETURN_DOM_FRAGMENT) {
1893
- returnNode = createDocumentFragment.call(body.ownerDocument);
1894
- while (body.firstChild) {
1895
- // eslint-disable-next-line unicorn/prefer-dom-node-append
1896
- returnNode.appendChild(body.firstChild);
1897
- }
1898
- } else {
1899
- returnNode = body;
1900
- }
1901
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1902
- /*
1903
- AdoptNode() is not used because internal state is not reset
1904
- (e.g. the past names map of a HTMLFormElement), this is safe
1905
- in theory but we would rather not risk another attack vector.
1906
- The state that is cloned by importNode() is explicitly defined
1907
- by the specs.
1908
- */
1909
- returnNode = importNode.call(originalDocument, returnNode, true);
1910
- }
1911
- return returnNode;
1912
- }
1913
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1914
-
1915
- /* Serialize doctype if allowed */
1916
- if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1917
- serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1918
- }
1919
-
1920
- /* Sanitize final string template-safe */
1921
- if (SAFE_FOR_TEMPLATES) {
1922
- arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1923
- serializedHTML = stringReplace(serializedHTML, expr, ' ');
1924
- });
1925
- }
1926
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1927
- };
1928
-
1929
- /**
1930
- * Public method to set the configuration once
1931
- * setConfig
1932
- *
1933
- * @param {Object} cfg configuration object
1934
- */
1935
- DOMPurify.setConfig = function () {
1936
- let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1937
- _parseConfig(cfg);
1938
- SET_CONFIG = true;
1939
- };
1940
-
1941
- /**
1942
- * Public method to remove the configuration
1943
- * clearConfig
1944
- *
1945
- */
1946
- DOMPurify.clearConfig = function () {
1947
- CONFIG = null;
1948
- SET_CONFIG = false;
1949
- };
1950
-
1951
- /**
1952
- * Public method to check if an attribute value is valid.
1953
- * Uses last set config, if any. Otherwise, uses config defaults.
1954
- * isValidAttribute
1955
- *
1956
- * @param {String} tag Tag name of containing element.
1957
- * @param {String} attr Attribute name.
1958
- * @param {String} value Attribute value.
1959
- * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1960
- */
1961
- DOMPurify.isValidAttribute = function (tag, attr, value) {
1962
- /* Initialize shared config vars if necessary. */
1963
- if (!CONFIG) {
1964
- _parseConfig({});
1965
- }
1966
- const lcTag = transformCaseFunc(tag);
1967
- const lcName = transformCaseFunc(attr);
1968
- return _isValidAttribute(lcTag, lcName, value);
1969
- };
1970
-
1971
- /**
1972
- * AddHook
1973
- * Public method to add DOMPurify hooks
1974
- *
1975
- * @param {String} entryPoint entry point for the hook to add
1976
- * @param {Function} hookFunction function to execute
1977
- */
1978
- DOMPurify.addHook = function (entryPoint, hookFunction) {
1979
- if (typeof hookFunction !== 'function') {
1980
- return;
1981
- }
1982
- hooks[entryPoint] = hooks[entryPoint] || [];
1983
- arrayPush(hooks[entryPoint], hookFunction);
1984
- };
1985
-
1986
- /**
1987
- * RemoveHook
1988
- * Public method to remove a DOMPurify hook at a given entryPoint
1989
- * (pops it from the stack of hooks if more are present)
1990
- *
1991
- * @param {String} entryPoint entry point for the hook to remove
1992
- * @return {Function} removed(popped) hook
1993
- */
1994
- DOMPurify.removeHook = function (entryPoint) {
1995
- if (hooks[entryPoint]) {
1996
- return arrayPop(hooks[entryPoint]);
1997
- }
1998
- };
1999
-
2000
- /**
2001
- * RemoveHooks
2002
- * Public method to remove all DOMPurify hooks at a given entryPoint
2003
- *
2004
- * @param {String} entryPoint entry point for the hooks to remove
2005
- */
2006
- DOMPurify.removeHooks = function (entryPoint) {
2007
- if (hooks[entryPoint]) {
2008
- hooks[entryPoint] = [];
2009
- }
2010
- };
2011
-
2012
- /**
2013
- * RemoveAllHooks
2014
- * Public method to remove all DOMPurify hooks
2015
- */
2016
- DOMPurify.removeAllHooks = function () {
2017
- hooks = {};
2018
- };
2019
- return DOMPurify;
2020
- }
2021
- var purify = createDOMPurify();
2022
-
2023
418
  var getInitialTab = function getInitialTab(stripeAccount) {
2024
419
  if (stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected) {
2025
420
  return STEPS.finish;
@@ -2043,7 +438,7 @@ var Connect = function Connect(_ref) {
2043
438
  var _useTranslation = reactI18next.useTranslation(),
2044
439
  t = _useTranslation.t;
2045
440
  var _useState = React.useState(INTEGRATION_METHOD.createNewAccount),
2046
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
441
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
2047
442
  selectedOption = _useState2[0],
2048
443
  setSelectedOption = _useState2[1];
2049
444
  var stripeConnectUrl = buildStripeConnectUrl(holdableId, returnUrl);
@@ -2052,7 +447,7 @@ var Connect = function Connect(_ref) {
2052
447
  setActiveTab(STEPS.configure);
2053
448
  return;
2054
449
  }
2055
- window.location.href = purify.sanitize(stripeConnectUrl);
450
+ window.location.href = DOMPurify__default["default"].sanitize(stripeConnectUrl);
2056
451
  };
2057
452
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2058
453
  className: "mx-auto w-full max-w-lg space-y-8",
@@ -2102,7 +497,7 @@ var Finish = reactUtils.withT(function (_ref) {
2102
497
  });
2103
498
 
2104
499
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2105
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { defineProperty._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
500
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2106
501
  var StripeConnect = function StripeConnect(_ref) {
2107
502
  var _ref$holdableId = _ref.holdableId,
2108
503
  holdableId = _ref$holdableId === void 0 ? null : _ref$holdableId,
@@ -2116,11 +511,11 @@ var StripeConnect = function StripeConnect(_ref) {
2116
511
  _useFetchConnectedStr3 = _useFetchConnectedStr2 === void 0 ? {} : _useFetchConnectedStr2,
2117
512
  stripeAccount = _useFetchConnectedStr3.account;
2118
513
  var _useStateWithDependen = reactUtils.useStateWithDependency(getInitialTab(stripeAccount), [stripeAccount]),
2119
- _useStateWithDependen2 = slicedToArray._slicedToArray(_useStateWithDependen, 2),
514
+ _useStateWithDependen2 = _slicedToArray__default["default"](_useStateWithDependen, 2),
2120
515
  activeTab = _useStateWithDependen2[0],
2121
516
  setActiveTab = _useStateWithDependen2[1];
2122
517
  var steps = React.useMemo(function () {
2123
- var _INTEGRATION_STEPS = slicedToArray._slicedToArray(INTEGRATION_STEPS, 4),
518
+ var _INTEGRATION_STEPS = _slicedToArray__default["default"](INTEGRATION_STEPS, 4),
2124
519
  connect = _INTEGRATION_STEPS[0],
2125
520
  configure = _INTEGRATION_STEPS[1],
2126
521
  finish = _INTEGRATION_STEPS[2],