@wise/dynamic-flow-client 5.22.0 → 5.22.1

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
  };
@@ -6924,7 +6952,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6924
6952
  if (onLoad.type === "link") {
6925
6953
  return createExternalConfirmation(
6926
6954
  `${uid}-external-confirmation`,
6927
- onLoad == null ? void 0 : onLoad.url,
6955
+ safeParseLink(onLoad.url),
6928
6956
  mapperProps.onLink,
6929
6957
  mapperProps.onComponentUpdate
6930
6958
  );
@@ -6932,7 +6960,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6932
6960
  if ((external == null ? void 0 : external.url) && onLoad.type === "none") {
6933
6961
  return createExternalConfirmation(
6934
6962
  `${uid}-external-confirmation`,
6935
- external == null ? void 0 : external.url,
6963
+ safeParseLink(external.url),
6936
6964
  mapperProps.onLink,
6937
6965
  mapperProps.onComponentUpdate
6938
6966
  );
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
  };
@@ -6893,7 +6921,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6893
6921
  if (onLoad.type === "link") {
6894
6922
  return createExternalConfirmation(
6895
6923
  `${uid}-external-confirmation`,
6896
- onLoad == null ? void 0 : onLoad.url,
6924
+ safeParseLink(onLoad.url),
6897
6925
  mapperProps.onLink,
6898
6926
  mapperProps.onComponentUpdate
6899
6927
  );
@@ -6901,7 +6929,7 @@ var getExternalConfiguration = (uid, external, onLoad, mapperProps) => {
6901
6929
  if ((external == null ? void 0 : external.url) && onLoad.type === "none") {
6902
6930
  return createExternalConfirmation(
6903
6931
  `${uid}-external-confirmation`,
6904
- external == null ? void 0 : external.url,
6932
+ safeParseLink(external.url),
6905
6933
  mapperProps.onLink,
6906
6934
  mapperProps.onComponentUpdate
6907
6935
  );