@lwrjs/client-modules 0.17.2-alpha.3 → 0.17.2-alpha.31

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.
@@ -414,6 +414,7 @@ function maskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
414
414
  },
415
415
  construct(_target$LWS, args$LWS, newTarget$LWS) {
416
416
  lastProxyTrapCalled$LWS = 2 /* ProxyHandlerTraps.Construct */;
417
+ // istanbul ignore else: it is unnecessary to cover the else path here
417
418
  if (newTarget$LWS === proxy$LWS || newTarget$LWS === maskFunc$LWS) {
418
419
  newTarget$LWS = func$LWS;
419
420
  }
@@ -1356,17 +1357,21 @@ function isGaterEnabledFeature$LWS(featureName$LWS) {
1356
1357
  }
1357
1358
  const ENABLE_MAX_PERF_MODE_GATE$LWS = 'enableMaxPerfMode';
1358
1359
  const ENABLE_SANDBOXED_SAMEORIGIN_IFRAME_GATE$LWS = 'enableSandboxedSameOriginIframe';
1359
- const omniStudioPredicates$LWS = [key$LWS => key$LWS === 'omnistudio', key$LWS => ReflectApply$LWS$1(StringProtoStartsWith$LWS, key$LWS, ['devopsimpkg'])];
1360
+ const omnistudioPredicates$LWS = [key$LWS => key$LWS === 'omnistudio', key$LWS => ReflectApply$LWS$1(StringProtoStartsWith$LWS, key$LWS, ['devopsimpkg']), key$LWS => ReflectApply$LWS$1(RegExpProtoTest$LWS$1, /^devops\d{3}gs0/, [key$LWS]) // Matches devops001gs0, devops002gs0, etc
1361
+ ];
1362
+ const consolidatedGaterEnabledOverridePredicates$LWS = [...omnistudioPredicates$LWS
1363
+ // Allows for aggregating multiple lists
1364
+ ];
1360
1365
  const gaterEnabledOverrideRegistry$LWS = {
1361
1366
  __proto__: null,
1362
1367
  $lwsBogusFeatureDisabledTrue: [() => true],
1363
1368
  $lwsBogusFeatureDisabledFalse: [() => false],
1364
- [ENABLE_MAX_PERF_MODE_GATE$LWS]: omniStudioPredicates$LWS,
1369
+ [ENABLE_MAX_PERF_MODE_GATE$LWS]: consolidatedGaterEnabledOverridePredicates$LWS,
1365
1370
  // Temporarily disable this feature gate
1366
1371
  // Ref:
1367
1372
  // "W-17049687: [LWS] Temporarily disable same origin iframe sandbox security fix for OS and devopsimpkg"
1368
1373
  // https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE000023unysYAA/view
1369
- [ENABLE_SANDBOXED_SAMEORIGIN_IFRAME_GATE$LWS]: omniStudioPredicates$LWS
1374
+ [ENABLE_SANDBOXED_SAMEORIGIN_IFRAME_GATE$LWS]: consolidatedGaterEnabledOverridePredicates$LWS
1370
1375
  };
1371
1376
  function isAllowedToOverrideGaterEnabledFeature$LWS(sandboxKey$LWS, featureName$LWS) {
1372
1377
  var _gaterEnabledOverride$LWS;
@@ -1376,6 +1381,10 @@ function isAllowedToOverrideGaterEnabledFeature$LWS(sandboxKey$LWS, featureName$
1376
1381
  function isNotAllowedToOverrideGaterEnabledFeature$LWS(...args$LWS) {
1377
1382
  return !isAllowedToOverrideGaterEnabledFeature$LWS(...args$LWS);
1378
1383
  }
1384
+ const keepAlivePredicates$LWS = [...omnistudioPredicates$LWS];
1385
+ function isAllowedToKeepAlive$LWS(sandboxKey$LWS) {
1386
+ return keepAlivePredicates$LWS.some(predicate$LWS => predicate$LWS(sandboxKey$LWS));
1387
+ }
1379
1388
  const trackedLiveTargets$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1());
1380
1389
  function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None */) {
1381
1390
  if (targetTraits$LWS & 1 /* TargetTraits.IsArray */ || targetTraits$LWS & 2 /* TargetTraits.IsArrayBufferView */ || targetTraits$LWS & 64 /* TargetTraits.Revoked */ || target$LWS === null || target$LWS === undefined || target$LWS === ObjectProto$LWS$1 || target$LWS === RegExpProto$LWS$1) {
@@ -1415,6 +1424,7 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
1415
1424
  }
1416
1425
  // eslint-disable-next-line no-empty
1417
1426
  } catch (_unused19$LWS) {}
1427
+ // istanbul ignore else: it is unnecessary to cover the else path here
1418
1428
  if (targetTraits$LWS === 0 /* TargetTraits.None */) {
1419
1429
  try {
1420
1430
  if (ArrayIsArray$LWS$1(target$LWS)) {
@@ -1504,7 +1514,7 @@ const {
1504
1514
  } = PromiseCtor$LWS.prototype;
1505
1515
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1506
1516
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1507
- /*! version: 0.23.6 */
1517
+ /*! version: 0.24.6 */
1508
1518
 
1509
1519
  /*!
1510
1520
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2276,7 +2286,7 @@ const {
2276
2286
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
2277
2287
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
2278
2288
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
2279
- /*! version: 0.23.6 */
2289
+ /*! version: 0.24.6 */
2280
2290
 
2281
2291
  /*!
2282
2292
  * Copyright (C) 2019 salesforce.com, inc.
@@ -2301,6 +2311,22 @@ const TRUSTED_DOMAINS_REG_EXP$LWS = /\.(force|salesforce|visualforce|documentfor
2301
2311
  const URL_SCHEMES_LIST$LWS = toSafeArray$LWS$1(['about:', 'http:', 'https:']);
2302
2312
  const newlinesAndTabsRegExp$LWS = /[\u2028\u2029\n\r\t]/g;
2303
2313
  const normalizerAnchor$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, rootDocument$LWS, ['a']);
2314
+ function isSameOriginURL$LWS(resourceValue$LWS) {
2315
+ let validParsedURL$LWS;
2316
+ try {
2317
+ validParsedURL$LWS = new URLCtor$LWS(resourceValue$LWS);
2318
+ } catch (_unused$LWS) {
2319
+ /* empty */
2320
+ }
2321
+ // Empty strings and file path fragments are effectively "same origin"
2322
+ if (!validParsedURL$LWS) {
2323
+ return true;
2324
+ }
2325
+ const resourceUrlOrigin$LWS = ReflectApply$LWS$1(URLProtoOriginGetter$LWS, validParsedURL$LWS, []);
2326
+ // If there is an origin for the provided resource and its the same as the top level window
2327
+ // then it can be treated as a same-origin URL.
2328
+ return resourceUrlOrigin$LWS && resourceUrlOrigin$LWS === rootWindow$LWS$1.location.origin;
2329
+ }
2304
2330
  // @TODO: W-7302311 Make paths and domains configurable.
2305
2331
  function isValidURL$LWS(parsedURL$LWS) {
2306
2332
  // Need to add /services to isValidUrl unit test and locker/scripts/test/disallowed-endpoints.js once we remove the gate.
@@ -2336,7 +2362,7 @@ function sanitizeURLForElement$LWS(url$LWS) {
2336
2362
  function sanitizeURLString$LWS(urlString$LWS) {
2337
2363
  return urlString$LWS === '' ? urlString$LWS : ReflectApply$LWS$1(StringProtoReplace$LWS, urlString$LWS, [newlinesAndTabsRegExp$LWS, '']);
2338
2364
  }
2339
- /*! version: 0.23.6 */
2365
+ /*! version: 0.24.6 */
2340
2366
 
2341
2367
  /*! @license DOMPurify 3.1.6 | (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.6/LICENSE */
2342
2368
 
@@ -3895,15 +3921,28 @@ var purify = createDOMPurify();
3895
3921
  */
3896
3922
  // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3897
3923
  const SUPPORTS_TRUSTED_TYPES = typeof trustedTypes !== 'undefined';
3898
- function createTrustedTypesPolicy(name, options) {
3924
+ const trustedTypePolicyRegistry = {
3925
+ __proto__: null
3926
+ };
3927
+ function createDuplicateSafeTrustedTypesPolicy(name, options) {
3928
+ // istanbul ignore next: not testable in coverage collection
3929
+ if (trustedTypePolicyRegistry[name]) {
3930
+ return trustedTypePolicyRegistry[name];
3931
+ }
3899
3932
  // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3900
- return trustedTypes.createPolicy(name, options);
3933
+ // eslint-disable-next-line no-return-assign
3934
+ return trustedTypePolicyRegistry[name] = trustedTypes.createPolicy(name, options);
3901
3935
  }
3902
- function createFallbackPolicy(_name, options) {
3903
- return options;
3936
+ function createDuplicateSafeFallbackPolicy(name, options) {
3937
+ if (trustedTypePolicyRegistry[name]) {
3938
+ return trustedTypePolicyRegistry[name];
3939
+ }
3940
+ // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3941
+ // eslint-disable-next-line no-return-assign
3942
+ return trustedTypePolicyRegistry[name] = options;
3904
3943
  }
3905
3944
  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
3906
- const createPolicy = SUPPORTS_TRUSTED_TYPES ? createTrustedTypesPolicy : createFallbackPolicy;
3945
+ const createPolicy = SUPPORTS_TRUSTED_TYPES ? createDuplicateSafeTrustedTypesPolicy : createDuplicateSafeFallbackPolicy;
3907
3946
  const policyOptions = {
3908
3947
  createHTML(value) {
3909
3948
  return value;
@@ -3951,7 +3990,7 @@ try {
3951
3990
  // swallow
3952
3991
  }
3953
3992
  const trusted = createPolicy('trusted', policyOptions);
3954
- /*! version: 0.23.6 */
3993
+ /*! version: 0.24.6 */
3955
3994
 
3956
3995
  /*!
3957
3996
  * Copyright (C) 2019 salesforce.com, inc.
@@ -4212,7 +4251,7 @@ function blobSanitizer$LWS(sandboxKey$LWS) {
4212
4251
  }
4213
4252
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
4214
4253
  }
4215
- /*! version: 0.23.6 */
4254
+ /*! version: 0.24.6 */
4216
4255
 
4217
4256
  /*!
4218
4257
  * Copyright (C) 2023 salesforce.com, inc.
@@ -4311,12 +4350,12 @@ const policyOptions$LWS = {
4311
4350
  return '';
4312
4351
  },
4313
4352
  createScriptURL(dirty$LWS, evaluator$LWS, targetElement$LWS) {
4314
- const setURL$LWS = encloseSrcSetter$LWS(targetElement$LWS);
4353
+ const setScriptURL$LWS = createScriptSrcURLSetter$LWS(targetElement$LWS);
4315
4354
  dirty$LWS = `${dirty$LWS}`;
4316
4355
  // Passthrough for any script element evaluated by us
4317
4356
  // or if userland code tries to set a falsy value.
4318
4357
  if (evaluatedScripts$LWS.has(targetElement$LWS) || dirty$LWS === '' || dirty$LWS === 'undefined' || dirty$LWS === 'null') {
4319
- setURL$LWS(trusted.createScriptURL(dirty$LWS));
4358
+ setScriptURL$LWS(dirty$LWS);
4320
4359
  return dirty$LWS;
4321
4360
  }
4322
4361
  const targetElementIsConnected$LWS = ReflectApply$LWS$1(NodeProtoIsConnectedGetter$LWS, targetElement$LWS, []);
@@ -4326,7 +4365,7 @@ const policyOptions$LWS = {
4326
4365
  // because it will never be evaluated again.
4327
4366
  if (getURL$LWS(targetElement$LWS)) {
4328
4367
  evaluatedScripts$LWS.add(targetElement$LWS);
4329
- setURL$LWS(trusted.createScriptURL(dirty$LWS));
4368
+ setScriptURL$LWS(dirty$LWS);
4330
4369
  return dirty$LWS;
4331
4370
  }
4332
4371
  // There is a small window while the source code is asynchronously fetched but the script may
@@ -4356,12 +4395,12 @@ const policyOptions$LWS = {
4356
4395
  // of the new URL.
4357
4396
  // However, TrustedTypes still requires this assignment to be signed.
4358
4397
  // We do this because we don't want to leave observable traces in the DOM.
4359
- setURL$LWS(trusted.createScriptURL(cachedURL$LWS));
4398
+ setScriptURL$LWS(cachedURL$LWS);
4360
4399
  evaluator$LWS(sourceText$LWS);
4361
4400
  }, [targetElement$LWS]),
4362
4401
  set: undefined
4363
4402
  });
4364
- setURL$LWS(trusted.createScriptURL(safeURL$LWS));
4403
+ setScriptURL$LWS(safeURL$LWS);
4365
4404
  };
4366
4405
  const onReject$LWS = _error$LWS => {
4367
4406
  URLRevokeObjectURL$LWS(safeURL$LWS);
@@ -4373,11 +4412,11 @@ const policyOptions$LWS = {
4373
4412
  // the state of the script elements. It's an either or operation: either we set a
4374
4413
  // signed value and we are ok or we don't and the browser throws an error. We
4375
4414
  // want our 404 URL to be set and trigger the event handlers, hence we have to sign.
4376
- setURL$LWS(trusted.createScriptURL('blob:http://localhost/not-found'));
4415
+ setScriptURL$LWS('blob:http://localhost/not-found');
4377
4416
  // This error event handler will get triggered after we set our 404 blob URL.
4378
4417
  const errorEventHandler$LWS = () => {
4379
4418
  // Similar to our wrappedEvaluator, we leave no traces.
4380
- setURL$LWS(trusted.createScriptURL(cachedURL$LWS));
4419
+ setScriptURL$LWS(cachedURL$LWS);
4381
4420
  ReflectApply$LWS$1(EventTargetProtoRemoveEventListener$LWS, targetElement$LWS, ['error', errorEventHandler$LWS]);
4382
4421
  };
4383
4422
  ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, targetElement$LWS, ['error', errorEventHandler$LWS]);
@@ -4402,15 +4441,16 @@ function getURL$LWS(targetElement$LWS) {
4402
4441
  const hasHref$LWS = ReflectApply$LWS$1(ElementProtoHasAttribute$LWS, targetElement$LWS, ['href']);
4403
4442
  return hasHref$LWS ? ReflectApply$LWS$1(ElementProtoGetAttribute$LWS, targetElement$LWS, ['href']) : ReflectApply$LWS$1(ElementProtoGetAttribute$LWS, targetElement$LWS, ['xlink:href']);
4404
4443
  }
4405
- function encloseSrcSetter$LWS(targetElement$LWS) {
4444
+ function createScriptSrcURLSetter$LWS(targetElement$LWS) {
4406
4445
  const namespaceURI$LWS = ReflectApply$LWS$1(ElementProtoNamespaceURIGetter$LWS, targetElement$LWS, []);
4407
4446
  const attributeNamespaceURI$LWS = namespaceURI$LWS === NAMESPACE_XHTML$LWS ? '' : NAMESPACE_XLINK$LWS;
4408
4447
  const attributeName$LWS = targetElement$LWS instanceof HTMLScriptElementCtor$LWS ? 'src' : 'href';
4409
- return function (src$LWS) {
4448
+ return function (dirty$LWS) {
4449
+ const src$LWS = trusted.createScriptURL(dirty$LWS);
4410
4450
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
4411
4451
  };
4412
4452
  }
4413
- /*! version: 0.23.6 */
4453
+ /*! version: 0.24.6 */
4414
4454
 
4415
4455
  /*!
4416
4456
  * Copyright (C) 2019 salesforce.com, inc.
@@ -6190,11 +6230,27 @@ function initDistortionDocumentOpen$LWS({
6190
6230
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/open#three-argument_document.open
6191
6231
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
6192
6232
  const childWindow$LWS = ReflectApply$LWS$1(originalDocumentOpen$LWS, this, normalizedArgs$LWS);
6193
- // W-16032332
6194
- // Block access to unsafe child window properties
6195
- markForUnsafePropertyBlocking$LWS(childWindow$LWS);
6233
+ const {
6234
+ 0: resourceUrl$LWS = ''
6235
+ } = normalizedArgs$LWS;
6236
+ // In 256, limit this restriction to urls that can be treated as same-origin
6237
+ // istanbul ignore else: previous behavior will not be tested in collection coverage
6238
+ if (isGaterEnabledFeature$LWS('enabledChangesSince.256')) {
6239
+ // This CANNOT be combined with the above condition, because doing so
6240
+ // will result in the else consequent body being executed in the case
6241
+ // where the gate is enabled and the url is not same origin,
6242
+ // which is counter to the goals of this change!!
6243
+ if (isSameOriginURL$LWS(resourceUrl$LWS)) {
6244
+ // W-16032332
6245
+ // Block access to unsafe child window properties
6246
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
6247
+ }
6248
+ } else {
6249
+ // When the gate is disabled, mark all child windows
6250
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
6251
+ }
6196
6252
  if (childWindow$LWS) {
6197
- initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
6253
+ initWindowOpenChildWindow$LWS(childWindow$LWS, resourceUrl$LWS);
6198
6254
  }
6199
6255
  return childWindow$LWS;
6200
6256
  }
@@ -6443,6 +6499,8 @@ function initDistortionElementBefore$LWS({
6443
6499
  return distortionEntry$LWS;
6444
6500
  };
6445
6501
  }
6502
+
6503
+ // TODO: this has been deprecated and is no longer implemented in any browser
6446
6504
  function initDistortionElementGetInnerHTML$LWS({
6447
6505
  globalObject: {
6448
6506
  Element: {
@@ -6456,6 +6514,7 @@ function initDistortionElementGetInnerHTML$LWS({
6456
6514
  // istanbul ignore next: only runs in browsers without property
6457
6515
  return noop$LWS$1;
6458
6516
  }
6517
+ // istanbul ignore next: only runs in browsers with property, which no longer includes Chrome https://issues.chromium.org/issues/41492947
6459
6518
  const distortionEntry$LWS = [originalGetInnerHTML$LWS, function getInnerHTML$LWS(...args$LWS) {
6460
6519
  if (args$LWS.length) {
6461
6520
  const {
@@ -6481,6 +6540,7 @@ function initDistortionElementGetInnerHTML$LWS({
6481
6540
  }
6482
6541
  return ReflectApply$LWS$1(originalGetInnerHTML$LWS, this, args$LWS);
6483
6542
  }];
6543
+ // istanbul ignore next: only runs in browsers with property, which no longer includes Chrome https://issues.chromium.org/issues/41492947
6484
6544
  return function distortionElementGetInnerHTML$LWS() {
6485
6545
  return distortionEntry$LWS;
6486
6546
  };
@@ -7562,13 +7622,12 @@ function enforceSandboxAllowScriptsForSameOriginIframeRealm$LWS(iframe$LWS) {
7562
7622
  throw new LockerSecurityError$LWS('HTMLIFrameElement.sandbox cannot be set to "allow-same-origin"');
7563
7623
  }
7564
7624
  if (srcValue$LWS !== '' && srcValue$LWS !== ABOUT_BLANK_TOKEN$LWS) {
7565
- // If there is a valid src value and it is not "about:blank", parse it and
7566
- // compare it to the top level window's location.origin. We don't want to
7567
- // impose the sandbox="allow-scripts" on cross-origin iframes.
7625
+ // If there is a valid src value and it is not "about:blank" compare it to the top
7626
+ // level window's location.origin. We don't want to impose the sandbox="allow-scripts"
7627
+ // on cross-origin iframes.
7568
7628
  try {
7569
- const srcUrlOrigin$LWS = ReflectApply$LWS$1(URLProtoOriginGetter$LWS, new URLCtor$LWS(srcValue$LWS), []);
7570
- // If this iframe.src is cross-origin, let the browser take care of security.
7571
- if (srcUrlOrigin$LWS && srcUrlOrigin$LWS !== rootWindow$LWS$1.location.origin) {
7629
+ // This change is >=256 safe, as it just moved the existing logic into a shared function
7630
+ if (!isSameOriginURL$LWS(srcValue$LWS)) {
7572
7631
  return;
7573
7632
  }
7574
7633
  } catch (_unused2$LWS) {
@@ -7933,6 +7992,65 @@ function initDistortionHTMLScriptElementTextSetter$LWS({
7933
7992
  }];
7934
7993
  };
7935
7994
  }
7995
+ function initDistortionHTMLScriptElementTextContentGetter$LWS({
7996
+ globalObject: {
7997
+ HTMLScriptElement: HTMLScriptElement$LWS
7998
+ }
7999
+ }) {
8000
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElement$LWS.prototype, 'textContent');
8001
+ // This may not be implemented in all browsers.
8002
+ // https://www.w3.org/TR/trusted-types/#enforcement-in-scripts
8003
+ if (!isGaterEnabledFeature$LWS('enabledChangesSince.256') || !descriptor$LWS) {
8004
+ return noop$LWS$1;
8005
+ }
8006
+ // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
8007
+ const {
8008
+ get: originalTextContentGetter$LWS
8009
+ } = descriptor$LWS;
8010
+ // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
8011
+ const distortionEntry$LWS = [originalTextContentGetter$LWS, function textContent$LWS() {
8012
+ var _getOriginalScriptPro$LWS;
8013
+ return (_getOriginalScriptPro$LWS = getOriginalScriptProperty$LWS(this)) != null ? _getOriginalScriptPro$LWS : ReflectApply$LWS$1(originalTextContentGetter$LWS, this, []);
8014
+ }];
8015
+ // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
8016
+ return function distortionHTMLScriptElementSrcGetter$LWS() {
8017
+ return distortionEntry$LWS;
8018
+ };
8019
+ }
8020
+ function initDistortionHTMLScriptElementTextContentSetter$LWS({
8021
+ globalObject: {
8022
+ HTMLScriptElement: HTMLScriptElement$LWS
8023
+ },
8024
+ root: {
8025
+ distortions: distortions$LWS
8026
+ }
8027
+ }) {
8028
+ const descriptor$LWS = ReflectGetOwnPropertyDescriptor$LWS(HTMLScriptElement$LWS.prototype, 'textContent');
8029
+ // This may not be implemented in all browsers.
8030
+ // https://www.w3.org/TR/trusted-types/#enforcement-in-scripts
8031
+ if (!isGaterEnabledFeature$LWS('enabledChangesSince.256') || !descriptor$LWS) {
8032
+ return noop$LWS$1;
8033
+ }
8034
+ // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
8035
+ const {
8036
+ get: originalTextContentGetter$LWS,
8037
+ set: originalTextContentSetter$LWS
8038
+ } = descriptor$LWS;
8039
+ // istanbul ignore next: currently not implemented in Chrome (used for coverage collection)
8040
+ return function distortionHTMLScriptElementTextContentSetter$LWS(record$LWS) {
8041
+ const {
8042
+ sandboxEvaluator: sandboxEvaluator$LWS
8043
+ } = record$LWS;
8044
+ return [originalTextContentSetter$LWS, function textContent$LWS(value$LWS) {
8045
+ const valueAsString$LWS = trusted.createScript(value$LWS);
8046
+ const scriptWasNotEvaluatedInScriptPropertySetter$LWS = scriptPropertySetters$LWS(this, 'textContent', valueAsString$LWS, originalTextContentGetter$LWS, originalTextContentSetter$LWS, distortions$LWS, sandboxEvaluator$LWS, trusted.createScript(SCRIPT_HOOK_SOURCE_TEXT$LWS));
8047
+ if (scriptWasNotEvaluatedInScriptPropertySetter$LWS) {
8048
+ return;
8049
+ }
8050
+ ReflectApply$LWS$1(originalTextContentSetter$LWS, this, [valueAsString$LWS]);
8051
+ }];
8052
+ };
8053
+ }
7936
8054
  function initDistortionIDBObjectStoreAdd$LWS({
7937
8055
  globalObject: {
7938
8056
  DOMException: DOMException$LWS,
@@ -7991,13 +8109,14 @@ function initDistortionIDBObjectStorePut$LWS({
7991
8109
  }
7992
8110
  function initDistortionMathMLElementOnsecuritypolicyviolation$LWS({
7993
8111
  globalObject: {
7994
- MathMLElement: {
7995
- prototype: MathMLElementProto$LWS
7996
- },
7997
8112
  MathMLElement: MathMLElement$LWS
7998
8113
  }
7999
8114
  }) {
8000
- return createEventDistortionFactory$LWS(MathMLElementProto$LWS, MathMLElement$LWS, 'securitypolicyviolation');
8115
+ // istanbul ignore next: ensure that MathMLElement exists before attempting to distort it. This is unreachable in the test environment.
8116
+ if (typeof MathMLElement$LWS !== 'function') {
8117
+ return noop$LWS$1;
8118
+ }
8119
+ return createEventDistortionFactory$LWS(MathMLElement$LWS.prototype, MathMLElement$LWS, 'securitypolicyviolation');
8001
8120
  }
8002
8121
  function initDistortionMessagePortPostMessage$LWS({
8003
8122
  globalObject: {
@@ -8264,8 +8383,8 @@ function initDistortionNodeTextContentGetter$LWS({
8264
8383
  const originalTextContentGetter$LWS = ObjectLookupOwnGetter$LWS$1(Node$LWS.prototype, 'textContent');
8265
8384
  const distortionEntry$LWS = [originalTextContentGetter$LWS, function textContent$LWS() {
8266
8385
  if (this instanceof HTMLScriptElement$LWS || this instanceof SVGScriptElement$LWS) {
8267
- var _getOriginalScriptPro$LWS;
8268
- return (_getOriginalScriptPro$LWS = getOriginalScriptProperty$LWS(this)) != null ? _getOriginalScriptPro$LWS : ReflectApply$LWS$1(originalTextContentGetter$LWS, this, []);
8386
+ var _getOriginalScriptPro2$LWS;
8387
+ return (_getOriginalScriptPro2$LWS = getOriginalScriptProperty$LWS(this)) != null ? _getOriginalScriptPro2$LWS : ReflectApply$LWS$1(originalTextContentGetter$LWS, this, []);
8269
8388
  }
8270
8389
  return ReflectApply$LWS$1(originalTextContentGetter$LWS, this, []);
8271
8390
  }];
@@ -9926,9 +10045,25 @@ function initDistortionWindowOpen$LWS({
9926
10045
  const distortionEntry$LWS = [originalWindowOpen$LWS, function open$LWS(...args$LWS) {
9927
10046
  const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
9928
10047
  const childWindow$LWS = ReflectApply$LWS$1(originalWindowOpen$LWS, this, normalizedArgs$LWS);
9929
- // W-16032332
9930
- // Block access to unsafe child window properties
9931
- markForUnsafePropertyBlocking$LWS(childWindow$LWS);
10048
+ const {
10049
+ 0: resourceUrl$LWS = ''
10050
+ } = normalizedArgs$LWS;
10051
+ // In 256, limit this restriction to urls that can be treated as same-origin
10052
+ // istanbul ignore else: previous behavior will not be tested in collection coverage
10053
+ if (isGaterEnabledFeature$LWS('enabledChangesSince.256')) {
10054
+ // This CANNOT be combined with the above condition, because doing so
10055
+ // will result in the else consequent body being executed in the case
10056
+ // where the gate is enabled and the url is not same origin,
10057
+ // which is counter to the goals of this change!!
10058
+ if (isSameOriginURL$LWS(resourceUrl$LWS)) {
10059
+ // W-16032332
10060
+ // Block access to unsafe child window properties
10061
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
10062
+ }
10063
+ } else {
10064
+ // When the gate is disabled, mark all child windows
10065
+ markForUnsafePropertyBlocking$LWS(childWindow$LWS);
10066
+ }
9932
10067
  // W-14218118
9933
10068
  // If the target is '_self', '_parent', or '_top', only makes one request
9934
10069
  if (normalizedArgs$LWS.length > 1) {
@@ -9943,7 +10078,7 @@ function initDistortionWindowOpen$LWS({
9943
10078
  // W-13552831
9944
10079
  // If the target is anything else, two requests are made
9945
10080
  if (childWindow$LWS && normalizedArgs$LWS.length) {
9946
- initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
10081
+ initWindowOpenChildWindow$LWS(childWindow$LWS, resourceUrl$LWS);
9947
10082
  }
9948
10083
  return childWindow$LWS;
9949
10084
  }];
@@ -10005,19 +10140,22 @@ function initDistortionWindowSetInterval$LWS({
10005
10140
  const {
10006
10141
  0: callback$LWS
10007
10142
  } = args$LWS;
10008
- if (callback$LWS !== null && callback$LWS !== undefined && typeof callback$LWS !== 'function') {
10009
- // Snapshot callback source to prevent shapeshifting.
10010
- const sourceText$LWS = toSafeStringValue$LWS(callback$LWS);
10011
- // Defer transforming source text asynchronously.
10012
- let transformedSourceText$LWS;
10013
- // Replace callback parameter.
10014
- args$LWS[0] = () => {
10015
- // istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
10016
- if (transformedSourceText$LWS === undefined) {
10017
- transformedSourceText$LWS = transformSourceText$LWS(sourceText$LWS);
10143
+ if (callback$LWS !== null && callback$LWS !== undefined) {
10144
+ if (typeof callback$LWS !== 'function') {
10145
+ // Snapshot callback source to prevent shapeshifting.
10146
+ const sourceText$LWS = toSafeStringValue$LWS(callback$LWS);
10147
+ // Replace callback parameter.
10148
+ args$LWS[0] = () => {
10149
+ // Defer transforming source text asynchronously.
10150
+ sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
10151
+ };
10152
+ } else {
10153
+ if (isGaterEnabledFeature$LWS('enabledChangesSince.256') &&
10154
+ // @ts-ignore callback and eval have different type defs, but that's ok for this condition
10155
+ callback$LWS === eval) {
10156
+ throw new LockerSecurityError$LWS('Cannot pass unsafe eval reference.');
10018
10157
  }
10019
- sandboxEvaluator$LWS(transformedSourceText$LWS, UNCOMPILED_CONTEXT$LWS);
10020
- };
10158
+ }
10021
10159
  }
10022
10160
  }
10023
10161
  return ReflectApply$LWS$1(originalSetInterval$LWS, this, args$LWS);
@@ -10040,14 +10178,22 @@ function initDistortionWindowSetTimeout$LWS({
10040
10178
  const {
10041
10179
  0: callback$LWS
10042
10180
  } = args$LWS;
10043
- if (callback$LWS !== null && callback$LWS !== undefined && typeof callback$LWS !== 'function') {
10044
- // Snapshot callback source to prevent shapeshifting.
10045
- const sourceText$LWS = toSafeStringValue$LWS(callback$LWS);
10046
- // Replace callback parameter.
10047
- args$LWS[0] = () => {
10048
- // Defer transforming source text asynchronously.
10049
- sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
10050
- };
10181
+ if (callback$LWS !== null && callback$LWS !== undefined) {
10182
+ if (typeof callback$LWS !== 'function') {
10183
+ // Snapshot callback source to prevent shapeshifting.
10184
+ const sourceText$LWS = toSafeStringValue$LWS(callback$LWS);
10185
+ // Replace callback parameter.
10186
+ args$LWS[0] = () => {
10187
+ // Defer transforming source text asynchronously.
10188
+ sandboxEvaluator$LWS(transformSourceText$LWS(sourceText$LWS), UNCOMPILED_CONTEXT$LWS);
10189
+ };
10190
+ } else {
10191
+ if (isGaterEnabledFeature$LWS('enabledChangesSince.256') &&
10192
+ // @ts-ignore callback and eval have different type defs, but that's ok for this condition
10193
+ callback$LWS === eval) {
10194
+ throw new LockerSecurityError$LWS('Cannot pass unsafe eval reference.');
10195
+ }
10196
+ }
10051
10197
  }
10052
10198
  }
10053
10199
  return ReflectApply$LWS$1(originalSetTimeout$LWS, this, args$LWS);
@@ -10241,7 +10387,7 @@ initDistortionHTMLLinkElementRelSetter$LWS, initDistortionHTMLLinkElementRelList
10241
10387
  // HTMLObjectElement
10242
10388
  initDistortionHTMLObjectElementDataSetter$LWS,
10243
10389
  // HTMLScriptElement
10244
- initDistortionHTMLScriptElementSrcGetter$LWS, initDistortionHTMLScriptElementTextSetter$LWS,
10390
+ initDistortionHTMLScriptElementSrcGetter$LWS, initDistortionHTMLScriptElementTextContentGetter$LWS, initDistortionHTMLScriptElementTextContentSetter$LWS, initDistortionHTMLScriptElementTextSetter$LWS,
10245
10391
  // IDBObjectStore
10246
10392
  initDistortionIDBObjectStoreAdd$LWS, initDistortionIDBObjectStorePut$LWS,
10247
10393
  // MessagePort
@@ -10367,7 +10513,7 @@ const SVGElementBlockedProperties$LWS = ['nonce'];
10367
10513
  const UIEventBlockedProperties$LWS = ['rangeParent'];
10368
10514
  const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
10369
10515
  const XSLTProcessorBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
10370
- /*! version: 0.23.6 */
10516
+ /*! version: 0.24.6 */
10371
10517
 
10372
10518
  /*!
10373
10519
  * Copyright (C) 2019 salesforce.com, inc.
@@ -15068,7 +15214,11 @@ function getESGlobalKeys$LWS(maxPerfMode$LWS) {
15068
15214
  const maxPerfModeKeys$LWS = {
15069
15215
  intrinsics: ['ArrayBuffer', 'Atomics', 'BigInt64Array', 'BigUint64Array', 'DataView', 'Float32Array', 'Float64Array', 'Int16Array', 'Int32Array', 'Int8Array', 'SharedArrayBuffer', 'Uint16Array', 'Uint32Array', 'Uint8Array', 'Uint8ClampedArray'],
15070
15216
  // Ideally these should come from browser-realm, that's a code reorg improvement for later
15071
- browser: ['Blob', 'crypto', 'Crypto', 'File', 'FileReader', 'SubtleCrypto', 'URL']
15217
+ browser: ['Blob',
15218
+ // 'createImageBitmap',
15219
+ 'crypto', 'Crypto', 'fetch', 'File', 'FileReader', 'FileReaderSync',
15220
+ // 'ImageData',
15221
+ 'Request', 'Response', 'SubtleCrypto', 'TextDecoder', 'TextEncoder', 'URL', 'XMLHttpRequest']
15072
15222
  };
15073
15223
  if (maxPerfMode$LWS) {
15074
15224
  ESGlobalKeys$LWS.push(...maxPerfModeKeys$LWS.intrinsics, ...maxPerfModeKeys$LWS.browser);
@@ -15703,7 +15853,7 @@ function toSourceText$LWS(value$LWS, sourceType$LWS) {
15703
15853
  // tools from mistaking the regexp or the replacement string for an
15704
15854
  // actual source mapping URL.
15705
15855
  /\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
15706
- sourceText$LWS = `\n//# LWS Version = "0.23.6"\n${sourceText$LWS}`;
15856
+ sourceText$LWS = `\n//# LWS Version = "0.24.6"\n${sourceText$LWS}`;
15707
15857
  return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
15708
15858
  // Append "'use strict'" to the extracted function body so it is
15709
15859
  // evaluated in strict mode.
@@ -15799,6 +15949,13 @@ function createVirtualEnvironment$LWS(record$LWS) {
15799
15949
  const maxPerfMode$LWS = isGaterEnabledFeature$LWS(ENABLE_MAX_PERF_MODE_GATE$LWS) ||
15800
15950
  // 'devopsimpkg*' or exact 'omnistudio' will override INTO maxPerfMode
15801
15951
  isAllowedToOverrideGaterEnabledFeature$LWS(key$LWS, ENABLE_MAX_PERF_MODE_GATE$LWS);
15952
+ const keepAlive$LWS =
15953
+ // If maxPerfMode is true, then run with keepAlive = true
15954
+ maxPerfMode$LWS ||
15955
+ // istanbul ignore next: cannot test isLockerFeatureEnabled
15956
+ isAllowedToKeepAlive$LWS(key$LWS) && isLockerFeatureEnabled$LWS('isLockerNextForOmnistudioEnabled') ||
15957
+ // For debug mode
15958
+ IFRAME_KEEP_ALIVE_FLAG$LWS;
15802
15959
  return createIframeVirtualEnvironment$LWS(globalObject$LWS, {
15803
15960
  defaultPolicy: {
15804
15961
  createScript:
@@ -15889,9 +16046,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
15889
16046
  ObjectAssign$LWS$1({}, DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS, ObjectGetOwnPropertyDescriptors$LWS(endowments$LWS)) : DEFAULT_ENDOWMENTS_DESCRIPTOR_MAP$LWS,
15890
16047
  instrumentation: instrumentation$LWS,
15891
16048
  maxPerfMode: maxPerfMode$LWS,
15892
- keepAlive:
15893
- // istanbul ignore next: cannot test isLockerFeatureEnabled
15894
- maxPerfMode$LWS && isLockerFeatureEnabled$LWS('isLockerNextForOmnistudioEnabled') || IFRAME_KEEP_ALIVE_FLAG$LWS,
16049
+ keepAlive: keepAlive$LWS,
15895
16050
  liveTargetCallback: isTargetLive$LWS,
15896
16051
  signSourceCallback: sourceText$LWS => trusted.createScript(sourceText$LWS)
15897
16052
  });
@@ -16390,9 +16545,9 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
16390
16545
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
16391
16546
  return secureDep$LWS;
16392
16547
  }
16393
- /*! version: 0.23.6 */
16548
+ /*! version: 0.24.6 */
16394
16549
 
16395
- const loaderDefine = globalThis.LWR.define;
16550
+ const loaderDefine = (globalThis ).LWR.define;
16396
16551
 
16397
16552
  /**
16398
16553
  * Mark an exports object as "live", see https://github.com/caridy/secure-javascript-environment/pull/87.
@@ -16461,7 +16616,7 @@ function secureExporter(
16461
16616
  }
16462
16617
  }
16463
16618
  if (exportsIndex !== -1 || lwcIndex !== -1 || platformResourceLoaderIndex !== -1) {
16464
- return function (...args) {
16619
+ return (...args) => {
16465
16620
  if (exportsIndex !== -1) {
16466
16621
  const arg = args[exportsIndex];
16467
16622
  args[exportsIndex] = markLiveObject(arg) || arg;
@@ -16483,6 +16638,8 @@ function secureExporter(
16483
16638
  namespace,
16484
16639
  );
16485
16640
  }
16641
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16642
+ // @ts-ignore
16486
16643
  return out.apply(this, args);
16487
16644
  };
16488
16645
  }
@@ -16492,8 +16649,8 @@ function secureExporter(
16492
16649
 
16493
16650
  function registerLockerDefine(trustedNamespaces) {
16494
16651
  // override the global LWR.define() for Locker
16495
- globalThis.LWR = Object.freeze(
16496
- Object.assign(Object.assign({}, globalThis.LWR), {
16652
+ (globalThis ).LWR = Object.freeze(
16653
+ Object.assign(Object.assign({}, (globalThis ).LWR), {
16497
16654
  define: function (specifier, dependencies, exporter, signature) {
16498
16655
  if (typeof dependencies === 'function') {
16499
16656
  // when the module has no dependency, the bundler only passes 3 parameters, the specifier, exporter and signature