@hubspot/cms-dev-server 1.2.28 → 1.2.31

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-BaJjNBFd.js
13
+ // ../cms-js-internal/dist/types-BsFs0N9P.js
14
14
  import path from "path";
15
15
  var viteRoot;
16
16
  var viteCommand;
@@ -31,7 +31,7 @@ function resolveIslandPlugin(islandsSet) {
31
31
  idWithNoParam,
32
32
  componentExtension
33
33
  );
34
- const modulePath = path.relative(viteRoot, idWithNoParam);
34
+ const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
35
35
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
36
36
  if (islandsSet) {
37
37
  islandsSet.add(moduleId);
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-BaJjNBFd.js
6
+ // ../cms-js-internal/dist/types-BsFs0N9P.js
7
7
  import path from "path";
8
8
  import { createHash } from "crypto";
9
9
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -118,7 +118,7 @@ function resolveIslandPlugin(islandsSet) {
118
118
  idWithNoParam,
119
119
  componentExtension
120
120
  );
121
- const modulePath = path.relative(viteRoot, idWithNoParam);
121
+ const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
122
122
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
123
123
  if (islandsSet) {
124
124
  islandsSet.add(moduleId);
@@ -240,8 +240,7 @@ 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",
244
- "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
243
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
245
244
  };
246
245
  function isUngatedFor(gates, gate) {
247
246
  return gates.includes(gate);
@@ -1632,7 +1631,7 @@ function trackUsage(action) {
1632
1631
  eventName: EVENT_NAME,
1633
1632
  action,
1634
1633
  nodeVersion: getNodeVersionData(),
1635
- version: "1.2.28",
1634
+ version: "1.2.17",
1636
1635
  os: getPlatform()
1637
1636
  };
1638
1637
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2913,51 +2912,8 @@ import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
2913
2912
  import { getConfigAccountIfExists as getConfigAccountIfExists3 } from "@hubspot/local-dev-lib/config";
2914
2913
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
2915
2914
  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
- }
2959
2915
  var { JSDOM } = jsdom;
2960
- async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
2916
+ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue) {
2961
2917
  const moduleInfoQueryParams = new URLSearchParams({
2962
2918
  portalId: `${authedPortalId}`
2963
2919
  });
@@ -2972,6 +2928,8 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
2972
2928
  "User-Agent": "HubSpot CMS Dev Server"
2973
2929
  }
2974
2930
  })).data;
2931
+ const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
2932
+ process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
2975
2933
  const queryParams = new URLSearchParams({
2976
2934
  portalId: `${authedPortalId}`,
2977
2935
  hsLocalProxy: `${true}`,
@@ -2979,34 +2937,20 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
2979
2937
  hsLoginVerifyDisabled: `${true}`,
2980
2938
  module_id: moduleInfo.moduleId
2981
2939
  });
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
- }
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"
3009
2948
  }
2949
+ })).data;
2950
+ if (currentHubApiDomainOverride) {
2951
+ process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
2952
+ } else {
2953
+ delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3010
2954
  }
3011
2955
  const dom = new JSDOM(modulePreviewHtml);
