@wise/dynamic-flow-client 5.22.0 → 5.22.2

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/build/main.js CHANGED
@@ -1313,6 +1313,15 @@ var makeDismissHandler = (onDismiss, mapperProps) => () => {
1313
1313
  });
1314
1314
  };
1315
1315
 
1316
+ // src/utils/safe-parse-link.ts
1317
+ var safeParseLink = (url) => {
1318
+ const parsed = URL.parse(url);
1319
+ if ((parsed == null ? void 0 : parsed.protocol) === "javascript:") {
1320
+ throw new Error("Javascript URLs are not allowed");
1321
+ }
1322
+ return url;
1323
+ };
1324
+
1316
1325
  // src/domain/mappers/utils/behavior-utils.ts
1317
1326
  var getDomainLayerBehavior = ({ action, behavior: specBehavior }, stepActions, registerSubmissionBehavior) => {
1318
1327
  if (specBehavior) {
@@ -1336,13 +1345,32 @@ var normaliseBehavior = (behavior, stepActions) => {
1336
1345
  onError: behavior.onError ? normaliseBehavior(behavior.onError, stepActions) : void 0
1337
1346
  });
1338
1347
  }
1348
+ if (behavior.type === "delay") {
1349
+ return {
1350
+ type: "none",
1351
+ track: false
1352
+ };
1353
+ }
1354
+ if (behavior.type === "dispatch-event") {
1355
+ return {
1356
+ type: "none",
1357
+ track: false
1358
+ };
1359
+ }
1360
+ if (behavior.type === "link") {
1361
+ return __spreadProps(__spreadValues({}, behavior), {
1362
+ type: "link",
1363
+ url: safeParseLink(behavior.url),
1364
+ track: true
1365
+ });
1366
+ }
1339
1367
  return __spreadProps(__spreadValues({}, behavior), { track: true });
1340
1368
  }
1341
1369
  if ("action" in behavior && behavior.action) {
1342
1370
  return actionToBehavior(behavior.action, stepActions);
1343
1371
  }
1344
1372
  if ("link" in behavior && behavior.link) {
1345
- return { type: "link", url: behavior.link.url, track: true };
1373
+ return { type: "link", url: safeParseLink(behavior.link.url), track: true };
1346
1374
  }
1347
1375
  return { type: "none", track: false };
1348
1376
  };
@@ -1718,9 +1746,15 @@ var mergeSections = (existing, incoming) => {
1718
1746
  const knownIds = new Set(existing.map((section) => section.id));
1719
1747
  const newSections = incoming.filter((section) => !knownIds.has(section.id));
1720
1748
  const merged = existing.map((section) => {
1749
+ var _a, _b;
1721
1750
  const match = incoming.find((s) => s.id === section.id);
1722
1751
  if (!match) return section;
1723
- return __spreadProps(__spreadValues({}, match), { items: [...section.items, ...match.items] });
1752
+ return {
1753
+ id: match.id,
1754
+ title: (_a = match.title) != null ? _a : section.title,
1755
+ callToAction: (_b = match.callToAction) != null ? _b : section.callToAction,
1756
+ items: [...section.items, ...match.items]
1757
+ };
1724
1758
  });
1725
1759
  return [...merged, ...newSections];
1726
1760
  };
@@ -6924,7 +6958,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6924
6958
  if (onLoad.type === "link") {
6925
6959
  return createExternalConfirmation(
6926
6960
  `${uid}-external-confirmation`,
6927
- onLoad == null ? void 0 : onLoad.url,
6961
+ safeParseLink(onLoad.url),
6928
6962
  mapperProps.onLink,
6929
6963
  mapperProps.onComponentUpdate
6930
6964
  );
@@ -6932,7 +6966,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6932
6966
  if ((external == null ? void 0 : external.url) && onLoad.type === "none") {
6933
6967
  return createExternalConfirmation(
6934
6968
  `${uid}-external-confirmation`,
6935
- external == null ? void 0 : external.url,
6969
+ safeParseLink(external.url),
6936
6970
  mapperProps.onLink,
6937
6971
  mapperProps.onComponentUpdate
6938
6972
  );
package/build/main.mjs CHANGED
@@ -1282,6 +1282,15 @@ var makeDismissHandler = (onDismiss, mapperProps) => () => {
1282
1282
  });
1283
1283
  };
