@salesforce-ui-embedding/internal-lightning-ui-embedding 2.2.7-rc.3 → 2.2.7

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.
@@ -25,7 +25,7 @@ import {
25
25
  UI_STATE_UNSUBSCRIBE_METHOD,
26
26
  } from "./utils/sf-embedding-contract";
27
27
  import { composeUiState, MIRRORED_ATTRIBUTES } from "./utils/ui-state";
28
- import { appendHostMetaData, parseOrigin } from "./utils/url";
28
+ import { appendHostMetaData, isLightningDomain, parseOrigin } from "./utils/url";
29
29
 
30
30
  /** Stable reference for null/undefined `props` so the setter's `===` guard can short-circuit. */
31
31
  const EMPTY_PROPS = Object.freeze({});
@@ -312,7 +312,8 @@ export default class Embedding extends LightningElement {
312
312
  message: "iframe src MUST be a parseable URL.",
313
313
  };
314
314
  }
315
- if (this._iframeSrcOrigin === window.location.origin) {
315
+ const hostOrigin = window.location.origin;
316
+ if (this._iframeSrcOrigin === hostOrigin && !isLightningDomain(hostOrigin)) {
316
317
  return {
317
318
  code: ERROR_CODES.SAME_ORIGIN_SRC,
318
319
  message: "iframe src origin MUST differ from the host document origin.",
@@ -5,6 +5,23 @@
5
5
 
6
6
  export const DEFAULT_SANDBOX_TOKENS = ["allow-scripts", "allow-same-origin"];
7
7
 
8
+ // Source of truth: Core's AuraDomainSuffix Lightning family (domainsuffix.xml); matched with anchored endsWith.
9
+ // Parity is manual and fails closed — a new Core Lightning suffix isn't honored here until this list is
10
+ // hand-updated. A follow-up work item (W-24242222) tracks automated drift detection between the two lists.
11
+ export const LIGHTNING_DOMAIN_SUFFIXES = [
12
+ ".lightning.force.com",
13
+ ".lightning.crmforce.mil",
14
+ // .lightning.sfcrmapps.cn (China/CAG) deferred pending Secure Domains/CAG sign-off.
15
+ ".my-lightning.com",
16
+ // Internal R&D/perf-pod host, NOT customer-facing.
17
+ ".lightning.pc-rnd.force.com",
18
+ ];
19
+
20
+ // SFW/local-dev hosts: hyphenated family label + workspace hash + location before .crm.dev; endsWith can't
21
+ // anchor a mid-hostname marker, so this regex anchors both the .lightning.<family>. label and the trailing .crm.dev.
22
+ export const SFW_DEV_LIGHTNING_DOMAIN_PATTERN =
23
+ /\.lightning\.(?:force-com|crmforce-mil)\.[a-z0-9-]+(?:\.[a-z0-9-]+)*\.crm\.dev$/i;
24
+
8
25
  // Default advisory heartbeat deadline; Infinity opts out.
9
26
  export const DEFAULT_HEARTBEAT_TIMEOUT_MS = 30_000;
10
27
 
@@ -3,11 +3,11 @@
3
3
  * For full license text, see the LICENSE.txt file in this package.
4
4
  */
5
5
 
6
- // `"2.2.7-rc.3"` is a repo-wide ambient declared in /types/globals.d.ts;
6
+ // `"2.2.7"` is a repo-wide ambient declared in /types/globals.d.ts;
7
7
  // build.mjs substitutes the literal at build time, jest globals supply a test value.
8
8
 
9
9
  /** Identity emitted on `ui/notifications/host-initialized`. */
10
10
  export const HOST_INFO = {
11
11
  name: "lightning-ui-embedding",
12
- version: "2.2.7-rc.3",
12
+ version: "2.2.7",
13
13
  };
@@ -3,16 +3,31 @@
3
3
  * For full license text, see the LICENSE.txt file in this package.
4
4
  */
5
5
 
6
+ import { LIGHTNING_DOMAIN_SUFFIXES, SFW_DEV_LIGHTNING_DOMAIN_PATTERN } from "./constants";
6
7
  import { HOST_META_DATA_PARAM } from "./sf-embedding-contract";
7
8
 
8
- export function parseOrigin(src) {
9
+ function safeUrl(input) {
9
10
  try {
10
- return new URL(src).origin;
11
+ return new URL(input);
11
12
  } catch {
12
13
  return null;
13
14
  }
14
15
  }
15
16
 
17
+ export function parseOrigin(src) {
18
+ return safeUrl(src)?.origin ?? null;
19
+ }
20
+
21
+ // True when the origin is a Lightning domain (prod suffixes or SFW/local-dev pattern); set-synonymous with
22
+ // SfdcUrl.isLightningDomain || isInternalUrl, endsWith-anchored so evil.lightning.force.com.attacker.com fails.
23
+ export function isLightningDomain(origin) {
24
+ const hostname = safeUrl(origin ?? "")?.hostname ?? "";
25
+ return (
26
+ LIGHTNING_DOMAIN_SUFFIXES.some((suffix) => hostname.endsWith(suffix)) ||
27
+ SFW_DEV_LIGHTNING_DOMAIN_PATTERN.test(hostname)
28
+ );
29
+ }
30
+
16
31
  export function appendHostMetaData(src, instanceId, hostAppOrigin) {
17
32
  const url = new URL(src);
18
33
  const meta = { instanceId, hostAppOrigin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce-ui-embedding/internal-lightning-ui-embedding",
3
- "version": "2.2.7-rc.3",
3
+ "version": "2.2.7",
4
4
  "private": false,
5
5
  "description": "Lightning Base Component (LWC) host for sf-embedding-protocol iframes",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@salesforce/jsonrpc": "^10.12.3",
25
- "@salesforce/sf-embedding-contract": "2.2.7-rc.3",
26
- "utils": "2.2.7-rc.3"
25
+ "@salesforce/sf-embedding-contract": "2.2.7",
26
+ "utils": "2.2.7"
27
27
  },
28
28
  "sideEffects": false,
29
29
  "publishConfig": {