3012
2956
  const modulePreviewContent = dom.window.document.querySelector(
@@ -3249,8 +3193,7 @@ var partialRouteHandler = async (request, response) => {
3249
3193
  remoteModule.path,
3250
3194
  authedPortalId,
3251
3195
  authedEnv,
3252
- request.get("COOKIE"),
3253
- jsRenderingGates
3196
+ request.get("COOKIE")
3254
3197
  ).then((result) => ({
3255
3198
  remoteModule,
3256
3199
  result
@@ -4137,27 +4080,21 @@ ${e.stack}`);
4137
4080
  var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
4138
4081
 
4139
4082
  // src/routes/hublModuleRouteHandler.ts
4083
+ import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4140
4084
  var hublModuleRouteHandler = async (request, response) => {
4141
4085
  sendTrackingRequest("view-hubl-module-route");
4142
- const { authedPortalId, localPreviewToken, projectName, jsRenderingGates } = request.app.locals;
4086
+ const { authedPortalId, localPreviewToken } = request.app.locals;
4143
4087
  const { modulePath } = request.params;
4144
4088
  if (!modulePath) {
4145
4089
  response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
4146
4090
  return;
4147
4091
  }
4148
- const projectPrefix = projectName ? "@projects/" : "";
4149
- const calculatedPath = `@preview/${localPreviewToken}/${projectPrefix}${modulePath}.module`;
4092
+ const calculatedPath = `@preview/${localPreviewToken}/@projects/${modulePath}.module`;
4150
4093
  let customWidgetInfo;
4151
4094
  try {
4152
4095
  customWidgetInfo = await fetchModuleByPath(authedPortalId, calculatedPath);
4153
4096
  } catch (err) {
4154
- console.error(`Failed to fetch module data for ${calculatedPath}: ${err}`);
4155
- response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(err));
4156
- return;
4157
- }
4158
- if (!customWidgetInfo || !("moduleId" in customWidgetInfo)) {
4159
- response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(null));
4160
- return;
4097
+ console.log(`Failed to fetch module data for ${calculatedPath}`);
4161
4098
  }
4162
4099
  const params = {
4163
4100
  module_id: customWidgetInfo.moduleId,
@@ -4165,9 +4102,13 @@ var hublModuleRouteHandler = async (request, response) => {
4165
4102
  updated: Date.now(),
4166
4103
  ...request.query
4167
4104
  };
4168
- const previewUrl = getPreviewUrl(request, params);
4105
+ const previewUrl = new URL(getPreviewUrl(request, params));
4169
4106
  try {
4170
- const result = await signedGet(authedPortalId, previewUrl, {}, jsRenderingGates);
4107
+ const result = (await hsCliHttp9.get(authedPortalId, {
4108
+ baseURL: previewUrl.origin,
4109
+ url: previewUrl.pathname,
4110
+ params
4111
+ })).data;
4171
4112
  const html = addRefreshScript(result);
4172
4113
  response.status(200).set({ "Content-Type": "text/html" }).end(html);
4173
4114
  } catch (err) {
@@ -4189,6 +4130,7 @@ var buildModuleIndex = () => buildHTMLResponse(`
4189
4130
  `);
4190
4131
 
4191
4132
  // src/routes/hublTemplateRouteHandler.ts
4133
+ import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4192
4134
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
4193
4135
  import { getConfigAccountEnvironment } from "@hubspot/local-dev-lib/config";
4194
4136
  var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
@@ -4239,15 +4181,14 @@ var templateRouteHandler = async (request, response) => {
4239
4181
  hsCacheBuster: Date.now().toString(),
4240
4182
  ...request.query
4241
4183
  };
4242
- const previewUrl = getPreviewUrl(request, params);
4184
+ const previewUrl = new URL(getPreviewUrl(request, params));
4243
4185
  const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
4244
4186
  try {
4245
- const result = await signedGet(
4246
- authedPortalId,
4247
- previewUrl,
4248
- {},
4249
- jsRenderingGates
4250
- );
4187
+ const result = (await hsCliHttp10.get(authedPortalId, {
4188
+ baseURL: previewUrl.origin,
4189
+ url: previewUrl.pathname,
4190
+ params
4191
+ })).data;
4251
4192
  const pageHtml = addRefreshScript(result);
4252
4193
  const finalHtml = pageHtml.replace(
4253
4194
  HUBSPOT_PREVIEW_BASE_TAG_REGEX,
@@ -4266,7 +4207,6 @@ var templateRouteHandler = async (request, response) => {
4266
4207
  false
4267
4208
  );
4268
4209
  } catch (err) {
4269
- console.error("Template route error:", err);
4270
4210
  response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
4271
4211
  }
4272
4212
  };
@@ -4348,10 +4288,10 @@ import path11 from "path";
4348
4288
  import { normalizePath as normalizePath9 } from "vite";
4349
4289
 
4350
4290
  // src/api/project.ts
4351
- import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4291
+ import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
4352
4292
  var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
4353
4293
  async function fetchProjectByName(accountId, projectName) {
4354
- return (await hsCliHttp9.get(accountId, {
4294
+ return (await hsCliHttp11.get(accountId, {
4355
4295
  url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
4356
4296
  })).data;
4357
4297
  }
@@ -4969,7 +4909,7 @@ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
4969
4909
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from "@hubspot/local-dev-lib/constants/auth";
4970
4910
 
4971
4911
  // src/proxyPage/fetchDomains.ts
4972
- import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4912
+ import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
4973
4913
 
4974
4914
  // src/lib/errors.ts
4975
4915
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -5027,7 +4967,7 @@ function handleSecretsError(error) {
5027
4967
  // src/proxyPage/fetchDomains.ts
5028
4968
  async function fetchDomains(portalId) {
5029
4969
  try {
5030
- const result = (await hsCliHttp10.get(portalId, {
4970
+ const result = (await hsCliHttp12.get(portalId, {
5031
4971
  url: `/cms/v3/domains`,
5032
4972
  params: { portalId },
5033
4973
  responseType: "json"
@@ -5053,7 +4993,7 @@ async function fetchWebsiteDomainNames(portalId) {
5053
4993
  import path14 from "path";
5054
4994
  import fs5 from "fs";
5055
4995
  import select from "@inquirer/select";
5056
- import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
4996
+ import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
5057
4997
  var HSPROJECT_JSON = "hsproject.json";
5058
4998
  function checkFileExists(filePath) {
5059
4999
  return fs5.existsSync(filePath) && fs5.statSync(filePath).isFile();
@@ -5087,7 +5027,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5087
5027
  const { platformVersion } = hsProjectJSONData;
5088
5028
  let platformVersionResult;
5089
5029
  try {
5090
- platformVersionResult = (await hsCliHttp11.get(portalId, {
5030
+ platformVersionResult = (await hsCliHttp13.get(portalId, {
5091
5031
  url: `developer/projects/v1/platformVersion`,
5092
5032
  responseType: "json"
5093
5033
  })).data;
@@ -5127,7 +5067,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5127
5067
  }
5128
5068
 
5129
5069
  // src/createDevServer.ts
5130
- import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5070
+ import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
5131
5071
 
5132
5072
  // ../cms-js-internal/dist/buildFieldsTypes.js
5133
5073
  import { writeFileSync } from "fs";
@@ -5648,7 +5588,7 @@ Local proxy functionality and module preview routes will not work without settin
5648
5588
  }
5649
5589
  let authedHublet;
5650
5590
  try {
5651
- const accountInformation = (await hsCliHttp12.get(authedPortalId, {
5591
+ const accountInformation = (await hsCliHttp14.get(authedPortalId, {
5652
5592
  url: "/account-info/v3/details"
5653
5593
  })).data;
5654
5594
  authedHublet = accountInformation.dataHostingLocation;
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-BaJjNBFd.js
1
+ // ../cms-js-internal/dist/types-BsFs0N9P.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -175,7 +175,7 @@ function resolveIslandPlugin(islandsSet) {
175
175
  idWithNoParam,
176
176
  componentExtension
177
177
  );
178
- const modulePath = path.relative(viteRoot, idWithNoParam);
178
+ const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
179
179
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
180
180
  if (islandsSet) {
181
181
  islandsSet.add(moduleId);
@@ -386,14 +386,12 @@ var GATES = [
386
386
  "CMS:JSRenderer:RemoveCjsPlugin",
387
387
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
388
388
  "CMS:JSRenderer:AnalyzeCmsModules",
389
- "CMS:JSRenderer:StripNullBytes",
390
- "PortalsAccessIdentity:DesignManager:UrlSigning"
389
+ "CMS:JSRenderer:StripNullBytes"
391
390
  ];
392
391
  var ENABLED_FEATURES_GATE_MAP = {
393
392
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
394
393
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
395
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
396
- "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
394
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
397
395
  };
398
396
  function isUngatedFor(gates, gate) {
399
397
  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-BaJjNBFd.js
857
+ // ../cms-js-internal/dist/types-BsFs0N9P.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";
@@ -969,7 +969,7 @@ function resolveIslandPlugin(islandsSet) {
969
969
  idWithNoParam,
970
970
  componentExtension
971
971
  );
972
- const modulePath = path3.relative(viteRoot, idWithNoParam);
972
+ const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
973
973
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
974
974
  if (islandsSet) {
975
975
  islandsSet.add(moduleId);
@@ -1091,8 +1091,7 @@ 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",
1095
- "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
1094
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
1096
1095
  };
1097
1096
  function isUngatedFor(gates, gate) {
1098
1097
  return gates.includes(gate);
@@ -2198,7 +2197,7 @@ function trackUsage(action) {
2198
2197
  eventName: EVENT_NAME,
2199
2198
  action,
2200
2199
  nodeVersion: getNodeVersionData(),
2201
- version: "1.2.28",
2200
+ version: "1.2.17",
2202
2201
  os: getPlatform()
2203
2202
  };
2204
2203
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -3479,51 +3478,8 @@ import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
3479
3478
  import { getConfigAccountIfExists as getConfigAccountIfExists4 } from "@hubspot/local-dev-lib/config";
3480
3479
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
3481
3480
  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
- }
3525
3481
  var { JSDOM } = jsdom;
3526
- async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue, gates) {
3482
+ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv, cookieValue) {
3527
3483
  const moduleInfoQueryParams = new URLSearchParams({
3528
3484
  portalId: `${authedPortalId}`
3529
3485
  });
@@ -3538,6 +3494,8 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3538
3494
  "User-Agent": "HubSpot CMS Dev Server"
3539
3495
  }
3540
3496
  })).data;
3497
+ const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
3498
+ process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot`;
3541
3499
  const queryParams = new URLSearchParams({
3542
3500
  portalId: `${authedPortalId}`,
3543
3501
  hsLocalProxy: `${true}`,
@@ -3545,34 +3503,20 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3545
3503
  hsLoginVerifyDisabled: `${true}`,
3546
3504
  module_id: moduleInfo.moduleId
3547
3505
  });
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
- }
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"
3575
3514
  }
3515
+ })).data;
3516
+ if (currentHubApiDomainOverride) {
3517
+ process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
3518
+ } else {
3519
+ delete process.env.HUBAPI_DOMAIN_OVERRIDE;
3576
3520
  }