1284
1284
 
1285
+ // src/utils/safe-parse-link.ts
1286
+ var safeParseLink = (url) => {
1287
+ const parsed = URL.parse(url);
1288
+ if ((parsed == null ? void 0 : parsed.protocol) === "javascript:") {
1289
+ throw new Error("Javascript URLs are not allowed");
1290
+ }
1291
+ return url;
1292
+ };
1293
+
1285
1294
  // src/domain/mappers/utils/behavior-utils.ts
1286
1295
  var getDomainLayerBehavior = ({ action, behavior: specBehavior }, stepActions, registerSubmissionBehavior) => {
1287
1296
  if (specBehavior) {
@@ -1305,13 +1314,32 @@ var normaliseBehavior = (behavior, stepActions) => {
1305
1314
  onError: behavior.onError ? normaliseBehavior(behavior.onError, stepActions) : void 0
1306
1315
  });
1307
1316
  }
1317
+ if (behavior.type === "delay") {
1318
+ return {
1319
+ type: "none",
1320
+ track: false
1321
+ };
1322
+ }
1323
+ if (behavior.type === "dispatch-event") {
1324
+ return {
1325
+ type: "none",
1326
+ track: false
1327
+ };
1328
+ }
1329
+ if (behavior.type === "link") {
1330
+ return __spreadProps(__spreadValues({}, behavior), {
1331
+ type: "link",
1332
+ url: safeParseLink(behavior.url),
1333
+ track: true
1334
+ });
1335
+ }
1308
1336
  return __spreadProps(__spreadValues({}, behavior), { track: true });
1309
1337
  }
1310
1338
  if ("action" in behavior && behavior.action) {
1311
1339
  return actionToBehavior(behavior.action, stepActions);
1312
1340
  }
1313
1341
  if ("link" in behavior && behavior.link) {
1314
- return { type: "link", url: behavior.link.url, track: true };
1342
+ return { type: "link", url: safeParseLink(behavior.link.url), track: true };
1315
1343
  }
1316
1344
  return { type: "none", track: false };
1317
1345
  };
@@ -1687,9 +1715,15 @@ var mergeSections = (existing, incoming) => {
1687
1715
  const knownIds = new Set(existing.map((section) => section.id));
1688
1716
  const newSections = incoming.filter((section) => !knownIds.has(section.id));
1689
1717
  const merged = existing.map((section) => {
1718
+ var _a, _b;
1690
1719
  const match = incoming.find((s) => s.id === section.id);
1691
1720
  if (!match) return section;
1692
- return __spreadProps(__spreadValues({}, match), { items: [...section.items, ...match.items] });
1721
+ return {
1722
+ id: match.id,
1723
+ title: (_a = match.title) != null ? _a : section.title,
1724
+ callToAction: (_b = match.callToAction) != null ? _b : section.callToAction,
1725
+ items: [...section.items, ...match.items]
1726
+ };
1693
1727
  });
1694
1728
  return [...merged, ...newSections];
1695
1729
  };
@@ -6893,7 +6927,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6893
6927
  if (onLoad.type === "link") {
6894
6928
  return createExternalConfirmation(
6895
6929
  `${uid}-external-confirmation`,
6896
- onLoad == null ? void 0 : onLoad.url,
6930
+ safeParseLink(onLoad.url),
6897
6931
  mapperProps.onLink,
6898
6932
  mapperProps.onComponentUpdate
6899
6933
  );
@@ -6901,7 +6935,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6901
6935
  if ((external == null ? void 0 : external.url) && onLoad.type === "none") {
6902
6936
  return createExternalConfirmation(
6903
6937
  `${uid}-external-confirmation`,
6904
- external == null ? void 0 : external.url,
6938
+ safeParseLink(external.url),
6905
6939
  mapperProps.onLink,
6906
6940
  mapperProps.onComponentUpdate
6907
6941
  );