@hubspot/cms-dev-server 1.2.27 → 1.2.28

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 { 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-BoToPcXg.js
13
+ // ../cms-js-internal/dist/types-BaJjNBFd.js
14
14
  import path from "path";
15
15
  var viteRoot;
16
16
  var viteCommand;
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-BoToPcXg.js
6
+ // ../cms-js-internal/dist/types-BaJjNBFd.js
7
7
  import path from "path";
8
8
  import { createHash } from "crypto";
9
9
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -240,7 +240,8 @@ function getCMSAssetConfig(webRoot) {
240
240
  var ENABLED_FEATURES_GATE_MAP = {
241
241
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
242
242
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
243
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
243
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
244
+ "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
244
245
  };
245
246
  function isUngatedFor(gates, gate) {
246
247
  return gates.includes(gate);
@@ -1631,7 +1632,7 @@ function trackUsage(action) {
1631
1632
  eventName: EVENT_NAME,
1632
1633
  action,
1633
1634
  nodeVersion: getNodeVersionData(),
1634
- version: "1.2.27",
1635
+ version: "1.2.28",
1635
1636
  os: getPlatform()
1636
1637
  };
1637
1638
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2912,8 +2913,51 @@ import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
2912
2913
  import { getConfigAccountIfExists as getConfigAccountIfExists3 } from "@hubspot/local-dev-lib/config";
2913
2914
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
2914
2915
  import jsdom from "jsdom";
2916
+ var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
2917
+ async function signGetUrl(authedPortalId, unsignedUrl) {
2918
+ const urlWithPortalId = new URL(unsignedUrl);
2919
+ urlWithPortalId.searchParams.set("portalId", `${authedPortalId}`);
2920
+ const response = await hsCliHttp7.post(authedPortalId, {
2921
+ url: "/url-signer-rest/v1/signing",
2922
+ headers: {
2923
+ "Content-Type": "application/json",
2924
+ Accept: "application/json"
2925
+ },
2926
+ data: JSON.stringify({
2927
+ unsignedUrl: urlWithPortalId.toString(),
2928
+ httpMethod: "GET"
2929
+ })
2930
+ });
2931
+ return response.data.signedUrl;
2932
+ }
2933
+ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
2934
+ if (!isUngatedFor(gates, URL_SIGNING_GATE)) {
2935
+ const { data } = await hsCliHttp7.get(authedPortalId, {
2936
+ url: unsignedUrl,
2937
+ headers
2938
+ });
2939
+ return data;
2940
+ }
2941
+ const signedUrl = await signGetUrl(authedPortalId, unsignedUrl);
2942
+ const authHeaders = {};
2943
+ const accountConfig = getConfigAccountIfExists3(authedPortalId);
2944
+ if (accountConfig && accountConfig.authType === "personalaccesskey") {
2945
+ const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
2946
+ authHeaders["Authorization"] = `Bearer ${accessToken}`;
2947
+ }
2948
+ const response = await fetch(signedUrl, {
2949
+ method: "GET",
2950
+ headers: { ...headers, ...authHeaders }
2951
+ });
2952
+ if (!response.ok) {
2953
+ throw new Error(
2954
+ `Preview GET failed: ${response.status} ${response.statusText}`
2955
+ );
2956
+ }
2957
+ return await response.text();
2958
+ }
2915
2959
  var { JSDOM } = jsdom;
2916
- async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue) {
2960
+ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
2917
2961
  const moduleInfoQueryParams = new URLSearchParams({
2918
2962
  portalId: `${authedPortalId}`
2919
2963
  });
@@ -2928,8 +2972,6 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
2928
2972
  "User-Agent": "HubSpot CMS Dev Server"
2929
2973
  }
2930
2974
  })).data;
2931
- const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
2932
- process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
2933
2975
  const queryParams = new URLSearchParams({
2934
2976
  portalId: `${authedPortalId}`,
2935
2977
  hsLocalProxy: `${true}`,
@@ -2937,20 +2979,34 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
2937
2979
  hsLoginVerifyDisabled: `${true}`,
2938
2980
  module_id: moduleInfo.moduleId
2939
2981
  });