3577
3521
  const dom = new JSDOM(modulePreviewHtml);
3578
3522
  const modulePreviewContent = dom.window.document.querySelector(
@@ -3815,8 +3759,7 @@ var partialRouteHandler = async (request, response) => {
3815
3759
  remoteModule.path,
3816
3760
  authedPortalId,
3817
3761
  authedEnv,
3818
- request.get("COOKIE"),
3819
- jsRenderingGates
3762
+ request.get("COOKIE")
3820
3763
  ).then((result) => ({
3821
3764
  remoteModule,
3822
3765
  result
@@ -4703,27 +4646,21 @@ ${e.stack}`);
4703
4646
  var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
4704
4647
 
4705
4648
  // src/routes/hublModuleRouteHandler.ts
4649
+ import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4706
4650
  var hublModuleRouteHandler = async (request, response) => {
4707
4651
  sendTrackingRequest("view-hubl-module-route");
4708
- const { authedPortalId, localPreviewToken, projectName, jsRenderingGates } = request.app.locals;
4652
+ const { authedPortalId, localPreviewToken } = request.app.locals;
4709
4653
  const { modulePath } = request.params;
4710
4654
  if (!modulePath) {
4711
4655
  response.status(200).set({ "Content-Type": "text/html" }).end(buildModuleIndex());
4712
4656
  return;
4713
4657
  }
4714
- const projectPrefix = projectName ? "@projects/" : "";
4715
- const calculatedPath = `@preview/${localPreviewToken}/${projectPrefix}${modulePath}.module`;
4658
+ const calculatedPath = `@preview/${localPreviewToken}/@projects/${modulePath}.module`;
4716
4659
  let customWidgetInfo;
4717
4660
  try {
4718
4661
  customWidgetInfo = await fetchModuleByPath(authedPortalId, calculatedPath);
4719
4662
  } catch (err) {
4720
- console.error(`Failed to fetch module data for ${calculatedPath}: ${err}`);
4721
- response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(err));
4722
- return;
4723
- }
4724
- if (!customWidgetInfo || !("moduleId" in customWidgetInfo)) {
4725
- response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex(null));
4726
- return;
4663
+ console.log(`Failed to fetch module data for ${calculatedPath}`);
4727
4664
  }
4728
4665
  const params = {
4729
4666
  module_id: customWidgetInfo.moduleId,
@@ -4731,9 +4668,13 @@ var hublModuleRouteHandler = async (request, response) => {
4731
4668
  updated: Date.now(),
4732
4669
  ...request.query
4733
4670
  };
4734
- const previewUrl = getPreviewUrl(request, params);
4671
+ const previewUrl = new URL(getPreviewUrl(request, params));
4735
4672
  try {
4736
- const result = await signedGet(authedPortalId, previewUrl, {}, jsRenderingGates);
4673
+ const result = (await hsCliHttp9.get(authedPortalId, {
4674
+ baseURL: previewUrl.origin,
4675
+ url: previewUrl.pathname,
4676
+ params
4677
+ })).data;
4737
4678
  const html = addRefreshScript(result);
4738
4679
  response.status(200).set({ "Content-Type": "text/html" }).end(html);
4739
4680
  } catch (err) {
@@ -4755,6 +4696,7 @@ var buildModuleIndex = () => buildHTMLResponse(`
4755
4696
  `);
4756
4697
 
4757
4698
  // src/routes/hublTemplateRouteHandler.ts
4699
+ import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
4758
4700
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
4759
4701
  import { getConfigAccountEnvironment } from "@hubspot/local-dev-lib/config";
4760
4702
  var HUBSPOT_PREVIEW_BASE_TAG_REGEX = /<base\s+[^>]*href=["'][^"']*(?:hubspotpreview(?:qa)?)[^"']*["'][^>]*>/i;
@@ -4805,15 +4747,14 @@ var templateRouteHandler = async (request, response) => {
4805
4747
  hsCacheBuster: Date.now().toString(),
4806
4748
  ...request.query
4807
4749
  };
4808
- const previewUrl = getPreviewUrl(request, params);
4750
+ const previewUrl = new URL(getPreviewUrl(request, params));
4809
4751
  const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
4810
4752
  try {
4811
- const result = await signedGet(
4812
- authedPortalId,
4813
- previewUrl,
4814
- {},
4815
- jsRenderingGates
4816
- );
4753
+ const result = (await hsCliHttp10.get(authedPortalId, {
4754
+ baseURL: previewUrl.origin,
4755
+ url: previewUrl.pathname,
4756
+ params
4757
+ })).data;
4817
4758
  const pageHtml = addRefreshScript(result);
4818
4759
  const finalHtml = pageHtml.replace(
4819
4760
  HUBSPOT_PREVIEW_BASE_TAG_REGEX,
@@ -4832,7 +4773,6 @@ var templateRouteHandler = async (request, response) => {
4832
4773
  false
4833
4774
  );
4834
4775
  } catch (err) {
4835
- console.error("Template route error:", err);
4836
4776
  response.status(500).set({ "Content-Type": "text/html" }).end(buildErrorIndex2());
4837
4777
  }
4838
4778
  };
@@ -4914,10 +4854,10 @@ import path12 from "path";
4914
4854
  import { normalizePath as normalizePath9 } from "vite";
4915
4855
 
4916
4856
  // src/api/project.ts
4917
- import { http as hsCliHttp9 } from "@hubspot/local-dev-lib/http";
4857
+ import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
4918
4858
  var DEVELOPER_PROJECTS_API_PATH = "/developer/projects/v1";
4919
4859
  async function fetchProjectByName(accountId, projectName) {
4920
- return (await hsCliHttp9.get(accountId, {
4860
+ return (await hsCliHttp11.get(accountId, {
4921
4861
  url: `${DEVELOPER_PROJECTS_API_PATH}/by-name/${projectName}`
4922
4862
  })).data;
4923
4863
  }
@@ -5638,7 +5578,7 @@ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
5638
5578
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from "@hubspot/local-dev-lib/constants/auth";
5639
5579
 
5640
5580
  // src/proxyPage/fetchDomains.ts
5641
- import { http as hsCliHttp10 } from "@hubspot/local-dev-lib/http";
5581
+ import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5642
5582
 
5643
5583
  // src/lib/errors.ts
5644
5584
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -5696,7 +5636,7 @@ function handleSecretsError(error) {
5696
5636
  // src/proxyPage/fetchDomains.ts
5697
5637
  async function fetchDomains(portalId) {
5698
5638
  try {
5699
- const result = (await hsCliHttp10.get(portalId, {
5639
+ const result = (await hsCliHttp12.get(portalId, {
5700
5640
  url: `/cms/v3/domains`,
5701
5641
  params: { portalId },
5702
5642
  responseType: "json"
@@ -5722,7 +5662,7 @@ async function fetchWebsiteDomainNames(portalId) {
5722
5662
  import path15 from "path";
5723
5663
  import fs6 from "fs";
5724
5664
  import select from "@inquirer/select";
5725
- import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
5665
+ import { http as hsCliHttp13 } from "@hubspot/local-dev-lib/http";
5726
5666
  var HSPROJECT_JSON = "hsproject.json";
5727
5667
  function checkFileExists(filePath) {
5728
5668
  return fs6.existsSync(filePath) && fs6.statSync(filePath).isFile();
@@ -5756,7 +5696,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5756
5696
  const { platformVersion } = hsProjectJSONData;
5757
5697
  let platformVersionResult;
5758
5698
  try {
5759
- platformVersionResult = (await hsCliHttp11.get(portalId, {
5699
+ platformVersionResult = (await hsCliHttp13.get(portalId, {
5760
5700
  url: `developer/projects/v1/platformVersion`,
5761
5701
  responseType: "json"
5762
5702
  })).data;
@@ -5796,7 +5736,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
5796
5736
  }
5797
5737
 
5798
5738
  // src/createDevServer.ts
5799
- import { http as hsCliHttp12 } from "@hubspot/local-dev-lib/http";
5739
+ import { http as hsCliHttp14 } from "@hubspot/local-dev-lib/http";
5800
5740
 
5801
5741
  // ../cms-js-internal/dist/buildFieldsTypes.js
5802
5742
  import { writeFileSync } from "fs";
@@ -6317,7 +6257,7 @@ Local proxy functionality and module preview routes will not work without settin
6317
6257
  }
6318
6258
  let authedHublet;
6319
6259
  try {
6320
- const accountInformation = (await hsCliHttp12.get(authedPortalId, {
6260
+ const accountInformation = (await hsCliHttp14.get(authedPortalId, {
6321
6261
  url: "/account-info/v3/details"
6322
6262
  })).data;
6323
6263
  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-BaJjNBFd.js
4
+ // ../cms-js-internal/dist/types-BsFs0N9P.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-BaJjNBFd.js
11
+ // ../cms-js-internal/dist/types-BsFs0N9P.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -132,7 +132,7 @@ function resolveIslandPlugin(islandsSet) {
132
132
  idWithNoParam,
133
133
  componentExtension
134
134
  );
135
- const modulePath = path.relative(viteRoot, idWithNoParam);
135
+ const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
136
136
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
137
137
  if (islandsSet) {
138
138
  islandsSet.add(moduleId);
@@ -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_BaJjNBFd = __esm({
382
- "../cms-js-internal/dist/types-BaJjNBFd.js"() {
381
+ var init_types_BsFs0N9P = __esm({
382
+ "../cms-js-internal/dist/types-BsFs0N9P.js"() {
383
383
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
384
384
  ENTRY_POINTS_PATH = "components/partials/";
385
385
  MODULE_FOLDER_PATH = "components/modules/";
@@ -501,14 +501,12 @@ ${groupEnd}</script>
501
501
  "CMS:JSRenderer:RemoveCjsPlugin",
502
502
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
503
503
  "CMS:JSRenderer:AnalyzeCmsModules",
504
- "CMS:JSRenderer:StripNullBytes",
505
- "PortalsAccessIdentity:DesignManager:UrlSigning"
504
+ "CMS:JSRenderer:StripNullBytes"
506
505
  ];
507
506
  ENABLED_FEATURES_GATE_MAP = {
508
507
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
509
508
  "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
510
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
511
- "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
509
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
512
510
  };
513
511
  findAllComponentsIn = (webRoot2, componentsFolder) => {
514
512
  const fullComponentsFolderPath = join(webRoot2, componentsFolder);
@@ -1173,8 +1171,8 @@ function GlobalPartialSlot(props) {
1173
1171
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1174
1172
  var init_dist = __esm({
1175
1173
  "../cms-js-internal/dist/index.js"() {
1176
- init_types_BaJjNBFd();
1177
- init_types_BaJjNBFd();
1174
+ init_types_BsFs0N9P();
1175
+ init_types_BsFs0N9P();
1178
1176
  ({ setProperty, getProperty, hasProperty } = dotProp);
1179
1177
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1180
1178
  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.28",
3
+ "version": "1.2.31",
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.28",
32
+ "@hubspot/cms-components": "^1.2.31",
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": "56958bf86fbcf8a1213a8e64f0617292873f71c0"
136
+ "gitHead": "c06c00177fa1c64b62e019604ef13eb41f95f14e"
137
137
  }
@@ -1,7 +1,4 @@
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<{
1
+ export declare function renderRemoteModulePreview(modulePath: string, authedPortalId: any, authedEnv: any, cookieValue: any): Promise<{
5
2
  html: string;
6
3
  cssNeeded: string;
7
4
  }>;