@locker/cli 0.28.3 → 0.28.5
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.
- package/README.md +195 -0
- package/bin/lws.mjs +185 -30
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs.js +1 -1
- package/dist/lws-sandbox.js +149 -46
- package/dist/purify.js +2 -2
- package/package.json +7 -5
- package/src/compile-lwc.mjs +37 -0
- package/src/config-resolver.mjs +269 -0
- package/src/constants.mjs +18 -0
- package/src/gates.mjs +132 -0
- package/src/output.mjs +19 -0
- package/src/playwright-check.mjs +65 -0
- package/src/repl.mjs +15 -0
- package/src/runner.mjs +68 -0
- package/src/sandbox-entry.ts +25 -0
- package/src/wire-mock.mjs +733 -0
package/dist/lws-sandbox.js
CHANGED
|
@@ -1354,6 +1354,27 @@
|
|
|
1354
1354
|
const gaterEnabledFeatures$LWS = toSafeSet$LWS(new SetCtor$LWS$1());
|
|
1355
1355
|
const FEATURE_NAME_PREFIX$LWS = 'com.salesforce.locker.';
|
|
1356
1356
|
const fullName$LWS = featureName$LWS => featureName$LWS.startsWith(FEATURE_NAME_PREFIX$LWS) ? featureName$LWS : `${FEATURE_NAME_PREFIX$LWS}${featureName$LWS}`;
|
|
1357
|
+
// The canonical set of LWS feature gates that are enabled in the test
|
|
1358
|
+
// harness (karma), and therefore in CI. This is the single source of truth
|
|
1359
|
+
// for "what gates a faithful LWS run turns on". Consumers register it as
|
|
1360
|
+
// their baseline so they reproduce CI's gate state: the karma evaluator
|
|
1361
|
+
// registers exactly this list before running tests, and the @locker/cli
|
|
1362
|
+
// tool registers it as the default for a `lws` run. Adding a gate here
|
|
1363
|
+
// turns it on by default in every consumer that registers this list.
|
|
1364
|
+
//
|
|
1365
|
+
// This is an inert exported constant, never auto-registered at module
|
|
1366
|
+
// load: registering here would change behavior for every @locker/shared
|
|
1367
|
+
// consumer. Each consumer opts in by passing it to
|
|
1368
|
+
// registerGaterEnabledFeatures. Names are fully qualified so the value
|
|
1369
|
+
// reads identically to what isGaterEnabledFeature stores (register and
|
|
1370
|
+
// deregister also accept the short form via fullName above). Frozen so a
|
|
1371
|
+
// consumer cannot mutate the shared array.
|
|
1372
|
+
Object.freeze([`${FEATURE_NAME_PREFIX$LWS}changesSince.260`, `${FEATURE_NAME_PREFIX$LWS}changesSince.262`, `${FEATURE_NAME_PREFIX$LWS}changesSince.264`, `${FEATURE_NAME_PREFIX$LWS}htmlAnchorElementHrefValidation`, `${FEATURE_NAME_PREFIX$LWS}enableSandboxedSameOriginIframe`, `${FEATURE_NAME_PREFIX$LWS}xmlEntityAttackPrologScan`]);
|
|
1373
|
+
function registerGaterEnabledFeatures$LWS(lockerGaterEnabledFeatures$LWS) {
|
|
1374
|
+
if (ArrayIsArray$LWS$1(lockerGaterEnabledFeatures$LWS)) {
|
|
1375
|
+
lockerGaterEnabledFeatures$LWS.forEach(feature$LWS => gaterEnabledFeatures$LWS.add(fullName$LWS(feature$LWS)));
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1357
1378
|
function isGaterEnabledFeature$LWS(featureName$LWS) {
|
|
1358
1379
|
return gaterEnabledFeatures$LWS.has(fullName$LWS(featureName$LWS));
|
|
1359
1380
|
}
|
|
@@ -1518,7 +1539,7 @@
|
|
|
1518
1539
|
const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
|
|
1519
1540
|
const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
|
|
1520
1541
|
toSafeSet$LWS(new SetCtor$LWS$1());
|
|
1521
|
-
/*! version: 0.28.
|
|
1542
|
+
/*! version: 0.28.5 */
|
|
1522
1543
|
|
|
1523
1544
|
/*!
|
|
1524
1545
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -1986,6 +2007,69 @@
|
|
|
1986
2007
|
// Matches: <!DOCTYPE root SYSTEM "..."> or <!DOCTYPE root PUBLIC "..." "...">
|
|
1987
2008
|
// External DTDs can define entities that get expanded with malicious content.
|
|
1988
2009
|
const DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS = /<!doctype\s+\S+\s+(?:system|public)\s/;
|
|
2010
|
+
const DOCTYPE_OPENER$LWS = '<!doctype';
|
|
2011
|
+
const PI_OPENER$LWS = '<?';
|
|
2012
|
+
const PI_CLOSER$LWS = '?>';
|
|
2013
|
+
const COMMENT_OPENER$LWS = '<!--';
|
|
2014
|
+
const COMMENT_CLOSER$LWS = '-->';
|
|
2015
|
+
// Locate a DOCTYPE that sits in the document prolog — the only position where a
|
|
2016
|
+
// DTD is actually parsed and where entity definitions can take effect. A DTD is
|
|
2017
|
+
// only meaningful before the root element's start tag; anything after the root
|
|
2018
|
+
// element opens (text, CDATA sections, comments, processing instructions) is
|
|
2019
|
+
// inert character data and can never act as a DTD, no matter what it spells.
|
|
2020
|
+
//
|
|
2021
|
+
// Returns the prolog slice beginning at the DOCTYPE so the existing
|
|
2022
|
+
// dangerous-form regexes can classify it, or null when the prolog contains no
|
|
2023
|
+
// DOCTYPE. Walks the prolog token by token, skipping the XML declaration and
|
|
2024
|
+
// processing instructions (`<?...?>`) and comments (`<!-- ... -->`), and stops
|
|
2025
|
+
// at the first other `<` — that is the root element's start tag. Skipping
|
|
2026
|
+
// comments here is what defeats the `<!-- <![CDATA[ -->` decoy: a real prolog
|
|
2027
|
+
// DOCTYPE after a comment is still found, and a DOCTYPE buried inside a comment
|
|
2028
|
+
// is correctly ignored.
|
|
2029
|
+
function findPrologDoctype$LWS(normalizedInput$LWS) {
|
|
2030
|
+
const {
|
|
2031
|
+
length: length$LWS
|
|
2032
|
+
} = normalizedInput$LWS;
|
|
2033
|
+
let index$LWS = 0;
|
|
2034
|
+
while (index$LWS < length$LWS) {
|
|
2035
|
+
const char$LWS = ReflectApply$LWS$1(StringProtoCharAt$LWS, normalizedInput$LWS, [index$LWS]);
|
|
2036
|
+
// Skip insignificant whitespace between prolog tokens.
|
|
2037
|
+
if (char$LWS === ' ' || char$LWS === '\t' || char$LWS === '\n' || char$LWS === '\r') {
|
|
2038
|
+
index$LWS += 1;
|
|
2039
|
+
continue;
|
|
2040
|
+
}
|
|
2041
|
+
// Anything that is not a markup-opening `<` at this point is either the
|
|
2042
|
+
// start of the root element's content model or malformed; in both cases
|
|
2043
|
+
// there is no prolog DOCTYPE to find.
|
|
2044
|
+
if (char$LWS !== '<') {
|
|
2045
|
+
return null;
|
|
2046
|
+
}
|
|
2047
|
+
if (ReflectApply$LWS$1(StringProtoStartsWith$LWS, normalizedInput$LWS, [DOCTYPE_OPENER$LWS, index$LWS])) {
|
|
2048
|
+
return ReflectApply$LWS$1(StringProtoSlice$LWS$1, normalizedInput$LWS, [index$LWS]);
|
|
2049
|
+
}
|
|
2050
|
+
if (ReflectApply$LWS$1(StringProtoStartsWith$LWS, normalizedInput$LWS, [COMMENT_OPENER$LWS, index$LWS])) {
|
|
2051
|
+
const closerOffset$LWS = ReflectApply$LWS$1(StringProtoIndexOf$LWS, normalizedInput$LWS, [COMMENT_CLOSER$LWS, index$LWS + COMMENT_OPENER$LWS.length]);
|
|
2052
|
+
// Unterminated comment: no well-formed prolog DOCTYPE can follow.
|
|
2053
|
+
if (closerOffset$LWS === -1) {
|
|
2054
|
+
return null;
|
|
2055
|
+
}
|
|
2056
|
+
index$LWS = closerOffset$LWS + COMMENT_CLOSER$LWS.length;
|
|
2057
|
+
continue;
|
|
2058
|
+
}
|
|
2059
|
+
if (ReflectApply$LWS$1(StringProtoStartsWith$LWS, normalizedInput$LWS, [PI_OPENER$LWS, index$LWS])) {
|
|
2060
|
+
const closerOffset$LWS = ReflectApply$LWS$1(StringProtoIndexOf$LWS, normalizedInput$LWS, [PI_CLOSER$LWS, index$LWS + PI_OPENER$LWS.length]);
|
|
2061
|
+
if (closerOffset$LWS === -1) {
|
|
2062
|
+
return null;
|
|
2063
|
+
}
|
|
2064
|
+
index$LWS = closerOffset$LWS + PI_CLOSER$LWS.length;
|
|
2065
|
+
continue;
|
|
2066
|
+
}
|
|
2067
|
+
// First `<` that is not a PI, comment, or DOCTYPE is the root element
|
|
2068
|
+
// start tag. The prolog has ended without a DOCTYPE.
|
|
2069
|
+
return null;
|
|
2070
|
+
}
|
|
2071
|
+
return null;
|
|
2072
|
+
}
|
|
1989
2073
|
/* eslint-disable no-underscore-dangle */
|
|
1990
2074
|
class Validator$LWS {
|
|
1991
2075
|
constructor(document$LWS, {
|
|
@@ -2002,12 +2086,28 @@
|
|
|
2002
2086
|
// Detect XML External Entity (XXE) injection attacks via DOCTYPE declarations.
|
|
2003
2087
|
// Attackers can embed malicious script content inside ENTITY definitions that
|
|
2004
2088
|
// get expanded when the XML/SVG is rendered, bypassing DOMPurify sanitization.
|
|
2089
|
+
//
|
|
2090
|
+
// A DTD only takes effect when it appears in the document prolog (before the
|
|
2091
|
+
// root element). The original guard scanned the entire input for a dangerous
|
|
2092
|
+
// DOCTYPE substring, which also rejected benign documents that merely quote a
|
|
2093
|
+
// DOCTYPE as inert text — inside a CDATA section, an XML comment, or element
|
|
2094
|
+
// text. The prolog-aware path keeps the dangerous-form classification
|
|
2095
|
+
// (internal subset, SYSTEM/PUBLIC external reference) exactly as-is, but only
|
|
2096
|
+
// applies it to a DOCTYPE that actually sits in the prolog. When the gate is
|
|
2097
|
+
// off, the original whole-input scan is preserved.
|
|
2005
2098
|
// eslint-disable-next-line class-methods-use-this
|
|
2006
2099
|
this.isXMLEntityAttack = input$LWS => {
|
|
2007
2100
|
const normalizedInput$LWS = normalizeInput$LWS(input$LWS, ' ');
|
|
2008
2101
|
// Block DOCTYPE with:
|
|
2009
2102
|
// - Internal DTD subset (e.g., <!DOCTYPE svg [<!ENTITY foo "...">]>)
|
|
2010
2103
|
// - SYSTEM or PUBLIC external entity references
|
|
2104
|
+
if (isGaterEnabledFeature$LWS('xmlEntityAttackPrologScan')) {
|
|
2105
|
+
const prologDoctype$LWS = findPrologDoctype$LWS(normalizedInput$LWS);
|
|
2106
|
+
if (prologDoctype$LWS === null) {
|
|
2107
|
+
return false;
|
|
2108
|
+
}
|
|
2109
|
+
return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_WITH_INTERNAL_SUBSET_REGEX$LWS, [prologDoctype$LWS]) || ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS, [prologDoctype$LWS]);
|
|
2110
|
+
}
|
|
2011
2111
|
return ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_WITH_INTERNAL_SUBSET_REGEX$LWS, [normalizedInput$LWS]) || ReflectApply$LWS$1(RegExpProtoTest$LWS$1, DOCTYPE_EXTERNAL_ENTITY_REGEX$LWS, [normalizedInput$LWS]);
|
|
2012
2112
|
};
|
|
2013
2113
|
// Detect namespaced script elements that execute in XML contexts.
|
|
@@ -2184,11 +2284,8 @@
|
|
|
2184
2284
|
return false;
|
|
2185
2285
|
}
|
|
2186
2286
|
function hasTag$LWS(input$LWS, tag$LWS) {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
// Input is already lowercased and invisible chars stripped by caller
|
|
2190
|
-
checkableInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, input$LWS, [/\s+/g, ' ']);
|
|
2191
|
-
}
|
|
2287
|
+
// Input is already lowercased and invisible chars stripped by caller
|
|
2288
|
+
const checkableInput$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, input$LWS, [/\s+/g, ' ']);
|
|
2192
2289
|
// Match <tag or :tag (namespaced) followed by whitespace, >, /
|
|
2193
2290
|
// Also match when directly followed by src or srcdoc (null byte was stripped)
|
|
2194
2291
|
const tagPattern$LWS = new RegExpCtor$LWS$1(`[<:]${tag$LWS}(?:[\\s>/]|(?=src))`);
|
|
@@ -2522,7 +2619,7 @@
|
|
|
2522
2619
|
const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
|
|
2523
2620
|
const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
|
|
2524
2621
|
ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
|
|
2525
|
-
/*! version: 0.28.
|
|
2622
|
+
/*! version: 0.28.5 */
|
|
2526
2623
|
|
|
2527
2624
|
/*!
|
|
2528
2625
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -2690,7 +2787,7 @@
|
|
|
2690
2787
|
}
|
|
2691
2788
|
return sanitized$LWS;
|
|
2692
2789
|
}
|
|
2693
|
-
/*! version: 0.28.
|
|
2790
|
+
/*! version: 0.28.5 */
|
|
2694
2791
|
|
|
2695
2792
|
/*!
|
|
2696
2793
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
@@ -2766,7 +2863,7 @@
|
|
|
2766
2863
|
// swallow
|
|
2767
2864
|
}
|
|
2768
2865
|
const trusted = createPolicy('trusted', policyOptions);
|
|
2769
|
-
/*! version: 0.28.
|
|
2866
|
+
/*! version: 0.28.5 */
|
|
2770
2867
|
|
|
2771
2868
|
/*!
|
|
2772
2869
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -3075,7 +3172,7 @@
|
|
|
3075
3172
|
}
|
|
3076
3173
|
return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
|
|
3077
3174
|
}
|
|
3078
|
-
/*! version: 0.28.
|
|
3175
|
+
/*! version: 0.28.5 */
|
|
3079
3176
|
|
|
3080
3177
|
/*!
|
|
3081
3178
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
@@ -3284,7 +3381,7 @@
|
|
|
3284
3381
|
ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
|
|
3285
3382
|
};
|
|
3286
3383
|
}
|
|
3287
|
-
/*! version: 0.28.
|
|
3384
|
+
/*! version: 0.28.5 */
|
|
3288
3385
|
|
|
3289
3386
|
/*!
|
|
3290
3387
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -5388,14 +5485,8 @@
|
|
|
5388
5485
|
}
|
|
5389
5486
|
const childWindow$LWS = ReflectApply$LWS$1(originalDocumentOpen$LWS, this, normalizedArgs$LWS);
|
|
5390
5487
|
// istanbul ignore next: behavior will not be tested in collection coverage
|
|
5391
|
-
if (!isGaterEnabledFeature$LWS('changesSince.262')) {
|
|
5392
|
-
|
|
5393
|
-
if (isSameOriginURL$LWS(resourceUrl$LWS)) {
|
|
5394
|
-
markForUnsafePropertyBlocking$LWS(childWindow$LWS);
|
|
5395
|
-
}
|
|
5396
|
-
} else {
|
|
5397
|
-
markForUnsafePropertyBlocking$LWS(childWindow$LWS);
|
|
5398
|
-
}
|
|
5488
|
+
if (!isGaterEnabledFeature$LWS('changesSince.262') && isSameOriginURL$LWS(resourceUrl$LWS)) {
|
|
5489
|
+
markForUnsafePropertyBlocking$LWS(childWindow$LWS);
|
|
5399
5490
|
}
|
|
5400
5491
|
if (childWindow$LWS) {
|
|
5401
5492
|
initWindowOpenChildWindow$LWS(childWindow$LWS, resourceUrl$LWS);
|
|
@@ -7784,14 +7875,12 @@
|
|
|
7784
7875
|
if (urlString$LWS && !isValidURLScheme$LWS(urlString$LWS)) {
|
|
7785
7876
|
throw new LockerSecurityError$LWS('HTMLIFrameElement.src supports http://, https:// schemes, relative urls and about:blank.');
|
|
7786
7877
|
}
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
throw new LockerSecurityError$LWS(`Cannot request disallowed endpoint: ${toSafeTemplateStringValue$LWS(normalizedURL$LWS)}`);
|
|
7794
|
-
}
|
|
7878
|
+
const parsedURL$LWS = parseURL$LWS(urlString$LWS);
|
|
7879
|
+
if (!isAllowedEndpointURL$LWS(parsedURL$LWS)) {
|
|
7880
|
+
const {
|
|
7881
|
+
normalizedURL: normalizedURL$LWS
|
|
7882
|
+
} = parsedURL$LWS;
|
|
7883
|
+
throw new LockerSecurityError$LWS(`Cannot request disallowed endpoint: ${toSafeTemplateStringValue$LWS(normalizedURL$LWS)}`);
|
|
7795
7884
|
}
|
|
7796
7885
|
// Same-origin URLs go through an async pre-flight that fetches
|
|
7797
7886
|
// the resource and runs its body through the rootValidator
|
|
@@ -8722,7 +8811,7 @@
|
|
|
8722
8811
|
const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElement$LWS.prototype, 'textContent');
|
|
8723
8812
|
// This may not be implemented in all browsers.
|
|
8724
8813
|
// https://www.w3.org/TR/trusted-types/#enforcement-in-scripts
|
|
8725
|
-
if (!
|
|
8814
|
+
if (!descriptor$LWS) {
|
|
8726
8815
|
return noop$LWS$1;
|
|
8727
8816
|
}
|
|
8728
8817
|
// istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
|
|
@@ -8753,7 +8842,7 @@
|
|
|
8753
8842
|
const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElement$LWS.prototype, 'textContent');
|
|
8754
8843
|
// This may not be implemented in all browsers.
|
|
8755
8844
|
// https://www.w3.org/TR/trusted-types/#enforcement-in-scripts
|
|
8756
|
-
if (!
|
|
8845
|
+
if (!descriptor$LWS) {
|
|
8757
8846
|
return noop$LWS$1;
|
|
8758
8847
|
}
|
|
8759
8848
|
// istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
|
|
@@ -11790,9 +11879,6 @@
|
|
|
11790
11879
|
return noop$LWS$1;
|
|
11791
11880
|
}
|
|
11792
11881
|
const distortionEntry$LWS = [originalFetchLater$LWS, function fetchLater$LWS(...args$LWS) {
|
|
11793
|
-
if (!isGaterEnabledFeature$LWS('changesSince.258')) {
|
|
11794
|
-
return ReflectApply$LWS$1(originalFetchLater$LWS, this, args$LWS);
|
|
11795
|
-
}
|
|
11796
11882
|
// Let the native method handle missing parameters error or null/undefined URL case.
|
|
11797
11883
|
let {
|
|
11798
11884
|
0: url$LWS
|
|
@@ -12179,14 +12265,8 @@
|
|
|
12179
12265
|
}
|
|
12180
12266
|
const childWindow$LWS = ReflectApply$LWS$1(originalWindowOpen$LWS, this, normalizedArgs$LWS);
|
|
12181
12267
|
// istanbul ignore next: behavior will not be tested in collection coverage
|
|
12182
|
-
if (!isGaterEnabledFeature$LWS('changesSince.262')) {
|
|
12183
|
-
|
|
12184
|
-
if (isSameOriginURL$LWS(resourceUrl$LWS)) {
|
|
12185
|
-
markForUnsafePropertyBlocking$LWS(childWindow$LWS);
|
|
12186
|
-
}
|
|
12187
|
-
} else {
|
|
12188
|
-
markForUnsafePropertyBlocking$LWS(childWindow$LWS);
|
|
12189
|
-
}
|
|
12268
|
+
if (!isGaterEnabledFeature$LWS('changesSince.262') && isSameOriginURL$LWS(resourceUrl$LWS)) {
|
|
12269
|
+
markForUnsafePropertyBlocking$LWS(childWindow$LWS);
|
|
12190
12270
|
}
|
|
12191
12271
|
// W-14218118
|
|
12192
12272
|
// If the target is '_self', '_parent', or '_top', only makes one request
|
|
@@ -12270,7 +12350,7 @@
|
|
|
12270
12350
|
// Defer transforming source text asynchronously.
|
|
12271
12351
|
sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
|
|
12272
12352
|
};
|
|
12273
|
-
} else
|
|
12353
|
+
} else {
|
|
12274
12354
|
throwIfUnsafeCallbackReference$LWS(callback$LWS);
|
|
12275
12355
|
}
|
|
12276
12356
|
}
|
|
@@ -12307,7 +12387,7 @@
|
|
|
12307
12387
|
// Defer transforming source text asynchronously.
|
|
12308
12388
|
sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
|
|
12309
12389
|
};
|
|
12310
|
-
} else
|
|
12390
|
+
} else {
|
|
12311
12391
|
throwIfUnsafeCallbackReference$LWS(callback$LWS);
|
|
12312
12392
|
}
|
|
12313
12393
|
}
|
|
@@ -12689,7 +12769,7 @@
|
|
|
12689
12769
|
const UIEventProtoBlockedProperties$LWS = ['rangeParent'];
|
|
12690
12770
|
const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
|
|
12691
12771
|
const XSLTProcessorProtoBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
|
|
12692
|
-
/*! version: 0.28.
|
|
12772
|
+
/*! version: 0.28.5 */
|
|
12693
12773
|
|
|
12694
12774
|
/*!
|
|
12695
12775
|
* Copyright (C) 2021 salesforce.com, inc.
|
|
@@ -12698,7 +12778,7 @@
|
|
|
12698
12778
|
function getPdpSchema$LWS() {
|
|
12699
12779
|
return pdpSchema$LWS;
|
|
12700
12780
|
}
|
|
12701
|
-
/*! version: 0.28.
|
|
12781
|
+
/*! version: 0.28.5 */
|
|
12702
12782
|
|
|
12703
12783
|
/*!
|
|
12704
12784
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -18090,7 +18170,7 @@
|
|
|
18090
18170
|
// tools from mistaking the regexp or the replacement string for an
|
|
18091
18171
|
// actual source mapping URL.
|
|
18092
18172
|
/\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
|
|
18093
|
-
sourceText$LWS = `\n//# LWS Version = "0.28.
|
|
18173
|
+
sourceText$LWS = `\n//# LWS Version = "0.28.5"\n${sourceText$LWS}`;
|
|
18094
18174
|
return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
|
|
18095
18175
|
// Append "'use strict'" to the extracted function body so it is
|
|
18096
18176
|
// evaluated in strict mode.
|
|
@@ -18770,12 +18850,35 @@
|
|
|
18770
18850
|
}
|
|
18771
18851
|
toSafeMap$LWS$1(new MapCtor$LWS$1());
|
|
18772
18852
|
toSafeSet$LWS(new SetCtor$LWS$1(['lightning/platformResourceLoader', 'lightning:platformResourceLoader', 'lightningmobileruntime/platformResourceLoader', 'lightningmobileruntime:platformResourceLoader']));
|
|
18773
|
-
/*! version: 0.28.
|
|
18853
|
+
/*! version: 0.28.5 */
|
|
18774
18854
|
|
|
18775
18855
|
// Expose evaluateInSandbox on the window global so the browser harness page
|
|
18776
18856
|
// (eval.html / component.html) can invoke it against source delivered by the
|
|
18777
18857
|
// CLI's local server. This is the minimal, non-Aura entry point for the LWS
|
|
18778
18858
|
// sandbox IIFE consumed by @locker/cli.
|
|
18779
18859
|
window.evaluateInSandbox = evaluateInSandbox$LWS;
|
|
18860
|
+
// Feature-gate registration for a run. The runner resolves the effective
|
|
18861
|
+
// gate list on the Node side (gates.mjs: the @locker/shared baseline
|
|
18862
|
+
// LWS_DEFAULT_GATER_FEATURES, plus --gates-on, minus --gates-off) and
|
|
18863
|
+
// publishes it on this window slot via addInitScript BEFORE the page
|
|
18864
|
+
// navigates. Reading and registering it
|
|
18865
|
+
// HERE, at IIFE init, is what makes the gates honored: this entry shares
|
|
18866
|
+
// the bundled @locker/shared module graph with @locker/sandbox, so
|
|
18867
|
+
// registerGaterEnabledFeatures writes into the very same gater Set that
|
|
18868
|
+
// the sandbox's internal isGaterEnabledFeature reads. Because the slot is
|
|
18869
|
+
// set before navigation and this code runs before any evaluateInSandbox
|
|
18870
|
+
// call, the Set is settled before the first SandboxRecord (which freezes
|
|
18871
|
+
// the gate reads for a key) is built.
|
|
18872
|
+
//
|
|
18873
|
+
// The slot name string is the wire contract with gates.mjs GATES_WINDOW_SLOT;
|
|
18874
|
+
// the two live in different bundles (this IIFE vs. the Node runner) and
|
|
18875
|
+
// cannot import a shared constant, so the literal is duplicated by design.
|
|
18876
|
+
// Bracket (string-key) access, not dot access: the slot name is a wire-
|
|
18877
|
+
// protocol key, and the bracket form keeps it out of no-underscore-dangle's
|
|
18878
|
+
// identifier check, matching how the sibling endowments slot is referenced.
|
|
18879
|
+
const gates = window['__lwsCLIGates'];
|
|
18880
|
+
if (Array.isArray(gates)) {
|
|
18881
|
+
registerGaterEnabledFeatures$LWS(gates);
|
|
18882
|
+
}
|
|
18780
18883
|
|
|
18781
18884
|
})(DOMPurify);
|
package/dist/purify.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;i||(i=function(e){return e}),a||(a=function(e){return e}),c||(c=function(e,t,n){return e.apply(t,n)}),s||(s=function(e,t){return new e(...t)});const u=R(Array.prototype.forEach),m=R(Array.prototype.lastIndexOf),p=R(Array.prototype.pop),f=R(Array.prototype.push),d=R(Array.prototype.splice),h=R(String.prototype.toLowerCase),g=R(String.prototype.toString),T=R(String.prototype.match),y=R(String.prototype.replace),E=R(String.prototype.indexOf),A=R(String.prototype.trim),_=R(Object.prototype.hasOwnProperty),S=R(RegExp.prototype.test),b=(N=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s(N,t)});var N;function R(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return c(e,t,o)}}function w(e,o){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h;t&&t(e,null);let i=o.length;for(;i--;){let t=o[i];if("string"==typeof t){const e=r(t);e!==t&&(n(o)||(o[i]=e),t=e)}e[t]=!0}return e}function O(e){for(let t=0;t<e.length;t++){_(e,t)||(e[t]=null)}return e}function D(t){const n=l(null);for(const[o,r]of e(t)){_(t,o)&&(Array.isArray(r)?n[o]=O(r):r&&"object"==typeof r&&r.constructor===Object?n[o]=D(r):n[o]=r)}return n}function v(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return R(n.get);if("function"==typeof n.value)return R(n.value)}e=o(e)}return function(){return null}}const L=i(["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"]),C=i(["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"]),x=i(["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"]),M=i(["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"]),k=i(["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"]),I=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),U=i(["#text"]),z=i(["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"]),P=i(["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"]),H=i(["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"]),F=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),B=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),W=a(/<%[\w\W]*|[\w\W]*%>/gm),G=a(/\$\{[\w\W]*/gm),Y=a(/^data-[\-\w.\u00B7-\uFFFF]+$/),j=a(/^aria-[\-\w]+$/),X=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q=a(/^(?:\w+script|data):/i),$=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),K=a(/^html$/i),V=a(/^[a-z][.\w]*(-[.\w]+)+$/i);var Z=Object.freeze({__proto__:null,ARIA_ATTR:j,ATTR_WHITESPACE:$,CUSTOM_ELEMENT:V,DATA_ATTR:Y,DOCTYPE_NAME:K,ERB_EXPR:W,IS_ALLOWED_URI:X,IS_SCRIPT_OR_DATA:q,MUSTACHE_EXPR:B,TMPLIT_EXPR:G});const J=1,Q=3,ee=7,te=8,ne=9,oe=function(){return"undefined"==typeof window?null:window};var re=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:oe();const o=e=>t(e);if(o.version="3.2.4",o.removed=[],!n||!n.document||n.document.nodeType!==ne||!n.Element)return o.isSupported=!1,o;let{document:r}=n;const a=r,c=a.currentScript,{DocumentFragment:s,HTMLTemplateElement:N,Node:R,Element:O,NodeFilter:B,NamedNodeMap:W=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:G,DOMParser:Y,trustedTypes:j}=n,q=O.prototype,$=v(q,"cloneNode"),V=v(q,"remove"),re=v(q,"nextSibling"),ie=v(q,"childNodes"),ae=v(q,"parentNode");if("function"==typeof N){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let le,ce="";const{implementation:se,createNodeIterator:ue,createDocumentFragment:me,getElementsByTagName:pe}=r,{importNode:fe}=a;let de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof e&&"function"==typeof ae&&se&&void 0!==se.createHTMLDocument;const{MUSTACHE_EXPR:he,ERB_EXPR:ge,TMPLIT_EXPR:Te,DATA_ATTR:ye,ARIA_ATTR:Ee,IS_SCRIPT_OR_DATA:Ae,ATTR_WHITESPACE:_e,CUSTOM_ELEMENT:Se}=Z;let{IS_ALLOWED_URI:be}=Z,Ne=null;const Re=w({},[...L,...C,...x,...k,...U]);let we=null;const Oe=w({},[...z,...P,...H,...F]);let De=Object.seal(l(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,Le=null,Ce=!0,xe=!0,Me=!1,ke=!0,Ie=!1,Ue=!0,ze=!1,Pe=!1,He=!1,Fe=!1,Be=!1,We=!1,Ge=!0,Ye=!1,je=!0,Xe=!1,qe={},$e=null;const Ke=w({},["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"]);let Ve=null;const Ze=w({},["audio","video","img","source","image","track"]);let Je=null;const Qe=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let ot=nt,rt=!1,it=null;const at=w({},[et,tt,nt],g);let lt=w({},["mi","mo","mn","ms","mtext"]),ct=w({},["annotation-xml"]);const st=w({},["title","style","font","a","script"]);let ut=null;const mt=["application/xhtml+xml","text/html"];let pt=null,ft=null;const dt=r.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ft||ft!==e){if(e&&"object"==typeof e||(e={}),e=D(e),ut=-1===mt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,pt="application/xhtml+xml"===ut?g:h,Ne=_(e,"ALLOWED_TAGS")?w({},e.ALLOWED_TAGS,pt):Re,we=_(e,"ALLOWED_ATTR")?w({},e.ALLOWED_ATTR,pt):Oe,it=_(e,"ALLOWED_NAMESPACES")?w({},e.ALLOWED_NAMESPACES,g):at,Je=_(e,"ADD_URI_SAFE_ATTR")?w(D(Qe),e.ADD_URI_SAFE_ATTR,pt):Qe,Ve=_(e,"ADD_DATA_URI_TAGS")?w(D(Ze),e.ADD_DATA_URI_TAGS,pt):Ze,$e=_(e,"FORBID_CONTENTS")?w({},e.FORBID_CONTENTS,pt):Ke,ve=_(e,"FORBID_TAGS")?w({},e.FORBID_TAGS,pt):{},Le=_(e,"FORBID_ATTR")?w({},e.FORBID_ATTR,pt):{},qe=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Ce=!1!==e.ALLOW_ARIA_ATTR,xe=!1!==e.ALLOW_DATA_ATTR,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ke=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ie=e.SAFE_FOR_TEMPLATES||!1,Ue=!1!==e.SAFE_FOR_XML,ze=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Be=e.RETURN_DOM_FRAGMENT||!1,We=e.RETURN_TRUSTED_TYPE||!1,He=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,Ye=e.SANITIZE_NAMED_PROPS||!1,je=!1!==e.KEEP_CONTENT,Xe=e.IN_PLACE||!1,be=e.ALLOWED_URI_REGEXP||X,ot=e.NAMESPACE||nt,lt=e.MATHML_TEXT_INTEGRATION_POINTS||lt,ct=e.HTML_INTEGRATION_POINTS||ct,De=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(De.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(De.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(De.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ie&&(xe=!1),Be&&(Fe=!0),qe&&(Ne=w({},U),we=[],!0===qe.html&&(w(Ne,L),w(we,z)),!0===qe.svg&&(w(Ne,C),w(we,P),w(we,F)),!0===qe.svgFilters&&(w(Ne,x),w(we,P),w(we,F)),!0===qe.mathMl&&(w(Ne,k),w(we,H),w(we,F))),e.ADD_TAGS&&(Ne===Re&&(Ne=D(Ne)),w(Ne,e.ADD_TAGS,pt)),e.ADD_ATTR&&(we===Oe&&(we=D(we)),w(we,e.ADD_ATTR,pt)),e.ADD_URI_SAFE_ATTR&&w(Je,e.ADD_URI_SAFE_ATTR,pt),e.FORBID_CONTENTS&&($e===Ke&&($e=D($e)),w($e,e.FORBID_CONTENTS,pt)),je&&(Ne["#text"]=!0),ze&&w(Ne,["html","head","body"]),Ne.table&&(w(Ne,["tbody"]),delete ve.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');le=e.TRUSTED_TYPES_POLICY,ce=le.createHTML("")}else void 0===le&&(le=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(j,c)),null!==le&&"string"==typeof ce&&(ce=le.createHTML(""));i&&i(e),ft=e}},Tt=w({},[...C,...x,...M]),yt=w({},[...k,...I]),Et=function(e){f(o.removed,{element:e});try{ae(e).removeChild(e)}catch(t){V(e)}},At=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Fe||Be)try{Et(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(He)e="<remove></remove>"+e;else{const t=T(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=le?le.createHTML(e):e;if(ot===nt)try{t=(new Y).parseFromString(o,ut)}catch(e){}if(!t||!t.documentElement){t=se.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?ce:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),ot===nt?pe.call(t,ze?"html":"body")[0]:ze?t.documentElement:i},St=function(e){return ue.call(e.ownerDocument||e,e,B.SHOW_ELEMENT|B.SHOW_COMMENT|B.SHOW_TEXT|B.SHOW_PROCESSING_INSTRUCTION|B.SHOW_CDATA_SECTION,null)},bt=function(e){return e instanceof G&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof W)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Nt=function(e){return"function"==typeof R&&e instanceof R};function Rt(e,t,n){u(e,(e=>{e.call(o,t,n,ft)}))}const wt=function(e){let t=null;if(Rt(de.beforeSanitizeElements,e,null),bt(e))return Et(e),!0;const n=pt(e.nodeName);if(Rt(de.uponSanitizeElement,e,{tagName:n,allowedTags:Ne}),e.hasChildNodes()&&!Nt(e.firstElementChild)&&S(/<[/\w]/g,e.innerHTML)&&S(/<[/\w]/g,e.textContent))return Et(e),!0;if(e.nodeType===ee)return Et(e),!0;if(Ue&&e.nodeType===te&&S(/<[/\w]/g,e.data))return Et(e),!0;if(!Ne[n]||ve[n]){if(!ve[n]&&Dt(n)){if(De.tagNameCheck instanceof RegExp&&S(De.tagNameCheck,n))return!1;if(De.tagNameCheck instanceof Function&&De.tagNameCheck(n))return!1}if(je&&!$e[n]){const t=ae(e)||e.parentNode,n=ie(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o){const r=$(n[o],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,re(e))}}}return Et(e),!0}return e instanceof O&&!function(e){let t=ae(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=h(e.tagName),o=h(t.tagName);return!!it[e.namespaceURI]&&(e.namespaceURI===tt?t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===o||lt[o]):Boolean(Tt[n]):e.namespaceURI===et?t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&ct[o]:Boolean(yt[n]):e.namespaceURI===nt?!(t.namespaceURI===tt&&!ct[o])&&!(t.namespaceURI===et&&!lt[o])&&!yt[n]&&(st[n]||!Tt[n]):!("application/xhtml+xml"!==ut||!it[e.namespaceURI]))}(e)?(Et(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!S(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ie&&e.nodeType===Q&&(t=e.textContent,u([he,ge,Te],(e=>{t=y(t,e," ")})),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),Rt(de.afterSanitizeElements,e,null),!1):(Et(e),!0)},Ot=function(e,t,n){if(Ge&&("id"===t||"name"===t)&&(n in r||n in dt))return!1;if(xe&&!Le[t]&&S(ye,t));else if(Ce&&S(Ee,t));else if(!we[t]||Le[t]){if(!(Dt(e)&&(De.tagNameCheck instanceof RegExp&&S(De.tagNameCheck,e)||De.tagNameCheck instanceof Function&&De.tagNameCheck(e))&&(De.attributeNameCheck instanceof RegExp&&S(De.attributeNameCheck,t)||De.attributeNameCheck instanceof Function&&De.attributeNameCheck(t))||"is"===t&&De.allowCustomizedBuiltInElements&&(De.tagNameCheck instanceof RegExp&&S(De.tagNameCheck,n)||De.tagNameCheck instanceof Function&&De.tagNameCheck(n))))return!1}else if(Je[t]);else if(S(be,y(n,_e,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E(n,"data:")||!Ve[e]){if(Me&&!S(Ae,y(n,_e,"")));else if(n)return!1}else;return!0},Dt=function(e){return"annotation-xml"!==e&&T(e,Se)},vt=function(e){Rt(de.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||bt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we,forceKeepAttr:void 0};let r=t.length;for(;r--;){const i=t[r],{name:a,namespaceURI:l,value:c}=i,s=pt(a);let m="value"===a?c:A(c);if(n.attrName=s,n.attrValue=m,n.keepAttr=!0,n.forceKeepAttr=void 0,Rt(de.uponSanitizeAttribute,e,n),m=n.attrValue,!Ye||"id"!==s&&"name"!==s||(At(a,e),m="user-content-"+m),Ue&&S(/((--!?|])>)|<\/(style|title)/i,m)){At(a,e);continue}if(n.forceKeepAttr)continue;if(At(a,e),!n.keepAttr)continue;if(!ke&&S(/\/>/i,m)){At(a,e);continue}Ie&&u([he,ge,Te],(e=>{m=y(m,e," ")}));const f=pt(e.nodeName);if(Ot(f,s,m)){if(le&&"object"==typeof j&&"function"==typeof j.getAttributeType)if(l);else switch(j.getAttributeType(f,s)){case"TrustedHTML":m=le.createHTML(m);break;case"TrustedScriptURL":m=le.createScriptURL(m)}try{l?e.setAttributeNS(l,a,m):e.setAttribute(a,m),bt(e)?Et(e):p(o.removed)}catch(e){}}}Rt(de.afterSanitizeAttributes,e,null)},Lt=function e(t){let n=null;const o=St(t);for(Rt(de.beforeSanitizeShadowDOM,t,null);n=o.nextNode();)Rt(de.uponSanitizeShadowNode,n,null),wt(n),vt(n),n.content instanceof s&&e(n.content);Rt(de.afterSanitizeShadowDOM,t,null)};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,i=null,l=null;if(rt=!e,rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Nt(e)){if("function"!=typeof e.toString)throw b("toString is not a function");if("string"!=typeof(e=e.toString()))throw b("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Pe||gt(t),o.removed=[],"string"==typeof e&&(Xe=!1),Xe){if(e.nodeName){const t=pt(e.nodeName);if(!Ne[t]||ve[t])throw b("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof R)n=_t("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===J&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!Fe&&!Ie&&!ze&&-1===e.indexOf("<"))return le&&We?le.createHTML(e):e;if(n=_t(e),!n)return Fe?null:We?ce:""}n&&He&&Et(n.firstChild);const c=St(Xe?e:n);for(;i=c.nextNode();)wt(i),vt(i),i.content instanceof s&&Lt(i.content);if(Xe)return e;if(Fe){if(Be)for(l=me.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(we.shadowroot||we.shadowrootmode)&&(l=fe.call(a,l,!0)),l}let m=ze?n.outerHTML:n.innerHTML;return ze&&Ne["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&S(K,n.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+m),Ie&&u([he,ge,Te],(e=>{m=y(m,e," ")})),le&&We?le.createHTML(m):m},o.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Pe=!0},o.clearConfig=function(){ft=null,Pe=!1},o.isValidAttribute=function(e,t,n){ft||gt({});const o=pt(e),r=pt(t);return Ot(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&f(de[e],t)},o.removeHook=function(e,t){if(void 0!==t){const n=m(de[e],t);return-1===n?void 0:d(de[e],n,1)[0]}return p(de[e])},o.removeHooks=function(e){de[e]=[]},o.removeAllHooks=function(){de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();return re}));
|
|
1
|
+
/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(e){s=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw r}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const n=Object.entries,o=Object.setPrototypeOf,r=Object.isFrozen,i=Object.getPrototypeOf,a=Object.getOwnPropertyDescriptor;let l=Object.freeze,c=Object.seal,s=Object.create,u="undefined"!=typeof Reflect&&Reflect,f=u.apply,p=u.construct;l||(l=function(e){return e}),c||(c=function(e){return e}),f||(f=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),p||(p=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const m=L(Array.prototype.forEach),d=L(Array.prototype.lastIndexOf),h=L(Array.prototype.pop),g=L(Array.prototype.push),y=L(Array.prototype.splice),T=Array.isArray,b=L(String.prototype.toLowerCase),S=L(String.prototype.toString),E=L(String.prototype.match),A=L(String.prototype.replace),N=L(String.prototype.indexOf),_=L(String.prototype.trim),w=L(Number.prototype.toString),O=L(Boolean.prototype.toString),v="undefined"==typeof BigInt?null:L(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:L(Symbol.prototype.toString),R=L(Object.prototype.hasOwnProperty),C=L(Object.prototype.toString),I=L(RegExp.prototype.test),k=(x=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p(x,t)});var x;function L(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return f(e,t,o)}}function M(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b;if(o&&o(e,null),!T(t))return e;let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(r(t)||(t[i]=e),o=e)}e[o]=!0}return e}function z(e){for(let t=0;t<e.length;t++){R(e,t)||(e[t]=null)}return e}function P(e){const o=s(null);for(const i of n(e)){var r=t(i,2);const n=r[0],a=r[1];R(e,n)&&(T(a)?o[n]=z(a):a&&"object"==typeof a&&a.constructor===Object?o[n]=P(a):o[n]=a)}return o}function U(e,t){for(;null!==e;){const n=a(e,t);if(n){if(n.get)return L(n.get);if("function"==typeof n.value)return L(n.value)}e=i(e)}return function(){return null}}const F=l(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),H=l(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),j=l(["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"]),B=l(["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"]),G=l(["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"]),W=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y=l(["#text"]),q=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),X=l(["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","mask-type","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"]),$=l(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),K=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),V=c(/{{[\w\W]*|^[\w\W]*}}/g),Z=c(/<%[\w\W]*|^[\w\W]*%>/g),J=c(/\${[\w\W]*/g),Q=c(/^data-[\-\w.\u00B7-\uFFFF]+$/),ee=c(/^aria-[\-\w]+$/),te=c(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ne=c(/^(?:\w+script|data):/i),oe=c(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),re=c(/^html$/i),ie=c(/^[a-z][.\w]*(-[.\w]+)+$/i),ae=c(/<[/\w!]/g),le=c(/<[/\w]/g),ce=c(/<\/no(script|embed|frames)/i),se=c(/\/>/i),ue=1,fe=3,pe=7,me=8,de=9,he=11,ge=function(){return"undefined"==typeof window?null:window},ye=function(e,t,n,o){return R(e,t)&&T(e[t])?M(o.base?P(o.base):{},e[t],o.transform):n};var Te=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ge();const o=t=>e(t);if(o.version="3.4.11",o.removed=[],!t||!t.document||t.document.nodeType!==de||!t.Element)return o.isSupported=!1,o;let r=t.document;const i=r,a=i.currentScript;t.DocumentFragment;const u=t.HTMLTemplateElement,f=t.Node,p=t.Element,x=t.NodeFilter,L=t.NamedNodeMap;void 0===L&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const z=t.DOMParser,Te=t.trustedTypes,be=p.prototype,Se=U(be,"cloneNode"),Ee=U(be,"remove"),Ae=U(be,"nextSibling"),Ne=U(be,"childNodes"),_e=U(be,"parentNode"),we=U(be,"shadowRoot"),Oe=U(be,"attributes"),ve=f&&f.prototype?U(f.prototype,"nodeType"):null,De=f&&f.prototype?U(f.prototype,"nodeName"):null;if("function"==typeof u){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let Re,Ce,Ie="",ke=!1,xe=0;const Le=function(){if(xe>0)throw k('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Me=function(e){Le(),xe++;try{return Re.createHTML(e)}finally{xe--}},ze=function(){return ke||(Ce=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(Te,a),ke=!0),Ce},Pe=r,Ue=Pe.implementation,Fe=Pe.createNodeIterator,He=Pe.createDocumentFragment,je=Pe.getElementsByTagName,Be=i.importNode;let Ge={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof n&&"function"==typeof _e&&Ue&&void 0!==Ue.createHTMLDocument;const We=V,Ye=Z,qe=J,Xe=Q,$e=ee,Ke=ne,Ve=oe,Ze=ie;let Je=te,Qe=null;const et=M({},[...F,...H,...j,...G,...Y]);let tt=null;const nt=M({},[...q,...X,...$,...K]);let ot=Object.seal(s(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),rt=null,it=null;const at=Object.seal(s(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let lt=!0,ct=!0,st=!1,ut=!0,ft=!1,pt=!0,mt=!1,dt=!1,ht=null,gt=null,yt=!1,Tt=!1,bt=!1,St=!1,Et=!0,At=!1;const Nt="user-content-";let _t=!0,wt=!1,Ot={},vt=null;const Dt=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Rt=null;const Ct=M({},["audio","video","img","source","image","track"]);let It=null;const kt=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xt="http://www.w3.org/1998/Math/MathML",Lt="http://www.w3.org/2000/svg",Mt="http://www.w3.org/1999/xhtml";let zt=Mt,Pt=!1,Ut=null;const Ft=M({},[xt,Lt,Mt],S),Ht=l(["mi","mo","mn","ms","mtext"]);let jt=M({},Ht);const Bt=l(["annotation-xml"]);let Gt=M({},Bt);const Wt=M({},["title","style","font","a","script"]);let Yt=null;const qt=["application/xhtml+xml","text/html"];let Xt=null,$t=null;const Kt=r.createElement("form"),Vt=function(e){return e instanceof RegExp||e instanceof Function},Zt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if($t&&$t===e)return;e&&"object"==typeof e||(e={}),e=P(e),Yt=-1===qt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Xt="application/xhtml+xml"===Yt?S:b,Qe=ye(e,"ALLOWED_TAGS",et,{transform:Xt}),tt=ye(e,"ALLOWED_ATTR",nt,{transform:Xt}),Ut=ye(e,"ALLOWED_NAMESPACES",Ft,{transform:S}),It=ye(e,"ADD_URI_SAFE_ATTR",kt,{transform:Xt,base:kt}),Rt=ye(e,"ADD_DATA_URI_TAGS",Ct,{transform:Xt,base:Ct}),vt=ye(e,"FORBID_CONTENTS",Dt,{transform:Xt}),rt=ye(e,"FORBID_TAGS",P({}),{transform:Xt}),it=ye(e,"FORBID_ATTR",P({}),{transform:Xt}),Ot=!!R(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?P(e.USE_PROFILES):e.USE_PROFILES),lt=!1!==e.ALLOW_ARIA_ATTR,ct=!1!==e.ALLOW_DATA_ATTR,st=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ut=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ft=e.SAFE_FOR_TEMPLATES||!1,pt=!1!==e.SAFE_FOR_XML,mt=e.WHOLE_DOCUMENT||!1,Tt=e.RETURN_DOM||!1,bt=e.RETURN_DOM_FRAGMENT||!1,St=e.RETURN_TRUSTED_TYPE||!1,yt=e.FORCE_BODY||!1,Et=!1!==e.SANITIZE_DOM,At=e.SANITIZE_NAMED_PROPS||!1,_t=!1!==e.KEEP_CONTENT,wt=e.IN_PLACE||!1,Je=function(e){try{return I(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:te,zt="string"==typeof e.NAMESPACE?e.NAMESPACE:Mt,jt=R(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?P(e.MATHML_TEXT_INTEGRATION_POINTS):M({},Ht),Gt=R(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?P(e.HTML_INTEGRATION_POINTS):M({},Bt);const t=R(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?P(e.CUSTOM_ELEMENT_HANDLING):s(null);if(ot=s(null),R(t,"tagNameCheck")&&Vt(t.tagNameCheck)&&(ot.tagNameCheck=t.tagNameCheck),R(t,"attributeNameCheck")&&Vt(t.attributeNameCheck)&&(ot.attributeNameCheck=t.attributeNameCheck),R(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(ot.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),c(ot),ft&&(ct=!1),bt&&(Tt=!0),Ot&&(Qe=M({},Y),tt=s(null),!0===Ot.html&&(M(Qe,F),M(tt,q)),!0===Ot.svg&&(M(Qe,H),M(tt,X),M(tt,K)),!0===Ot.svgFilters&&(M(Qe,j),M(tt,X),M(tt,K)),!0===Ot.mathMl&&(M(Qe,G),M(tt,$),M(tt,K))),at.tagCheck=null,at.attributeCheck=null,R(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?at.tagCheck=e.ADD_TAGS:T(e.ADD_TAGS)&&(Qe===et&&(Qe=P(Qe)),M(Qe,e.ADD_TAGS,Xt))),R(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?at.attributeCheck=e.ADD_ATTR:T(e.ADD_ATTR)&&(tt===nt&&(tt=P(tt)),M(tt,e.ADD_ATTR,Xt))),R(e,"ADD_URI_SAFE_ATTR")&&T(e.ADD_URI_SAFE_ATTR)&&M(It,e.ADD_URI_SAFE_ATTR,Xt),R(e,"FORBID_CONTENTS")&&T(e.FORBID_CONTENTS)&&(vt===Dt&&(vt=P(vt)),M(vt,e.FORBID_CONTENTS,Xt)),R(e,"ADD_FORBID_CONTENTS")&&T(e.ADD_FORBID_CONTENTS)&&(vt===Dt&&(vt=P(vt)),M(vt,e.ADD_FORBID_CONTENTS,Xt)),_t&&(Qe["#text"]=!0),mt&&M(Qe,["html","head","body"]),Qe.table&&(M(Qe,["tbody"]),delete rt.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=Re;Re=e.TRUSTED_TYPES_POLICY;try{Ie=Me("")}catch(e){throw Re=t,e}}else null===e.TRUSTED_TYPES_POLICY?(Re=void 0,Ie=""):(void 0===Re&&(Re=ze()),Re&&"string"==typeof Ie&&(Ie=Me("")));l&&l(e),$t=e},Jt=M({},[...H,...j,...B]),Qt=M({},[...G,...W]),en=function(e){let t=_e(e);t&&t.tagName||(t={namespaceURI:zt,tagName:"template"});const n=b(e.tagName),o=b(t.tagName);return!!Ut[e.namespaceURI]&&(e.namespaceURI===Lt?function(e,t,n){return t.namespaceURI===Mt?"svg"===e:t.namespaceURI===xt?"svg"===e&&("annotation-xml"===n||jt[n]):Boolean(Jt[e])}(n,t,o):e.namespaceURI===xt?function(e,t,n){return t.namespaceURI===Mt?"math"===e:t.namespaceURI===Lt?"math"===e&&Gt[n]:Boolean(Qt[e])}(n,t,o):e.namespaceURI===Mt?function(e,t,n){return!(t.namespaceURI===Lt&&!Gt[n])&&!(t.namespaceURI===xt&&!jt[n])&&!Qt[e]&&(Wt[e]||!Jt[e])}(n,t,o):!("application/xhtml+xml"!==Yt||!Ut[e.namespaceURI]))},tn=function(e){g(o.removed,{element:e});try{_e(e).removeChild(e)}catch(t){if(Ee(e),!_e(e))throw k("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},nn=function(e){const t=Ne(e);if(t){const e=[];m(t,t=>{g(e,t)}),m(e,e=>{try{Ee(e)}catch(e){}})}const n=Oe(e);if(n)for(let t=n.length-1;t>=0;--t){const o=n[t],r=o&&o.name;if("string"==typeof r)try{e.removeAttribute(r)}catch(e){}}},on=function(e,t){try{g(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){g(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Tt||bt)try{tn(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},rn=function(e){const t=Oe(e);if(t)for(let n=t.length-1;n>=0;--n){const o=t[n],r=o&&o.name;if("string"==typeof r&&!tt[Xt(r)])try{e.removeAttribute(r)}catch(e){}}},an=function(e){let t=null,n=null;if(yt)e="<remove></remove>"+e;else{const t=E(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Yt&&zt===Mt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=Re?Me(e):e;if(zt===Mt)try{t=(new z).parseFromString(o,Yt)}catch(e){}if(!t||!t.documentElement){t=Ue.createDocument(zt,"template",null);try{t.documentElement.innerHTML=Pt?Ie:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),zt===Mt?je.call(t,mt?"html":"body")[0]:mt?t.documentElement:i},ln=function(e){return Fe.call(e.ownerDocument||e,e,x.SHOW_ELEMENT|x.SHOW_COMMENT|x.SHOW_TEXT|x.SHOW_PROCESSING_INSTRUCTION|x.SHOW_CDATA_SECTION,null)},cn=function(e){return e=A(e,We," "),e=A(e,Ye," "),e=A(e,qe," ")},sn=function(e){var t;e.normalize();const n=Fe.call(e.ownerDocument||e,e,x.SHOW_TEXT|x.SHOW_COMMENT|x.SHOW_CDATA_SECTION|x.SHOW_PROCESSING_INSTRUCTION,null);let o=n.nextNode();for(;o;)o.data=cn(o.data),o=n.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&m(r,e=>{fn(e.content)&&sn(e.content)})},un=function(e){const t=De?De(e):null;return"string"==typeof t&&("form"===Xt(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Oe(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==ve(e)||e.childNodes!==Ne(e)))},fn=function(e){if(!ve||"object"!=typeof e||null===e)return!1;try{return ve(e)===he}catch(e){return!1}},pn=function(e){if(!ve||"object"!=typeof e||null===e)return!1;try{return"number"==typeof ve(e)}catch(e){return!1}};function mn(e,t,n){0!==e.length&&m(e,e=>{e.call(o,t,n,$t)})}const dn=function(e){if(mn(Ge.beforeSanitizeElements,e,null),un(e))return tn(e),!0;const t=Xt(De?De(e):e.nodeName);if(mn(Ge.uponSanitizeElement,e,{tagName:t,allowedTags:Qe}),function(e,t){return!!(pt&&e.hasChildNodes()&&!pn(e.firstElementChild)&&I(ae,e.textContent)&&I(ae,e.innerHTML))||!(!pt||e.namespaceURI!==Mt||"style"!==t||!pn(e.firstElementChild))||e.nodeType===pe||!(!pt||e.nodeType!==me||!I(le,e.data))}(e,t))return tn(e),!0;if(rt[t]||!(at.tagCheck instanceof Function&&at.tagCheck(t))&&!Qe[t])return function(e,t){if(!rt[t]&&yn(t)){if(ot.tagNameCheck instanceof RegExp&&I(ot.tagNameCheck,t))return!1;if(ot.tagNameCheck instanceof Function&&ot.tagNameCheck(t))return!1}if(_t&&!vt[t]){const t=_e(e),n=Ne(e);if(n&&t)for(let o=n.length-1;o>=0;--o){const r=wt?n[o]:Se(n[o],!0);t.insertBefore(r,Ae(e))}}return tn(e),!0}(e,t);if((ve?ve(e):e.nodeType)===ue&&!en(e))return tn(e),!0;if(("noscript"===t||"noembed"===t||"noframes"===t)&&I(ce,e.innerHTML))return tn(e),!0;if(ft&&e.nodeType===fe){const t=cn(e.textContent);e.textContent!==t&&(g(o.removed,{element:e.cloneNode()}),e.textContent=t)}return mn(Ge.afterSanitizeElements,e,null),!1},hn=function(e,t,n){if(it[t])return!1;if(Et&&("id"===t||"name"===t)&&(n in r||n in Kt))return!1;const o=tt[t]||at.attributeCheck instanceof Function&&at.attributeCheck(t,e);if(ct&&I(Xe,t));else if(lt&&I($e,t));else if(o)if(It[t]);else if(I(Je,A(n,Ve,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==N(n,"data:")||!Rt[e]){if(st&&!I(Ke,A(n,Ve,"")));else if(n)return!1}else;else if(!(yn(e)&&(ot.tagNameCheck instanceof RegExp&&I(ot.tagNameCheck,e)||ot.tagNameCheck instanceof Function&&ot.tagNameCheck(e))&&(ot.attributeNameCheck instanceof RegExp&&I(ot.attributeNameCheck,t)||ot.attributeNameCheck instanceof Function&&ot.attributeNameCheck(t,e))||"is"===t&&ot.allowCustomizedBuiltInElements&&(ot.tagNameCheck instanceof RegExp&&I(ot.tagNameCheck,n)||ot.tagNameCheck instanceof Function&&ot.tagNameCheck(n))))return!1;return!0},gn=M({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),yn=function(e){return!gn[b(e)]&&I(Ze,e)},Tn=function(e,t,n,o){if(Re&&"object"==typeof Te&&"function"==typeof Te.getAttributeType&&!n)switch(Te.getAttributeType(e,t)){case"TrustedHTML":return Me(o);case"TrustedScriptURL":return function(e){Le(),xe++;try{return Re.createScriptURL(e)}finally{xe--}}(o)}return o},bn=function(e,t,n,r){try{n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),un(e)?tn(e):h(o.removed)}catch(n){on(t,e)}},Sn=function(e){mn(Ge.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||un(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:tt,forceKeepAttr:void 0};let o=t.length;const r=Xt(e.nodeName);for(;o--;){const i=t[o],a=i.name,l=i.namespaceURI,c=i.value,s=Xt(a),u=c;let f="value"===a?u:_(u);n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,mn(Ge.uponSanitizeAttribute,e,n),f=n.attrValue,!At||"id"!==s&&"name"!==s||0===N(f,Nt)||(on(a,e),f=Nt+f),pt&&I(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)?on(a,e):"attributename"===s&&E(f,"href")?on(a,e):n.forceKeepAttr||(n.keepAttr&&(ut||!I(se,f))?(ft&&(f=cn(f)),hn(r,s,f)?(f=Tn(r,s,l,f),f!==u&&bn(e,a,l,f)):on(a,e)):on(a,e))}mn(Ge.afterSanitizeAttributes,e,null)},En=function(e){let t=null;const n=ln(e);for(mn(Ge.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){mn(Ge.uponSanitizeShadowNode,t,null),dn(t),Sn(t),fn(t.content)&&En(t.content);if((ve?ve(t):t.nodeType)===ue){const e=we(t);fn(e)&&(An(e),En(e))}}mn(Ge.afterSanitizeShadowDOM,e,null)},An=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){En(e.shadow);continue}const n=e.node,o=(ve?ve(n):n.nodeType)===ue,r=Ne(n);if(r)for(let e=r.length-1;e>=0;--e)t.push({node:r[e],shadow:null});if(o){const e=De?De(n):null;if("string"==typeof e&&"template"===Xt(e)){const e=n.content;fn(e)&&t.push({node:e,shadow:null})}}if(o){const e=we(n);fn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,a=null,l=null;if(Pt=!e,Pt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!pn(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return w(e);case"boolean":return O(e);case"bigint":return v?v(e):"0";case"symbol":return D?D(e):"Symbol()";case"undefined":default:return C(e);case"function":case"object":{if(null===e)return C(e);const t=e,n=U(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:C(e)}return C(e)}}}(e)))throw k("dirty is not a string, aborting");if(!o.isSupported)return e;dt?(Qe=ht,tt=gt):Zt(t),(Ge.uponSanitizeElement.length>0||Ge.uponSanitizeAttribute.length>0)&&(Qe=P(Qe)),Ge.uponSanitizeAttribute.length>0&&(tt=P(tt)),o.removed=[];const c=wt&&"string"!=typeof e&&pn(e);if(c){const t=De?De(e):e.nodeName;if("string"==typeof t){const e=Xt(t);if(!Qe[e]||rt[e])throw k("root node is forbidden and cannot be sanitized in-place")}if(un(e))throw k("root node is clobbered and cannot be sanitized in-place");try{An(e)}catch(t){throw nn(e),t}}else if(pn(e))n=an("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===ue&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r),An(r);else{if(!Tt&&!ft&&!mt&&-1===e.indexOf("<"))return Re&&St?Me(e):e;if(n=an(e),!n)return Tt?null:St?Ie:""}n&&yt&&tn(n.firstChild);const s=ln(c?e:n);try{for(;a=s.nextNode();)dn(a),Sn(a),fn(a.content)&&En(a.content)}catch(t){throw c&&nn(e),t}if(c)return m(o.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();(ve?ve(e):e.nodeType)===ue&&rn(e);const n=Ne(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}}(e.element)}),ft&&sn(e),e;if(Tt){if(ft&&sn(n),bt)for(l=He.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(tt.shadowroot||tt.shadowrootmode)&&(l=Be.call(i,l,!0)),l}let u=mt?n.outerHTML:n.innerHTML;return mt&&Qe["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&I(re,n.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+u),ft&&(u=cn(u)),Re&&St?Me(u):u},o.setConfig=function(){Zt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),dt=!0,ht=Qe,gt=tt},o.clearConfig=function(){$t=null,dt=!1,ht=null,gt=null,Re=Ce,Ie=""},o.isValidAttribute=function(e,t,n){$t||Zt({});const o=Xt(e),r=Xt(t);return hn(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&R(Ge,e)&&g(Ge[e],t)},o.removeHook=function(e,t){if(R(Ge,e)){if(void 0!==t){const n=d(Ge[e],t);return-1===n?void 0:y(Ge[e],n,1)[0]}return h(Ge[e])}},o.removeHooks=function(e){R(Ge,e)&&(Ge[e]=[])},o.removeAllHooks=function(){Ge={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();return Te});
|
|
3
3
|
//# sourceMappingURL=purify.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locker/cli",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.5",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"author": "Salesforce UI Security Team",
|
|
6
6
|
"description": "Lightning Web Security CLI",
|
|
@@ -26,20 +26,22 @@
|
|
|
26
26
|
"test:integration": "jest --config jest.config.integration.cjs"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@locker/
|
|
29
|
+
"@babel/parser": "7.28.0",
|
|
30
|
+
"@locker/rollup-plugin": "0.28.5",
|
|
31
|
+
"@locker/sandbox": "0.28.5",
|
|
32
|
+
"@locker/shared": "0.28.5",
|
|
31
33
|
"@lwc/engine-dom": "8.21.1",
|
|
32
34
|
"@lwc/rollup-plugin": "8.21.1",
|
|
33
35
|
"@rollup/plugin-commonjs": "21.1.0",
|
|
34
36
|
"@rollup/plugin-node-resolve": "15.1.0",
|
|
35
37
|
"@rollup/plugin-replace": "5.0.5",
|
|
36
38
|
"chokidar": "3.5.3",
|
|
37
|
-
"dompurify": "3.
|
|
39
|
+
"dompurify": "3.4.11",
|
|
38
40
|
"lwc": "8.21.1",
|
|
39
41
|
"playwright": "1.49.1",
|
|
40
42
|
"rollup": "2.79.1",
|
|
41
43
|
"rollup-plugin-ts": "3.4.5",
|
|
42
44
|
"yargs": "17.7.2"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "16f7eebf99a3b13eeb1831518cbb1de79a7aff15"
|
|
45
47
|
}
|
package/src/compile-lwc.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import path from 'node:path';
|
|
|
5
5
|
|
|
6
6
|
import { rollup } from 'rollup';
|
|
7
7
|
|
|
8
|
+
import { createWireMockPlugin } from './wire-mock.mjs';
|
|
9
|
+
|
|
8
10
|
const require = createRequire(import.meta.url);
|
|
9
11
|
const lockerRollupPlugin = require('@locker/rollup-plugin');
|
|
10
12
|
const lwcRollupPlugin = require('@lwc/rollup-plugin');
|
|
@@ -54,6 +56,15 @@ export async function compileComponent({
|
|
|
54
56
|
namespace = DEFAULT_NAMESPACE,
|
|
55
57
|
sandboxKey = 'cli',
|
|
56
58
|
lwcModules = [],
|
|
59
|
+
// Wire auto-mocking (D16). `wireMode` is undefined (off), 'success', or
|
|
60
|
+
// 'error'; `wireMockOverrides` is the Map from loadWireMockOverrides
|
|
61
|
+
// (adapter -> explicit shape); `onWireMock` receives each
|
|
62
|
+
// `[wire mock] ...` marker line so the runner can print it to stderr.
|
|
63
|
+
// When wireMode is undefined the plugin is not added and compilation
|
|
64
|
+
// is byte-for-byte what it was before D16.
|
|
65
|
+
wireMode,
|
|
66
|
+
wireMockOverrides = new Map(),
|
|
67
|
+
onWireMock = () => {},
|
|
57
68
|
}) {
|
|
58
69
|
const { dirName, jsFile } = await validateComponentDir(directory);
|
|
59
70
|
const derivedTag = name ?? deriveTagName(dirName);
|
|
@@ -96,9 +107,35 @@ export async function compileComponent({
|
|
|
96
107
|
}));
|
|
97
108
|
const moduleRecords = [...explicitModules, { dir: modulesRoot }];
|
|
98
109
|
|
|
110
|
+
// Wire auto-mocking (D16). When enabled, a virtual-module plugin
|
|
111
|
+
// supplies synthetic source for the wire specifiers the component
|
|
112
|
+
// imports (lightning/uiRecordApi, @salesforce/schema/*,
|
|
113
|
+
// @salesforce/apex/*) so the component renders locally with fake data
|
|
114
|
+
// instead of dying at runtime on an unresolved platform module. The
|
|
115
|
+
// plugin needs the component's OWN source for Tier A schema-field
|
|
116
|
+
// collection and Tier B usage inference, so read the entry component
|
|
117
|
+
// file here. It MUST sit before nodeResolve in the plugins array (see
|
|
118
|
+
// below) so it claims the wire specifiers before node-resolve can
|
|
119
|
+
// externalize them.
|
|
120
|
+
const wireMockPlugins = [];
|
|
121
|
+
if (wireMode !== undefined) {
|
|
122
|
+
const componentSource = await fs.readFile(jsFile, 'utf8');
|
|
123
|
+
wireMockPlugins.push(
|
|
124
|
+
createWireMockPlugin({
|
|
125
|
+
mode: wireMode,
|
|
126
|
+
overrides: wireMockOverrides,
|
|
127
|
+
componentSource,
|
|
128
|
+
report: onWireMock,
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
99
133
|
const bundle = await rollup({
|
|
100
134
|
input: entryFile,
|
|
101
135
|
plugins: [
|
|
136
|
+
// Wire-mock virtual modules first: its resolveId must claim the
|
|
137
|
+
// wire specifiers before nodeResolve can mark them external.
|
|
138
|
+
...wireMockPlugins,
|
|
102
139
|
nodeResolve({ preferBuiltins: true }),
|
|
103
140
|
// Plugin order matters: LWC compiler MUST run before the LWS
|
|
104
141
|
// compiler. Reversing the order breaks LWC component-file
|