@hubspot/cms-dev-server 1.2.26 → 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.
- package/dist/app/assets/{index-CEoO7aJ5.js → index-tvg7JxpD.js} +28 -28
- package/dist/app/index.html +1 -1
- package/dist/generateJsonFromJsx.js +2 -2
- package/dist/index.js +97 -44
- package/dist/internalSsr.js +6 -4
- package/dist/run.js +97 -44
- package/dist/storybook/index.js +1 -1
- package/dist/storybook-main/main.js +10 -8
- package/package.json +3 -3
- package/types/lib/renderModulePreview.d.ts +4 -1
- package/dist/.DS_Store +0 -0
- package/types/constants/errors.d.ts +0 -5
- package/types/createAppViteConfig.d.ts +0 -2
- package/types/lib/cli.d.ts +0 -22
- package/types/lib/constants.d.ts +0 -1
- package/types/routes/api.d.ts +0 -2
- package/types/routes/appServerApiRouteHandler.d.ts +0 -5
- package/types/routes/appServerRoutes.d.ts +0 -5
- package/types/routes/createAppServerRoutes.d.ts +0 -5
- package/types/routes/homeRouteHandler.d.ts +0 -3
- package/types/storybook-main/preview.d.ts +0 -9
package/dist/app/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>CMS React Dev Server Home</title>
|
|
7
7
|
<!--app-head-->
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-tvg7JxpD.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-PcyCbkys.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -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-
|
|
13
|
+
// ../cms-js-internal/dist/types-BaJjNBFd.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 =
|
|
34
|
+
const modulePath = path.relative(viteRoot, idWithNoParam);
|
|
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-
|
|
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";
|
|
@@ -118,7 +118,7 @@ function resolveIslandPlugin(islandsSet) {
|
|
|
118
118
|
idWithNoParam,
|
|
119
119
|
componentExtension
|
|
120
120
|
);
|
|
121
|
-
const modulePath =
|
|
121
|
+
const modulePath = path.relative(viteRoot, idWithNoParam);
|
|
122
122
|
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
123
123
|
if (islandsSet) {
|
|
124
124
|
islandsSet.add(moduleId);
|
|
@@ -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.
|
|
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
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
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 =
|
|
4168
|
+
const previewUrl = getPreviewUrl(request, params);
|
|
4113
4169
|
try {
|
|
4114
|
-
const result =
|
|
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 =
|
|
4242
|
+
const previewUrl = getPreviewUrl(request, params);
|
|
4192
4243
|
const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
|
|
4193
4244
|
try {
|
|
4194
|
-
const result =
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
5651
|
+
const accountInformation = (await hsCliHttp12.get(authedPortalId, {
|
|
5599
5652
|
url: "/account-info/v3/details"
|
|
5600
5653
|
})).data;
|
|
5601
5654
|
authedHublet = accountInformation.dataHostingLocation;
|
package/dist/internalSsr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../cms-js-internal/dist/types-
|
|
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";
|
|
@@ -175,7 +175,7 @@ function resolveIslandPlugin(islandsSet) {
|
|
|
175
175
|
idWithNoParam,
|
|
176
176
|
componentExtension
|
|
177
177
|
);
|
|
178
|
-
const modulePath =
|
|
178
|
+
const modulePath = path.relative(viteRoot, idWithNoParam);
|
|
179
179
|
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
180
180
|
if (islandsSet) {
|
|
181
181
|
islandsSet.add(moduleId);
|
|
@@ -386,12 +386,14 @@ var GATES = [
|
|
|
386
386
|
"CMS:JSRenderer:RemoveCjsPlugin",
|
|
387
387
|
"CMS:JSRenderer:RemoveMockClientEntryPlugin",
|
|
388
388
|
"CMS:JSRenderer:AnalyzeCmsModules",
|
|
389
|
-
"CMS:JSRenderer:
|
|
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-
|
|
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";
|
|
@@ -969,7 +969,7 @@ function resolveIslandPlugin(islandsSet) {
|
|
|
969
969
|
idWithNoParam,
|
|
970
970
|
componentExtension
|
|
971
971
|
);
|
|
972
|
-
const modulePath =
|
|
972
|
+
const modulePath = path3.relative(viteRoot, idWithNoParam);
|
|
973
973
|
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
974
974
|
if (islandsSet) {
|
|
975
975
|
islandsSet.add(moduleId);
|
|
@@ -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.
|
|
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
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
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 =
|
|
4734
|
+
const previewUrl = getPreviewUrl(request, params);
|
|
4679
4735
|
try {
|
|
4680
|
-
const result =
|
|
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 =
|
|
4808
|
+
const previewUrl = getPreviewUrl(request, params);
|
|
4758
4809
|
const fullOriginalUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`;
|
|
4759
4810
|
try {
|
|
4760
|
-
const result =
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
6320
|
+
const accountInformation = (await hsCliHttp12.get(authedPortalId, {
|
|
6268
6321
|
url: "/account-info/v3/details"
|
|
6269
6322
|
})).data;
|
|
6270
6323
|
authedHublet = accountInformation.dataHostingLocation;
|
package/dist/storybook/index.js
CHANGED