@backstage/integration 1.2.2-next.3 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 9de15a41d7: Upgrade @octokit/rest to 19.0.3
8
+ - a70869e775: Updated dependency `msw` to `^0.43.0`.
9
+ - 4e9a90e307: Updated dependency `luxon` to `^3.0.0`.
10
+ - 8006d0f9bf: Updated dependency `msw` to `^0.44.0`.
11
+ - 1f29047bad: Updated dependency `@octokit/auth-app` to `^4.0.0`.
12
+ - e2d7b76f43: Upgrade git-url-parse to 12.0.0.
13
+
14
+ Motivation for upgrade is transitively upgrading parse-url which is vulnerable
15
+ to several CVEs detected by Snyk.
16
+
17
+ - SNYK-JS-PARSEURL-2935944
18
+ - SNYK-JS-PARSEURL-2935947
19
+ - SNYK-JS-PARSEURL-2936249
20
+
21
+ - 8829e175f2: Allow frontend visibility for `integrations` itself.
22
+ - 954a94f52f: Support self-hosted gitlab installations with relative URL.
23
+ - 4df3390795: Avoid double encoding of the file path in `getBitbucketServerDownloadUrl`
24
+ - Updated dependencies
25
+ - @backstage/errors@1.1.0
26
+
3
27
  ## 1.2.2-next.3
4
28
 
5
29
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -1047,7 +1047,7 @@ class GithubAppManager {
1047
1047
  auth: result.data.token
1048
1048
  });
1049
1049
  const repos = await installationClient.paginate(installationClient.apps.listReposAccessibleToInstallation);
1050
- const hasRepo = repos.some((repository) => {
1050
+ const hasRepo = repos.repositories.some((repository) => {
1051
1051
  return repository.name === repo;
1052
1052
  });
1053
1053
  if (!hasRepo) {
@@ -1227,11 +1227,18 @@ function readGitLabIntegrationConfigs(configs) {
1227
1227
  }
1228
1228
  return result;
1229
1229
  }
1230
+ function getGitLabIntegrationRelativePath(config) {
1231
+ let relativePath = "";
1232
+ if (config.host !== GITLAB_HOST) {
1233
+ relativePath = new URL(config.baseUrl).pathname;
1234
+ }
1235
+ return lodash.trimEnd(relativePath, "/");
1236
+ }
1230
1237
 
1231
1238
  async function getGitLabFileFetchUrl(url, config) {
1232
1239
  if (url.includes("/-/blob/")) {
1233
1240
  const projectID = await getProjectId(url, config);
1234
- return buildProjectUrl(url, projectID).toString();
1241
+ return buildProjectUrl(url, projectID, config).toString();
1235
1242
  }
1236
1243
  return buildRawUrl(url).toString();
1237
1244
  }
@@ -1262,13 +1269,15 @@ function buildRawUrl(target) {
1262
1269
  throw new errors.InputError(`Incorrect url: ${target}, ${e}`);
1263
1270
  }
1264
1271
  }
1265
- function buildProjectUrl(target, projectID) {
1272
+ function buildProjectUrl(target, projectID, config) {
1266
1273
  try {
1267
1274
  const url = new URL(target);
1268
1275
  const branchAndFilePath = url.pathname.split("/-/blob/")[1];
1269
1276
  const [branch, ...filePath] = branchAndFilePath.split("/");
1277
+ const relativePath = getGitLabIntegrationRelativePath(config);
1270
1278
  url.pathname = [
1271
- "/api/v4/projects",
1279
+ ...relativePath ? [relativePath] : [],
1280
+ "api/v4/projects",
1272
1281
  projectID,
1273
1282
  "repository/files",
1274
1283
  encodeURIComponent(decodeURIComponent(filePath.join("/"))),
@@ -1286,8 +1295,12 @@ async function getProjectId(target, config) {
1286
1295
  throw new Error("Please provide full path to yaml file from GitLab");
1287
1296
  }
1288
1297
  try {
1289
- const repo = url.pathname.split("/-/blob/")[0];
1290
- const repoIDLookup = new URL(`${url.origin}/api/v4/projects/${encodeURIComponent(repo.replace(/^\//, ""))}`);
1298
+ let repo = url.pathname.split("/-/blob/")[0];
1299
+ const relativePath = getGitLabIntegrationRelativePath(config);
1300
+ if (relativePath) {
1301
+ repo = repo.replace(relativePath, "");
1302
+ }
1303
+ const repoIDLookup = new URL(`${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(repo.replace(/^\//, ""))}`);
1291
1304
  const response = await fetch__default["default"](repoIDLookup.toString(), getGitLabRequestOptions(config));
1292
1305
  const data = await response.json();
1293
1306
  if (!response.ok) {
@@ -1443,6 +1456,7 @@ exports.getGerritRequestOptions = getGerritRequestOptions;
1443
1456
  exports.getGitHubFileFetchUrl = getGitHubFileFetchUrl;
1444
1457
  exports.getGitHubRequestOptions = getGitHubRequestOptions;
1445
1458
  exports.getGitLabFileFetchUrl = getGitLabFileFetchUrl;
1459
+ exports.getGitLabIntegrationRelativePath = getGitLabIntegrationRelativePath;
1446
1460
  exports.getGitLabRequestOptions = getGitLabRequestOptions;
1447
1461
  exports.parseGerritGitilesUrl = parseGerritGitilesUrl;
1448
1462
  exports.parseGerritJsonResponse = parseGerritJsonResponse;