2940
- const modulePreviewHtml = (await hsCliHttp7.get(authedPortalId, {
2941
- url: `/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`,
2942
- headers: {
2943
- ["content-type"]: "application/x-www-form-urlencoded",
2944
- ["Accept"]: "text/html",
2945
- referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
2946
- cookie: cookieValue,
2947
- "User-Agent": "HubSpot CMS Dev Server"
2982
+ const cosRenderingUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`;
2983
+ const previousHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
2984
+ const needsDomainOverride = !isUngatedFor(gates, URL_SIGNING_GATE);
2985
+ if (needsDomainOverride) {
2986
+ process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
2987
+ }
2988
+ let modulePreviewHtml;
2989
+ try {
2990
+ modulePreviewHtml = await signedGet(
2991
+ authedPortalId,
2992
+ cosRenderingUrl,
2993
+ {
2994
+ ["content-type"]: "application/x-www-form-urlencoded",
2995
+ ["Accept"]: "text/html",
2996
+ referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
2997
+ cookie: cookieValue,
2998
+ "User-Agent": "HubSpot CMS Dev Server"
2999
+ },
3000
+ gates
3001
+ );
3002
+ } finally {
3003
+ if (needsDomainOverride) {
3004
+ if (previousHubApiDomainOverride) {
3005
+ process.env.HUBAPI_DOMAIN_OVERRIDE = previousHubApiDomainOverride;
3006
+ } else {
3007
+ delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3008
+ }
2948
3009
  }
2949
- })).data;
2950
- if (currentHubApiDomainOverride) {
2951
- process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
2952
- } else {
2953
- delete process.env.HUBAPI_DOMAIN_OVERRIDE;
2954
3010
  }
2955
3011
  const dom = new JSDOM(modulePreviewHtml);
2956
3012
  const modulePreviewContent = dom.window.document.querySelector(
@@ -3193,7 +3249,8 @@ var partialRouteHandler = async (request, response) => {
3193
3249
  remoteModule.path,
3194
3250
  authedPortalId,
3195
3251
  authedEnv,
3196
- request.get("COOKIE")
3252
+ request.get("COOKIE"),
3253
+ jsRenderingGates
3197
3254
  ).then((result) => ({
3198
3255
  remoteModule,
3199
3256
  result
@@ -4080,10 +4137,9 @@ ${e.stack}`);
4080
4137
  var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
4081
4138
 
4082
4139
  // src/routes/hublModuleRouteHandler.ts
4083
- import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4084
4140
  var hublModuleRouteHandler = async (request, response) => {
4085
4141
  sendTrackingRequest("view-hubl-module-route");
4086
- const { authedPortalId, localPreviewToken, projectName } = request.app.locals;
4142
+ const { authedPortalId, localPreviewToken, projectName, jsRenderingGates } = request.app.locals;
4087
4143
  const { modulePath } = request.params;
4088
4144
  if (!modulePath) {
4089
4145
  response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
@@ -4109,13 +4165,9 @@ var hublModuleRouteHandler = async (request, response) => {
4109
4165
  updated: Date.now(),
4110
4166
  ...request.query
4111
4167
  };
4112
- const previewUrl = new URL(getPreviewUrl(request, params));
4168
+ const previewUrl = getPreviewUrl(request, params);
4113
4169
  try {
4114
- const result = (await hsCliHttp9.get(authedPortalId, {
4115
- baseURL: previewUrl.origin,
4116
- url: previewUrl.pathname,
4117
- params
4118
- })).data;
4170
+ const result = await signedGet(authedPortalId, previewUrl, {}, jsRenderingGates);
4119
4171
  const html = addRefreshScript(result);
4120
4172
  response.status(200).set({ "Content-Type": "text/html" }).end(html);
4121
4173
  } catch (err) {
@@ -4137,7 +4189,6 @@ var buildModuleIndex = () => buildHTMLResponse(`
4137
4189
  `);
4138
4190
 
4139
4191
  // src/routes/hublTemplateRouteHandler.ts
4140
- import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4141
4192
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
4142
4193
  import { getConfigAccountEnvironment } from "@hubspot/local-dev-lib/config";
4143
4194
  var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
@@ -4188,14 +4239,15 @@ var templateRouteHandler = async (request, response) => {
4188
4239
  hsCacheBuster: Date.now().toString(),
4189
4240
  ...request.query
4190
4241
  };
4191
- const previewUrl = new URL(getPreviewUrl(request, params));
4242
+ const previewUrl = getPreviewUrl(request, params);
4192
4243
  const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
4193
4244
  try {
4194
- const result = (await hsCliHttp10.get(authedPortalId, {
4195
- baseURL: previewUrl.origin,
4196
- url: previewUrl.pathname,
4197
- params
4198
- })).data;
4245
+ const result = await signedGet(
4246
+ authedPortalId,
4247
+ previewUrl,
4248
+ {},
4249
+ jsRenderingGates
4250
+ );
4199
4251
  const pageHtml = addRefreshScript(result);
4200
4252
  const finalHtml = pageHtml.replace(
4201
4253
  HUBSPOT_PREVIEW_BASE_TAG_REGEX,
@@ -4214,6 +4266,7 @@ var templateRouteHandler = async (request, response) => {
4214
4266
  false
4215
4267
  );
4216
4268
  } catch (err) {
4269
+ console.error("Template route error:", err);
4217
4270
  response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
4218
4271
  }
4219
4272
  };
@@ -4295,10 +4348,10 @@ import path11 from "path";
4295
4348
  import { normalizePath as normalizePath9 } from "vite";
4296
4349
 
4297
4350
  // src/api/project.ts
4298
- import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
4351
+ import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4299
4352
  var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
4300
4353
  async function fetchProjectByName(accountId, projectName) {
4301
- return (await hsCliHttp11.get(accountId, {
4354
+ return (await hsCliHttp9.get(accountId, {
4302
4355
  url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
4303
4356
  })).data;
4304
4357
  }
@@ -4916,7 +4969,7 @@ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
4916
4969
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from "@hubspot/local-dev-lib/constants/auth";
4917
4970
 
4918
4971
  // src/proxyPage/fetchDomains.ts
4919
- import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
4972
+ import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4920
4973
 
4921
4974
  // src/lib/errors.ts
4922
4975
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -4974,7 +5027,7 @@ function handleSecretsError(error) {
4974
5027
  // src/proxyPage/fetchDomains.ts
4975
5028
  async function fetchDomains(portalId) {
4976
5029
  try {
4977
- const result = (await hsCliHttp12.get(portalId, {
5030
+ const result = (await hsCliHttp10.get(portalId, {
4978
5031
  url: `/cms/v3/domains`,
4979
5032
  params: { portalId },
4980
5033
  responseType: "json"
@@ -5000,7 +5053,7 @@ async function fetchWebsiteDomainNames(portalId) {
5000
5053
  import path14 from "path";
5001
5054
  import fs5 from "fs";
5002
5055
  import select from "@inquirer/select";
5003
- import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
5056
+ import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
5004
5057
  var HSPROJECT_JSON = "hsproject.json";
5005
5058
  function checkFileExists(filePath) {
5006
5059
  return fs5.existsSync(filePath) && fs5.statSync(filePath).isFile();
@@ -5034,7 +5087,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5034
5087
  const { platformVersion } = hsProjectJSONData;
5035
5088
  let platformVersionResult;
5036
5089
  try {
5037
- platformVersionResult = (await hsCliHttp13.get(portalId, {
5090
+ platformVersionResult = (await hsCliHttp11.get(portalId, {
5038
5091
  url: `developer/projects/v1/platformVersion`,
5039
5092
  responseType: "json"
5040
5093
  })).data;
@@ -5074,7 +5127,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5074
5127
  }
5075
5128
 
5076
5129
  // src/createDevServer.ts
5077
- import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
5130
+ import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5078
5131
 
5079
5132
  // ../cms-js-internal/dist/buildFieldsTypes.js
5080
5133
  import { writeFileSync } from "fs";
@@ -5595,7 +5648,7 @@ Local proxy functionality and module preview routes will not work without settin
5595
5648
  }
5596
5649
  let authedHublet;
5597
5650
  try {
5598
- const accountInformation = (await hsCliHttp14.get(authedPortalId, {
5651
+ const accountInformation = (await hsCliHttp12.get(authedPortalId, {
5599
5652
  url: "/account-info/v3/details"
5600
5653
  })).data;
5601
5654
  authedHublet = accountInformation.dataHostingLocation;
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-BoToPcXg.js
1
+ // ../cms-js-internal/dist/types-BaJjNBFd.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -386,12 +386,14 @@ var GATES = [
386
386
  "CMS:JSRenderer:RemoveCjsPlugin",
387
387
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
388
388
  "CMS:JSRenderer:AnalyzeCmsModules",
389
- "CMS:JSRenderer:StripNullBytes"
389
+ "CMS:JSRenderer:StripNullBytes",
390
+ "PortalsAccessIdentity:DesignManager:UrlSigning"
390
391
  ];
391
392
  var ENABLED_FEATURES_GATE_MAP = {
392
393
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
393
394
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
394
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
395
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
396
+ "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
395
397
  };
396
398
  function isUngatedFor(gates, gate) {
397
399
  return gates.includes(gate);
package/dist/run.js CHANGED
@@ -854,7 +854,7 @@ function packagePath(metaUrl, projectPath) {
854
854
  );
855
855
  }
856
856
 
857
- // ../cms-js-internal/dist/types-BoToPcXg.js
857
+ // ../cms-js-internal/dist/types-BaJjNBFd.js
858
858
  import path3 from "path";
859
859
  import { createHash } from "crypto";
860
860
  import fs2, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1091,7 +1091,8 @@ function getCMSAssetConfig(webRoot2) {
1091
1091
  var ENABLED_FEATURES_GATE_MAP = {
1092
1092
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
1093
1093
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
1094
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
1094
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
1095
+ "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
1095
1096
  };
1096
1097
  function isUngatedFor(gates, gate) {
1097
1098
  return gates.includes(gate);
@@ -2197,7 +2198,7 @@ function trackUsage(action) {
2197
2198
  eventName: EVENT_NAME,
2198
2199
  action,
2199
2200
  nodeVersion: getNodeVersionData(),
2200
- version: "1.2.27",
2201
+ version: "1.2.28",
2201
2202
  os: getPlatform()
2202
2203
  };
2203
2204
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -3478,8 +3479,51 @@ import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
3478
3479
  import { getConfigAccountIfExists as getConfigAccountIfExists4 } from "@hubspot/local-dev-lib/config";
3479
3480
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
3480
3481
  import jsdom from "jsdom";
3482
+ var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
3483
+ async function signGetUrl(authedPortalId, unsignedUrl) {
3484
+ const urlWithPortalId = new URL(unsignedUrl);
3485
+ urlWithPortalId.searchParams.set("portalId", `${authedPortalId}`);
3486
+ const response = await hsCliHttp7.post(authedPortalId, {
3487
+ url: "/url-signer-rest/v1/signing",
3488
+ headers: {
3489
+ "Content-Type": "application/json",
3490
+ Accept: "application/json"
3491
+ },
3492
+ data: JSON.stringify({
3493
+ unsignedUrl: urlWithPortalId.toString(),
3494
+ httpMethod: "GET"
3495
+ })
3496
+ });
3497
+ return response.data.signedUrl;
3498
+ }
3499
+ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
3500
+ if (!isUngatedFor(gates, URL_SIGNING_GATE)) {
3501
+ const { data } = await hsCliHttp7.get(authedPortalId, {
3502
+ url: unsignedUrl,
3503
+ headers
3504
+ });
3505
+ return data;
3506
+ }
3507
+ const signedUrl = await signGetUrl(authedPortalId, unsignedUrl);
3508
+ const authHeaders = {};
3509
+ const accountConfig = getConfigAccountIfExists4(authedPortalId);
3510
+ if (accountConfig && accountConfig.authType === "personalaccesskey") {
3511
+ const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
3512
+ authHeaders["Authorization"] = `Bearer ${accessToken}`;
3513
+ }
3514
+ const response = await fetch(signedUrl, {
3515
+ method: "GET",
3516
+ headers: { ...headers, ...authHeaders }
3517
+ });
3518
+ if (!response.ok) {
3519
+ throw new Error(
3520
+ `Preview GET failed: ${response.status} ${response.statusText}`
3521
+ );
3522
+ }
3523
+ return await response.text();
3524
+ }
3481
3525
  var { JSDOM } = jsdom;
3482
- async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue) {
3526
+ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
3483
3527
  const moduleInfoQueryParams = new URLSearchParams({
3484
3528
  portalId: `${authedPortalId}`
3485
3529
  });
@@ -3494,8 +3538,6 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3494
3538
  "User-Agent": "HubSpot CMS Dev Server"
3495
3539
  }
3496
3540
  })).data;
3497
- const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
3498
- process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
3499
3541
  const queryParams = new URLSearchParams({
3500
3542
  portalId: `${authedPortalId}`,
3501
3543
  hsLocalProxy: `${true}`,
@@ -3503,20 +3545,34 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3503
3545
  hsLoginVerifyDisabled: `${true}`,
3504
3546
  module_id: moduleInfo.moduleId
3505
3547
  });
3506
- const modulePreviewHtml = (await hsCliHttp7.get(authedPortalId, {
3507
- url: `/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`,
3508
- headers: {
3509
- ["content-type"]: "application/x-www-form-urlencoded",
3510
- ["Accept"]: "text/html",
3511
- referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3512
- cookie: cookieValue,
3513
- "User-Agent": "HubSpot CMS Dev Server"
3548
+ const cosRenderingUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com/api/cos-rendering/v1/public/_hcms/preview/template/multi?${queryParams}`;
3549
+ const previousHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
3550
+ const needsDomainOverride = !isUngatedFor(gates, URL_SIGNING_GATE);
3551
+ if (needsDomainOverride) {
3552
+ process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
3553
+ }
3554
+ let modulePreviewHtml;
3555
+ try {
3556
+ modulePreviewHtml = await signedGet(
3557
+ authedPortalId,
3558
+ cosRenderingUrl,
3559
+ {
3560
+ ["content-type"]: "application/x-www-form-urlencoded",
3561
+ ["Accept"]: "text/html",
3562
+ referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3563
+ cookie: cookieValue,
3564
+ "User-Agent": "HubSpot CMS Dev Server"
3565
+ },
3566
+ gates
3567
+ );
3568
+ } finally {
3569
+ if (needsDomainOverride) {
3570
+ if (previousHubApiDomainOverride) {
3571
+ process.env.HUBAPI_DOMAIN_OVERRIDE = previousHubApiDomainOverride;
3572
+ } else {
3573
+ delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3574
+ }
3514
3575
  }
3515
- })).data;
3516
- if (currentHubApiDomainOverride) {
3517
- process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
3518
- } else {
3519
- delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3520
3576
  }
3521
3577
  const dom = new JSDOM(modulePreviewHtml);
3522
3578
  const modulePreviewContent = dom.window.document.querySelector(
@@ -3759,7 +3815,8 @@ var partialRouteHandler = async (request, response) => {
3759
3815
  remoteModule.path,
3760
3816
  authedPortalId,
3761
3817
  authedEnv,
3762
- request.get("COOKIE")
3818
+ request.get("COOKIE"),
3819
+ jsRenderingGates
3763
3820
  ).then((result) => ({
3764
3821
  remoteModule,
3765
3822
  result
@@ -4646,10 +4703,9 @@ ${e.stack}`);
4646
4703
  var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
4647
4704
 
4648
4705
  // src/routes/hublModuleRouteHandler.ts
4649
- import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4650
4706
  var hublModuleRouteHandler = async (request, response) => {
4651
4707
  sendTrackingRequest("view-hubl-module-route");
4652
- const { authedPortalId, localPreviewToken, projectName } = request.app.locals;
4708
+ const { authedPortalId, localPreviewToken, projectName, jsRenderingGates } = request.app.locals;
4653
4709
  const { modulePath } = request.params;
4654
4710
  if (!modulePath) {
4655
4711
  response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
@@ -4675,13 +4731,9 @@ var hublModuleRouteHandler = async (request, response) => {
4675
4731
  updated: Date.now(),
4676
4732
  ...request.query
4677
4733
  };
4678
- const previewUrl = new URL(getPreviewUrl(request, params));
4734
+ const previewUrl = getPreviewUrl(request, params);
4679
4735
  try {
4680
- const result = (await hsCliHttp9.get(authedPortalId, {
4681
- baseURL: previewUrl.origin,
4682
- url: previewUrl.pathname,
4683
- params
4684
- })).data;
4736
+ const result = await signedGet(authedPortalId, previewUrl, {}, jsRenderingGates);
4685
4737
  const html = addRefreshScript(result);
4686
4738
  response.status(200).set({ "Content-Type": "text/html" }).end(html);
4687
4739
  } catch (err) {
@@ -4703,7 +4755,6 @@ var buildModuleIndex = () => buildHTMLResponse(`
4703
4755
  `);
4704
4756
 
4705
4757
  // src/routes/hublTemplateRouteHandler.ts
4706
- import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4707
4758
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
4708
4759
  import { getConfigAccountEnvironment } from "@hubspot/local-dev-lib/config";
4709
4760
  var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
@@ -4754,14 +4805,15 @@ var templateRouteHandler = async (request, response) => {
4754
4805
  hsCacheBuster: Date.now().toString(),
4755
4806
  ...request.query
4756
4807
  };
4757
- const previewUrl = new URL(getPreviewUrl(request, params));
4808
+ const previewUrl = getPreviewUrl(request, params);
4758
4809
  const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
4759
4810
  try {
4760
- const result = (await hsCliHttp10.get(authedPortalId, {
4761
- baseURL: previewUrl.origin,
4762
- url: previewUrl.pathname,
4763
- params
4764
- })).data;
4811
+ const result = await signedGet(
4812
+ authedPortalId,
4813
+ previewUrl,
4814
+ {},
4815
+ jsRenderingGates
4816
+ );
4765
4817
  const pageHtml = addRefreshScript(result);
4766
4818
  const finalHtml = pageHtml.replace(
4767
4819
  HUBSPOT_PREVIEW_BASE_TAG_REGEX,
@@ -4780,6 +4832,7 @@ var templateRouteHandler = async (request, response) => {
4780
4832
  false
4781
4833
  );
4782
4834
  } catch (err) {
4835
+ console.error("Template route error:", err);
4783
4836
  response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
4784
4837
  }
4785
4838
  };
@@ -4861,10 +4914,10 @@ import path12 from "path";
4861
4914
  import { normalizePath as normalizePath9 } from "vite";
4862
4915
 
4863
4916
  // src/api/project.ts
4864
- import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
4917
+ import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4865
4918
  var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
4866
4919
  async function fetchProjectByName(accountId, projectName) {
4867
- return (await hsCliHttp11.get(accountId, {
4920
+ return (await hsCliHttp9.get(accountId, {
4868
4921
  url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
4869
4922
  })).data;
4870
4923
  }
@@ -5585,7 +5638,7 @@ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
5585
5638
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from "@hubspot/local-dev-lib/constants/auth";
5586
5639
 
5587
5640
  // src/proxyPage/fetchDomains.ts
5588
- import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5641
+ import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
5589
5642
 
5590
5643
  // src/lib/errors.ts
5591
5644
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -5643,7 +5696,7 @@ function handleSecretsError(error) {
5643
5696
  // src/proxyPage/fetchDomains.ts
5644
5697
  async function fetchDomains(portalId) {
5645
5698
  try {
5646
- const result = (await hsCliHttp12.get(portalId, {
5699
+ const result = (await hsCliHttp10.get(portalId, {
5647
5700
  url: `/cms/v3/domains`,
5648
5701
  params: { portalId },
5649
5702
  responseType: "json"
@@ -5669,7 +5722,7 @@ async function fetchWebsiteDomainNames(portalId) {
5669
5722
  import path15 from "path";
5670
5723
  import fs6 from "fs";
5671
5724
  import select from "@inquirer/select";
5672
- import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
5725
+ import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
5673
5726
  var HSPROJECT_JSON = "hsproject.json";
5674
5727
  function checkFileExists(filePath) {
5675
5728
  return fs6.existsSync(filePath) && fs6.statSync(filePath).isFile();
@@ -5703,7 +5756,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5703
5756
  const { platformVersion } = hsProjectJSONData;
5704
5757
  let platformVersionResult;
5705
5758
  try {
5706
- platformVersionResult = (await hsCliHttp13.get(portalId, {
5759
+ platformVersionResult = (await hsCliHttp11.get(portalId, {
5707
5760
  url: `developer/projects/v1/platformVersion`,
5708
5761
  responseType: "json"
5709
5762
  })).data;
@@ -5743,7 +5796,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5743
5796
  }
5744
5797
 
5745
5798
  // src/createDevServer.ts
5746
- import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
5799
+ import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5747
5800
 
5748
5801
  // ../cms-js-internal/dist/buildFieldsTypes.js
5749
5802
  import { writeFileSync } from "fs";
@@ -6264,7 +6317,7 @@ Local proxy functionality and module preview routes will not work without settin
6264
6317
  }
6265
6318
  let authedHublet;
6266
6319
  try {
6267
- const accountInformation = (await hsCliHttp14.get(authedPortalId, {
6320
+ const accountInformation = (await hsCliHttp12.get(authedPortalId, {
6268
6321
  url: "/account-info/v3/details"
6269
6322
  })).data;
6270
6323
  authedHublet = accountInformation.dataHostingLocation;
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-BoToPcXg.js
4
+ // ../cms-js-internal/dist/types-BaJjNBFd.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-BoToPcXg.js
11
+ // ../cms-js-internal/dist/types-BaJjNBFd.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -378,8 +378,8 @@ function isStylesheetAsset(staticAsset) {
378
378
  return staticAsset.type === "stylesheet";
379
379
  }
380
380
  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;
381
- var init_types_BoToPcXg = __esm({
382
- "../cms-js-internal/dist/types-BoToPcXg.js"() {
381
+ var init_types_BaJjNBFd = __esm({
382
+ "../cms-js-internal/dist/types-BaJjNBFd.js"() {
383
383
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
384
384
  ENTRY_POINTS_PATH = "components/partials/";
385
385
  MODULE_FOLDER_PATH = "components/modules/";
@@ -501,12 +501,14 @@ ${groupEnd}</script>
501
501
  "CMS:JSRenderer:RemoveCjsPlugin",
502
502
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
503
503
  "CMS:JSRenderer:AnalyzeCmsModules",
504
- "CMS:JSRenderer:StripNullBytes"
504
+ "CMS:JSRenderer:StripNullBytes",
505
+ "PortalsAccessIdentity:DesignManager:UrlSigning"
505
506
  ];
506
507
  ENABLED_FEATURES_GATE_MAP = {
507
508
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
508
509
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
509
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
510
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
511
+ "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
510
512
  };
511
513
  findAllComponentsIn = (webRoot2, componentsFolder) => {
512
514
  const fullComponentsFolderPath = join(webRoot2, componentsFolder);
@@ -1171,8 +1173,8 @@ function GlobalPartialSlot(props) {
1171
1173
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1172
1174
  var init_dist = __esm({
1173
1175
  "../cms-js-internal/dist/index.js"() {
1174
- init_types_BoToPcXg();
1175
- init_types_BoToPcXg();
1176
+ init_types_BaJjNBFd();
1177
+ init_types_BaJjNBFd();
1176
1178
  ({ setProperty, getProperty, hasProperty } = dotProp);
1177
1179
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1178
1180
  const islandsArrayToSerialize = tweakedIslandsArray.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "1.2.27",
3
+ "version": "1.2.28",
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.27",
32
+ "@hubspot/cms-components": "^1.2.28",
33
33
  "@hubspot/local-dev-lib": "4.0.2",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -133,5 +133,5 @@
133
133
  "publishConfig": {
134
134
  "access": "public"
135
135
  },
136
- "gitHead": "1df03a88ffface32bfd8bd56fae3bfb2aac691b3"
136
+ "gitHead": "56958bf86fbcf8a1213a8e64f0617292873f71c0"
137
137
  }
@@ -1,4 +1,7 @@
1
- export declare function renderRemoteModulePreview(modulePath: string, authedPortalId: any, authedEnv: any, cookieValue: any): Promise<{
1
+ import { Gate } from '@hubspot/cms-js-internal';
2
+ export declare function signGetUrl(authedPortalId: number, unsignedUrl: string): Promise<string>;
3
+ export declare function signedGet(authedPortalId: number, unsignedUrl: string, headers: Record<string, string>, gates: Gate[]): Promise<string>;
4
+ export declare function renderRemoteModulePreview(modulePath: string, authedPortalId: any, authedEnv: any, cookieValue: any, gates: Gate[]): Promise<{
2
5
  html: string;
3
6
  cssNeeded: string;
4
7
  }>;