@hubspot/cms-dev-server 1.2.84 → 1.2.85

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.
@@ -10,7 +10,7 @@ import {
10
10
  import { createRequire } from "module";
11
11
  import { default as react } from "@vitejs/plugin-react";
12
12
 
13
- // ../cms-js-internal/dist/types-C8bPIEz4.js
13
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
14
14
  import path from "path";
15
15
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
16
16
  import { join } from "path/posix";
@@ -199,6 +199,37 @@ function noncePlaceholderPlugin() {
199
199
  }
200
200
  };
201
201
  }
202
+ function isSourcemapTraversal(url2) {
203
+ if (!url2)
204
+ return false;
205
+ const [pathname] = url2.split(/[?#]/);
206
+ if (!pathname.endsWith(".map"))
207
+ return false;
208
+ let decodedPathname;
209
+ try {
210
+ decodedPathname = decodeURI(pathname);
211
+ } catch {
212
+ return true;
213
+ }
214
+ return decodedPathname.split(/[/\\]/).includes("..");
215
+ }
216
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
217
+ if (isSourcemapTraversal(req.url)) {
218
+ res.statusCode = 403;
219
+ res.end();
220
+ return;
221
+ }
222
+ next();
223
+ }
224
+ function sourcemapTraversalGuardPlugin() {
225
+ return {
226
+ name: "cms-sourcemap-traversal-guard",
227
+ apply: "serve",
228
+ configureServer(server) {
229
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
230
+ }
231
+ };
232
+ }
202
233
  var traverse = _traverse.default;
203
234
  var {
204
235
  createServerRenderContextV2: createServerRenderContextV22,
@@ -373,6 +404,7 @@ async function forEachModule(projectRoot, moduleName, run) {
373
404
  dedupe: ["react", "react-dom", "@hubspot/cms-components", "styled-jsx"]
374
405
  },
375
406
  plugins: [
407
+ sourcemapTraversalGuardPlugin(),
376
408
  react({
377
409
  babel: {
378
410
  plugins: [
@@ -10,7 +10,7 @@ import { createServer as createViteServer } from "vite";
10
10
  import { createRequire } from "module";
11
11
  import { default as react } from "@vitejs/plugin-react";
12
12
 
13
- // ../cms-js-internal/dist/types-C8bPIEz4.js
13
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
14
14
  import path from "path";
15
15
  var viteRoot;
16
16
  var viteCommand;
@@ -113,6 +113,37 @@ function noncePlaceholderPlugin() {
113
113
  }
114
114
  };
115
115
  }
116
+ function isSourcemapTraversal(url2) {
117
+ if (!url2)
118
+ return false;
119
+ const [pathname] = url2.split(/[?#]/);
120
+ if (!pathname.endsWith(".map"))
121
+ return false;
122
+ let decodedPathname;
123
+ try {
124
+ decodedPathname = decodeURI(pathname);
125
+ } catch {
126
+ return true;
127
+ }
128
+ return decodedPathname.split(/[/\\]/).includes("..");
129
+ }
130
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
131
+ if (isSourcemapTraversal(req.url)) {
132
+ res.statusCode = 403;
133
+ res.end();
134
+ return;
135
+ }
136
+ next();
137
+ }
138
+ function sourcemapTraversalGuardPlugin() {
139
+ return {
140
+ name: "cms-sourcemap-traversal-guard",
141
+ apply: "serve",
142
+ configureServer(server) {
143
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
144
+ }
145
+ };
146
+ }
116
147
  var traverse = _traverse.default;
117
148
  var CMS_MODULE_COMPONENT_NAME = "Module";
118
149
  var DND_AREA_COMPONENT_NAME = "DndArea";
@@ -645,6 +676,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
645
676
  root: webRoot,
646
677
  ...ssrAndOptimizeDep,
647
678
  plugins: [
679
+ sourcemapTraversalGuardPlugin(),
648
680
  hsStaticAssetPlugin(),
649
681
  jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
650
682
  sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { createServer as createViteServer } from "vite";
3
3
  import { createRequire } from "module";
4
4
  import { default as react } from "@vitejs/plugin-react";
5
5
 
6
- // ../cms-js-internal/dist/types-C8bPIEz4.js
6
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
7
7
  import path from "path";
8
8
  import { createHash } from "crypto";
9
9
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -585,6 +585,37 @@ function noncePlaceholderPlugin() {
585
585
  }
586
586
  };
587
587
  }
588
+ function isSourcemapTraversal(url3) {
589
+ if (!url3)
590
+ return false;
591
+ const [pathname] = url3.split(/[?#]/);
592
+ if (!pathname.endsWith(".map"))
593
+ return false;
594
+ let decodedPathname;
595
+ try {
596
+ decodedPathname = decodeURI(pathname);
597
+ } catch {
598
+ return true;
599
+ }
600
+ return decodedPathname.split(/[/\\]/).includes("..");
601
+ }
602
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
603
+ if (isSourcemapTraversal(req.url)) {
604
+ res.statusCode = 403;
605
+ res.end();
606
+ return;
607
+ }
608
+ next();
609
+ }
610
+ function sourcemapTraversalGuardPlugin() {
611
+ return {
612
+ name: "cms-sourcemap-traversal-guard",
613
+ apply: "serve",
614
+ configureServer(server) {
615
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
616
+ }
617
+ };
618
+ }
588
619
  var traverse = _traverse.default;
589
620
  var CMS_MODULE_COMPONENT_NAME = "Module";
590
621
  var DND_AREA_COMPONENT_NAME = "DndArea";
@@ -1217,6 +1248,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
1217
1248
  root: webRoot,
1218
1249
  ...ssrAndOptimizeDep,
1219
1250
  plugins: [
1251
+ sourcemapTraversalGuardPlugin(),
1220
1252
  hsStaticAssetPlugin(),
1221
1253
  jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
1222
1254
  sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
@@ -1659,7 +1691,7 @@ function trackUsage(action) {
1659
1691
  eventName: EVENT_NAME,
1660
1692
  action,
1661
1693
  nodeVersion: getNodeVersionData(),
1662
- version: "1.2.84",
1694
+ version: "1.2.85",
1663
1695
  os: getPlatform()
1664
1696
  };
1665
1697
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2090,6 +2122,9 @@ import { createEmptyServerRenderContext } from "@hubspot/cms-components";
2090
2122
 
2091
2123
  // src/proxyPage/constants.ts
2092
2124
  var VALID_PROXY_DOMAIN_SUFFIXES = ["localhost", "hslocal.net"];
2125
+ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
2126
+ (domain) => `storybook.${domain}`
2127
+ );
2093
2128
 
2094
2129
  // src/proxyPage/utils.ts
2095
2130
  var getSubDomainFromValidLocalDomain = (hostname) => {
@@ -5392,9 +5427,6 @@ var appServerRouteHandler_default = appServerRouteHandler;
5392
5427
  // src/routes/createDevServerRoutes.ts
5393
5428
  import path16 from "path";
5394
5429
  var isProd2 = true;
5395
- var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
5396
- (domain) => `storybook.${domain}`
5397
- );
5398
5430
  var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
5399
5431
  const devServerApp = Router2();
5400
5432
  const { appViteServer, appWebRoot } = appLocals || {};
@@ -5410,7 +5442,7 @@ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
5410
5442
  (__pathname, req) => STORYBOOK_DOMAINS.includes(req.hostname),
5411
5443
  {
5412
5444
  logLevel: "warn",
5413
- target: `http://localhost:${storybookPort}`
5445
+ target: `http://127.0.0.1:${storybookPort}`
5414
5446
  }
5415
5447
  )
5416
5448
  );
@@ -5605,6 +5637,7 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
5605
5637
  include: ["react", "react-dom", "react-dom/client"]
5606
5638
  },
5607
5639
  plugins: [
5640
+ sourcemapTraversalGuardPlugin(),
5608
5641
  (() => {
5609
5642
  const require2 = createRequire2(import.meta.url);
5610
5643
  return react2({
@@ -6370,6 +6403,8 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
6370
6403
  "dev",
6371
6404
  "-p",
6372
6405
  STORYBOOK_PORT.toString(),
6406
+ "--host",
6407
+ DEV_SERVER_HOST,
6373
6408
  "-c",
6374
6409
  configPath,
6375
6410
  "--quiet",
@@ -6382,7 +6417,8 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
6382
6417
  portalId: authedPortalId.toString(),
6383
6418
  hsEnv: authedEnv,
6384
6419
  hublet: authedHublet,
6385
- WEB_ROOT: path19.join(webRoot, "components")
6420
+ WEB_ROOT: path19.join(webRoot, "components"),
6421
+ STORYBOOK_ALLOWED_HOSTS: STORYBOOK_DOMAINS.join(",")
6386
6422
  },
6387
6423
  stdio: "inherit"
6388
6424
  }
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-C8bPIEz4.js
1
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -395,7 +395,6 @@ function getBaseAssetUrlFromBuild(buildDir) {
395
395
  return getBuildInfo(buildDir).baseAssetUrl;
396
396
  }
397
397
  var GATES = [
398
- "CMS:JSRenderer:RemoveMockClientEntryPlugin",
399
398
  "CMS:JSRenderer:AnalyzeCmsModules",
400
399
  "CMS:JSRenderer:StripNullBytes"
401
400
  ];
@@ -738,6 +737,37 @@ function noncePlaceholderPlugin() {
738
737
  }
739
738
  };
740
739
  }
740
+ function isSourcemapTraversal(url) {
741
+ if (!url)
742
+ return false;
743
+ const [pathname] = url.split(/[?#]/);
744
+ if (!pathname.endsWith(".map"))
745
+ return false;
746
+ let decodedPathname;
747
+ try {
748
+ decodedPathname = decodeURI(pathname);
749
+ } catch {
750
+ return true;
751
+ }
752
+ return decodedPathname.split(/[/\\]/).includes("..");
753
+ }
754
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
755
+ if (isSourcemapTraversal(req.url)) {
756
+ res.statusCode = 403;
757
+ res.end();
758
+ return;
759
+ }
760
+ next();
761
+ }
762
+ function sourcemapTraversalGuardPlugin() {
763
+ return {
764
+ name: "cms-sourcemap-traversal-guard",
765
+ apply: "serve",
766
+ configureServer(server) {
767
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
768
+ }
769
+ };
770
+ }
741
771
  var traverse = _traverse.default;
742
772
  var CMS_MODULE_COMPONENT_NAME = "Module";
743
773
  var DND_AREA_COMPONENT_NAME = "DndArea";
@@ -1300,6 +1330,7 @@ export {
1300
1330
  includesHublDataReference,
1301
1331
  isFullHeightPreviewEnabled,
1302
1332
  isLocalUiDisabled,
1333
+ isSourcemapTraversal,
1303
1334
  isStorybookStory,
1304
1335
  isStylesheetAsset,
1305
1336
  isUngatedFor,
@@ -1319,6 +1350,8 @@ export {
1319
1350
  scriptTagToLogServerMessages,
1320
1351
  serializeIslandDataForInlineScript,
1321
1352
  setIn,
1353
+ sourcemapTraversalGuardMiddleware,
1354
+ sourcemapTraversalGuardPlugin,
1322
1355
  ungatedAtBuildTimeFor,
1323
1356
  virtualClientRenderIslandModuleId
1324
1357
  };
package/dist/run.js CHANGED
@@ -896,7 +896,7 @@ function packagePath(metaUrl, projectPath) {
896
896
  );
897
897
  }
898
898
 
899
- // ../cms-js-internal/dist/types-C8bPIEz4.js
899
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
900
900
  import path4 from "path";
901
901
  import { createHash } from "crypto";
902
902
  import fs3, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1478,6 +1478,37 @@ function noncePlaceholderPlugin() {
1478
1478
  }
1479
1479
  };
1480
1480
  }
1481
+ function isSourcemapTraversal(url3) {
1482
+ if (!url3)
1483
+ return false;
1484
+ const [pathname] = url3.split(/[?#]/);
1485
+ if (!pathname.endsWith(".map"))
1486
+ return false;
1487
+ let decodedPathname;
1488
+ try {
1489
+ decodedPathname = decodeURI(pathname);
1490
+ } catch {
1491
+ return true;
1492
+ }
1493
+ return decodedPathname.split(/[/\\]/).includes("..");
1494
+ }
1495
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
1496
+ if (isSourcemapTraversal(req.url)) {
1497
+ res.statusCode = 403;
1498
+ res.end();
1499
+ return;
1500
+ }
1501
+ next();
1502
+ }
1503
+ function sourcemapTraversalGuardPlugin() {
1504
+ return {
1505
+ name: "cms-sourcemap-traversal-guard",
1506
+ apply: "serve",
1507
+ configureServer(server) {
1508
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
1509
+ }
1510
+ };
1511
+ }
1481
1512
  var traverse = _traverse.default;
1482
1513
  var CMS_MODULE_COMPONENT_NAME = "Module";
1483
1514
  var DND_AREA_COMPONENT_NAME = "DndArea";
@@ -2258,7 +2289,7 @@ function trackUsage(action) {
2258
2289
  eventName: EVENT_NAME,
2259
2290
  action,
2260
2291
  nodeVersion: getNodeVersionData(),
2261
- version: "1.2.84",
2292
+ version: "1.2.85",
2262
2293
  os: getPlatform()
2263
2294
  };
2264
2295
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2689,6 +2720,9 @@ import { createEmptyServerRenderContext } from "@hubspot/cms-components";
2689
2720
 
2690
2721
  // src/proxyPage/constants.ts
2691
2722
  var VALID_PROXY_DOMAIN_SUFFIXES = ["localhost", "hslocal.net"];
2723
+ var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
2724
+ (domain2) => `storybook.${domain2}`
2725
+ );
2692
2726
 
2693
2727
  // src/proxyPage/utils.ts
2694
2728
  var getSubDomainFromValidLocalDomain = (hostname) => {
@@ -6002,6 +6036,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
6002
6036
  root: webRoot2,
6003
6037
  ...ssrAndOptimizeDep,
6004
6038
  plugins: [
6039
+ sourcemapTraversalGuardPlugin(),
6005
6040
  hsStaticAssetPlugin(),
6006
6041
  jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
6007
6042
  sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
@@ -6216,9 +6251,6 @@ var appServerRouteHandler_default = appServerRouteHandler;
6216
6251
  // src/routes/createDevServerRoutes.ts
6217
6252
  import path18 from "path";
6218
6253
  var isProd2 = true;
6219
- var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
6220
- (domain2) => `storybook.${domain2}`
6221
- );
6222
6254
  var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
6223
6255
  const devServerApp = Router2();
6224
6256
  const { appViteServer, appWebRoot } = appLocals || {};
@@ -6234,7 +6266,7 @@ var createDevServerRoutes = async (viteServer, appLocals, storybookPort) => {
6234
6266
  (__pathname, req) => STORYBOOK_DOMAINS.includes(req.hostname),
6235
6267
  {
6236
6268
  logLevel: "warn",
6237
- target: `http://localhost:${storybookPort}`
6269
+ target: `http://127.0.0.1:${storybookPort}`
6238
6270
  }
6239
6271
  )
6240
6272
  );
@@ -6429,6 +6461,7 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
6429
6461
  include: ["react", "react-dom", "react-dom/client"]
6430
6462
  },
6431
6463
  plugins: [
6464
+ sourcemapTraversalGuardPlugin(),
6432
6465
  (() => {
6433
6466
  const require2 = createRequire2(import.meta.url);
6434
6467
  return react2({
@@ -7039,6 +7072,8 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
7039
7072
  "dev",
7040
7073
  "-p",
7041
7074
  STORYBOOK_PORT.toString(),
7075
+ "--host",
7076
+ DEV_SERVER_HOST,
7042
7077
  "-c",
7043
7078
  configPath,
7044
7079
  "--quiet",
@@ -7051,7 +7086,8 @@ HubSpot CMS dev server running at ${protocol}://hslocal.net:${PORT}${extraServer
7051
7086
  portalId: authedPortalId.toString(),
7052
7087
  hsEnv: authedEnv,
7053
7088
  hublet: authedHublet,
7054
- WEB_ROOT: path20.join(webRoot2, "components")
7089
+ WEB_ROOT: path20.join(webRoot2, "components"),
7090
+ STORYBOOK_ALLOWED_HOSTS: STORYBOOK_DOMAINS.join(",")
7055
7091
  },
7056
7092
  stdio: "inherit"
7057
7093
  }
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-C8bPIEz4.js
4
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
5
5
  function namespaceModulePropsShape(props) {
6
6
  const {
7
7
  dataQueryResult,
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // ../cms-js-internal/dist/types-C8bPIEz4.js
11
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -392,8 +392,8 @@ function isStylesheetAsset(staticAsset) {
392
392
  return staticAsset.type === "stylesheet";
393
393
  }
394
394
  var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, TEMPLATE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, badInlineJsChars, inlineJsEscapeChars, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, removeIndexFromPath, removeIndexOrTrailingJsFromPath, HEALTHCHECKS_ENABLED_DEFAULT, HEALTHCHECKS_STRICT_DEFAULT, BUILD_INFO_PATH, GATES, ENABLED_FEATURES_GATE_MAP, findAllComponentsIn;
395
- var init_types_C8bPIEz4 = __esm({
396
- "../cms-js-internal/dist/types-C8bPIEz4.js"() {
395
+ var init_types_BWI07Ixv = __esm({
396
+ "../cms-js-internal/dist/types-BWI07Ixv.js"() {
397
397
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
398
398
  ENTRY_POINTS_PATH = "components/partials/";
399
399
  MODULE_FOLDER_PATH = "components/modules/";
@@ -510,7 +510,6 @@ ${groupEnd}</script>
510
510
  HEALTHCHECKS_STRICT_DEFAULT = false;
511
511
  BUILD_INFO_PATH = "/build-info.json";
512
512
  GATES = [
513
- "CMS:JSRenderer:RemoveMockClientEntryPlugin",
514
513
  "CMS:JSRenderer:AnalyzeCmsModules",
515
514
  "CMS:JSRenderer:StripNullBytes"
516
515
  ];
@@ -595,6 +594,7 @@ __export(dist_exports, {
595
594
  includesHublDataReference: () => includesHublDataReference,
596
595
  isFullHeightPreviewEnabled: () => isFullHeightPreviewEnabled,
597
596
  isLocalUiDisabled: () => isLocalUiDisabled,
597
+ isSourcemapTraversal: () => isSourcemapTraversal,
598
598
  isStorybookStory: () => isStorybookStory,
599
599
  isStylesheetAsset: () => isStylesheetAsset,
600
600
  isUngatedFor: () => isUngatedFor,
@@ -614,6 +614,8 @@ __export(dist_exports, {
614
614
  scriptTagToLogServerMessages: () => scriptTagToLogServerMessages,
615
615
  serializeIslandDataForInlineScript: () => serializeIslandDataForInlineScript,
616
616
  setIn: () => setIn,
617
+ sourcemapTraversalGuardMiddleware: () => sourcemapTraversalGuardMiddleware,
618
+ sourcemapTraversalGuardPlugin: () => sourcemapTraversalGuardPlugin,
617
619
  ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
618
620
  virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
619
621
  });
@@ -711,6 +713,37 @@ function noncePlaceholderPlugin() {
711
713
  }
712
714
  };
713
715
  }
716
+ function isSourcemapTraversal(url) {
717
+ if (!url)
718
+ return false;
719
+ const [pathname] = url.split(/[?#]/);
720
+ if (!pathname.endsWith(".map"))
721
+ return false;
722
+ let decodedPathname;
723
+ try {
724
+ decodedPathname = decodeURI(pathname);
725
+ } catch {
726
+ return true;
727
+ }
728
+ return decodedPathname.split(/[/\\]/).includes("..");
729
+ }
730
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
731
+ if (isSourcemapTraversal(req.url)) {
732
+ res.statusCode = 403;
733
+ res.end();
734
+ return;
735
+ }
736
+ next();
737
+ }
738
+ function sourcemapTraversalGuardPlugin() {
739
+ return {
740
+ name: "cms-sourcemap-traversal-guard",
741
+ apply: "serve",
742
+ configureServer(server) {
743
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
744
+ }
745
+ };
746
+ }
714
747
  function findCmsModules(buildContentDescriptors = {}) {
715
748
  let config;
716
749
  return {
@@ -1182,8 +1215,8 @@ function GlobalPartialSlot(props) {
1182
1215
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1183
1216
  var init_dist = __esm({
1184
1217
  "../cms-js-internal/dist/index.js"() {
1185
- init_types_C8bPIEz4();
1186
- init_types_C8bPIEz4();
1218
+ init_types_BWI07Ixv();
1219
+ init_types_BWI07Ixv();
1187
1220
  ({ setProperty, getProperty, hasProperty } = dotProp);
1188
1221
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1189
1222
  const islandsArrayToSerialize = tweakedIslandsArray.map(
@@ -1354,6 +1387,7 @@ import { default as react } from "@vitejs/plugin-react";
1354
1387
  var webRoot = process.env.WEB_ROOT;
1355
1388
  var storyPath = path2.resolve(process.cwd(), webRoot, "**/*.stories.*");
1356
1389
  var jsRenderingGates = process.env.GATES ? process.env.GATES.split(",") : [];
1390
+ var allowedHosts = process.env.STORYBOOK_ALLOWED_HOSTS ? process.env.STORYBOOK_ALLOWED_HOSTS.split(",") : [];
1357
1391
  var main_default = {
1358
1392
  addons: ["@storybook/addon-essentials"],
1359
1393
  framework: "@storybook/react-vite",
@@ -1382,6 +1416,9 @@ var main_default = {
1382
1416
  viteFinal: async (config) => {
1383
1417
  const { resolveIslandPlugin: resolveIslandPlugin2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
1384
1418
  const viteConfig = {
1419
+ server: {
1420
+ allowedHosts
1421
+ },
1385
1422
  define: {
1386
1423
  global: "globalThis",
1387
1424
  "process.env": "{}",
@@ -1411,6 +1448,7 @@ var main_default = {
1411
1448
  postcss: webRoot
1412
1449
  },
1413
1450
  plugins: [
1451
+ sourcemapTraversalGuardPlugin(),
1414
1452
  // Provide Node.js globals for browser environment
1415
1453
  {
1416
1454
  name: "provide-nodejs-globals",
@@ -10,7 +10,7 @@ import {
10
10
  import { createRequire } from "module";
11
11
  import { default as react } from "@vitejs/plugin-react";
12
12
 
13
- // ../cms-js-internal/dist/types-C8bPIEz4.js
13
+ // ../cms-js-internal/dist/types-BWI07Ixv.js
14
14
  import path from "path";
15
15
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
16
16
  import { join } from "path/posix";
@@ -199,6 +199,37 @@ function noncePlaceholderPlugin() {
199
199
  }
200
200
  };
201
201
  }
202
+ function isSourcemapTraversal(url2) {
203
+ if (!url2)
204
+ return false;
205
+ const [pathname] = url2.split(/[?#]/);
206
+ if (!pathname.endsWith(".map"))
207
+ return false;
208
+ let decodedPathname;
209
+ try {
210
+ decodedPathname = decodeURI(pathname);
211
+ } catch {
212
+ return true;
213
+ }
214
+ return decodedPathname.split(/[/\\]/).includes("..");
215
+ }
216
+ function sourcemapTraversalGuardMiddleware(req, res, next) {
217
+ if (isSourcemapTraversal(req.url)) {
218
+ res.statusCode = 403;
219
+ res.end();
220
+ return;
221
+ }
222
+ next();
223
+ }
224
+ function sourcemapTraversalGuardPlugin() {
225
+ return {
226
+ name: "cms-sourcemap-traversal-guard",
227
+ apply: "serve",
228
+ configureServer(server) {
229
+ server.middlewares.use(sourcemapTraversalGuardMiddleware);
230
+ }
231
+ };
232
+ }
202
233
  var traverse = _traverse.default;
203
234
  var {
204
235
  createServerRenderContextV2: createServerRenderContextV22,
@@ -750,6 +781,7 @@ async function forEachModule(projectRoot, moduleName, run) {
750
781
  dedupe: ["react", "react-dom", "@hubspot/cms-components", "styled-jsx"]
751
782
  },
752
783
  plugins: [
784
+ sourcemapTraversalGuardPlugin(),
753
785
  react({
754
786
  babel: {
755
787
  plugins: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "1.2.84",
3
+ "version": "1.2.85",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,7 +29,7 @@
29
29
  "@babel/parser": "^7.25.3",
30
30
  "@babel/traverse": "^7.25.3",
31
31
  "@babel/types": "^7.25.2",
32
- "@hubspot/cms-components": "^1.2.84",
32
+ "@hubspot/cms-components": "^1.2.85",
33
33
  "@hubspot/local-dev-lib": "5.15.0",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -0,0 +1,8 @@
1
+ export declare function debugAuthContext(
2
+ authedPortalId: number,
3
+ cookieValue: string
4
+ ): Promise<void>;
5
+ export declare function compareUrls(
6
+ originalUrl: string,
7
+ signedUrl: string
8
+ ): void;
@@ -0,0 +1,2 @@
1
+ export declare function getLocalComponentsPath(): string;
2
+ export declare function shouldUseLocalComponents(): boolean;
@@ -0,0 +1,18 @@
1
+ import { ViteDevServer } from 'vite';
2
+ /**
3
+ * Processes HTML to find remote assets and replace with Vite-managed URLs
4
+ */
5
+ export declare function processRemoteAssets(
6
+ html: string,
7
+ viteServer: ViteDevServer
8
+ ): Promise<string>;
9
+ /**
10
+ * Vite plugin to handle remote assets
11
+ */
12
+ export declare function remoteAssetsPlugin(): {
13
+ name: string;
14
+ apply: 'serve';
15
+ configResolved(config: any): void;
16
+ resolveId(id: string): string;
17
+ load(id: string): Promise<string>;
18
+ };
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function hubspotStaticAssetsPlugin(): Plugin;
@@ -0,0 +1,10 @@
1
+ import { ViteDevServer, Plugin } from 'vite';
2
+ /**
3
+ * Create a self-contained plugin with proper caching
4
+ */
5
+ export declare function remoteAssetsPlugin(): Plugin & {
6
+ processRemoteAssets: (
7
+ html: string,
8
+ viteServer: ViteDevServer
9
+ ) => Promise<string>;
10
+ };
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Plugin that provides URL signing capabilities
4
+ * Uses internal signing mechanisms when available, with fallback for public environments
5
+ */
6
+ export default function requestSigningPlugin(): Plugin;
@@ -1 +1,2 @@
1
1
  export declare const VALID_PROXY_DOMAIN_SUFFIXES: string[];
2
+ export declare const STORYBOOK_DOMAINS: string[];
@@ -0,0 +1,13 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare function handleGetModulePages(
3
+ req: Request,
4
+ res: Response,
5
+ next: NextFunction
6
+ ): Promise<Response<any, Record<string, any>>>;
7
+ export declare function handleOpenFile(
8
+ req: Request,
9
+ res: Response,
10
+ next: NextFunction
11
+ ): Response<any, Record<string, any>>;
12
+ export declare function createAppServerRoutes(): import('express-serve-static-core').Router;
13
+ export default createAppServerRoutes;
@@ -0,0 +1,7 @@
1
+ import { Request, Response } from 'express';
2
+ declare const homeRouteHandler: (
3
+ request: Request,
4
+ response: Response,
5
+ next: Function
6
+ ) => Promise<void>;
7
+ export default homeRouteHandler;