@backstage/integration 1.8.0 → 1.9.0-next.1

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,27 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.9.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d898f7: All single-line secrets read from config will now have both leading and trailing whitespace trimmed. This is done to ensure that the secrets are always valid HTTP header values, since many fetch implementations will include the header value itself when an error is thrown due to invalid header values.
8
+ - 1cae748: Updated dependency `git-url-parse` to `^14.0.0`.
9
+ - Updated dependencies
10
+ - @backstage/config@1.1.1
11
+ - @backstage/errors@1.2.3
12
+
13
+ ## 1.9.0-next.0
14
+
15
+ ### Minor Changes
16
+
17
+ - e27b7f3: Fix rate limit detection by looking for HTTP status code 429 and updating the header `x-ratelimit-remaining` to look for in case of a 403 code is returned
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+ - @backstage/config@1.1.1
23
+ - @backstage/errors@1.2.3
24
+
3
25
  ## 1.8.0
4
26
 
5
27
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -74,7 +74,7 @@ function defaultScmResolveUrl(options) {
74
74
 
75
75
  const AMAZON_AWS_HOST = "amazonaws.com";
76
76
  function readAwsS3IntegrationConfig(config) {
77
- var _a;
77
+ var _a, _b;
78
78
  const endpoint = config.getOptionalString("endpoint");
79
79
  const s3ForcePathStyle = (_a = config.getOptionalBoolean("s3ForcePathStyle")) != null ? _a : false;
80
80
  let host;
@@ -98,7 +98,7 @@ function readAwsS3IntegrationConfig(config) {
98
98
  host = AMAZON_AWS_HOST;
99
99
  }
100
100
  const accessKeyId = config.getOptionalString("accessKeyId");
101
- const secretAccessKey = config.getOptionalString("secretAccessKey");
101
+ const secretAccessKey = (_b = config.getOptionalString("secretAccessKey")) == null ? void 0 : _b.trim();
102
102
  const roleArn = config.getOptionalString("roleArn");
103
103
  const externalId = config.getOptionalString("externalId");
104
104
  return {
@@ -381,21 +381,20 @@ function asAzureDevOpsCredential(credential) {
381
381
  throw new Error("is not a valid credential");
382
382
  }
383
383
  function readAzureIntegrationConfig(config) {
384
- var _a, _b, _c, _d;
384
+ var _a, _b, _c, _d, _e, _f, _g;
385
385
  const host = (_a = config.getOptionalString("host")) != null ? _a : AZURE_HOST;
386
386
  let credentialConfigs = (_b = config.getOptionalConfigArray("credentials")) == null ? void 0 : _b.map((credential) => {
387
+ var _a2, _b2;
387
388
  const result = {
388
389
  organizations: credential.getOptionalStringArray("organizations"),
389
- personalAccessToken: credential.getOptionalString(
390
- "personalAccessToken"
391
- ),
390
+ personalAccessToken: (_a2 = credential.getOptionalString("personalAccessToken")) == null ? void 0 : _a2.trim(),
392
391
  tenantId: credential.getOptionalString("tenantId"),
393
392
  clientId: credential.getOptionalString("clientId"),
394
- clientSecret: credential.getOptionalString("clientSecret")
393
+ clientSecret: (_b2 = credential.getOptionalString("clientSecret")) == null ? void 0 : _b2.trim()
395
394
  };
396
395
  return result;
397
396
  });
398
- const token = config.getOptionalString("token");
397
+ const token = (_c = config.getOptionalString("token")) == null ? void 0 : _c.trim();
399
398
  if (config.getOptional("credential") !== void 0 && config.getOptional("credentials") !== void 0) {
400
399
  throw new Error(
401
400
  `Invalid Azure integration config, 'credential' and 'credentials' cannot be used together. Use 'credentials' instead.`
@@ -408,7 +407,7 @@ function readAzureIntegrationConfig(config) {
408
407
  }
409
408
  if (token !== void 0) {
410
409
  const mapped = [{ personalAccessToken: token }];
411
- credentialConfigs = (_c = credentialConfigs == null ? void 0 : credentialConfigs.concat(mapped)) != null ? _c : mapped;
410
+ credentialConfigs = (_d = credentialConfigs == null ? void 0 : credentialConfigs.concat(mapped)) != null ? _d : mapped;
412
411
  }
413
412
  if (config.getOptional("credential") !== void 0) {
414
413
  const mapped = [
@@ -416,13 +415,13 @@ function readAzureIntegrationConfig(config) {
416
415
  organizations: config.getOptionalStringArray(
417
416
  "credential.organizations"
418
417
  ),
419
- token: config.getOptionalString("credential.token"),
418
+ token: (_e = config.getOptionalString("credential.token")) == null ? void 0 : _e.trim(),
420
419
  tenantId: config.getOptionalString("credential.tenantId"),
421
420
  clientId: config.getOptionalString("credential.clientId"),
422
- clientSecret: config.getOptionalString("credential.clientSecret")
421
+ clientSecret: (_f = config.getOptionalString("credential.clientSecret")) == null ? void 0 : _f.trim()
423
422
  }
424
423
  ];
425
- credentialConfigs = (_d = credentialConfigs == null ? void 0 : credentialConfigs.concat(mapped)) != null ? _d : mapped;
424
+ credentialConfigs = (_g = credentialConfigs == null ? void 0 : credentialConfigs.concat(mapped)) != null ? _g : mapped;
426
425
  }
427
426
  if (!isValidHost(host)) {
428
427
  throw new Error(
@@ -743,12 +742,12 @@ async function getAzureRequestOptions(config, additionalHeaders) {
743
742
  const BITBUCKET_HOST = "bitbucket.org";
744
743
  const BITBUCKET_API_BASE_URL = "https://api.bitbucket.org/2.0";
745
744
  function readBitbucketIntegrationConfig(config) {
746
- var _a;
745
+ var _a, _b, _c;
747
746
  const host = (_a = config.getOptionalString("host")) != null ? _a : BITBUCKET_HOST;
748
747
  let apiBaseUrl = config.getOptionalString("apiBaseUrl");
749
- const token = config.getOptionalString("token");
748
+ const token = (_b = config.getOptionalString("token")) == null ? void 0 : _b.trim();
750
749
  const username = config.getOptionalString("username");
751
- const appPassword = config.getOptionalString("appPassword");
750
+ const appPassword = (_c = config.getOptionalString("appPassword")) == null ? void 0 : _c.trim();
752
751
  if (!isValidHost(host)) {
753
752
  throw new Error(
754
753
  `Invalid Bitbucket integration config, '${host}' is not a valid host`
@@ -924,10 +923,11 @@ function getBitbucketRequestOptions(config) {
924
923
  const BITBUCKET_CLOUD_HOST = "bitbucket.org";
925
924
  const BITBUCKET_CLOUD_API_BASE_URL = "https://api.bitbucket.org/2.0";
926
925
  function readBitbucketCloudIntegrationConfig(config) {
926
+ var _a;
927
927
  const host = BITBUCKET_CLOUD_HOST;
928
928
  const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;
929
929
  const username = config.getString("username");
930
- const appPassword = config.getString("appPassword");
930
+ const appPassword = (_a = config.getString("appPassword")) == null ? void 0 : _a.trim();
931
931
  return {
932
932
  host,
933
933
  apiBaseUrl,
@@ -1060,9 +1060,10 @@ function getBitbucketCloudRequestOptions(config) {
1060
1060
  }
1061
1061
 
1062
1062
  function readBitbucketServerIntegrationConfig(config) {
1063
+ var _a;
1063
1064
  const host = config.getString("host");
1064
1065
  let apiBaseUrl = config.getOptionalString("apiBaseUrl");
1065
- const token = config.getOptionalString("token");
1066
+ const token = (_a = config.getOptionalString("token")) == null ? void 0 : _a.trim();
1066
1067
  const username = config.getOptionalString("username");
1067
1068
  const password = config.getOptionalString("password");
1068
1069
  if (!isValidHost(host)) {
@@ -1195,12 +1196,13 @@ function getBitbucketServerRequestOptions(config) {
1195
1196
  }
1196
1197
 
1197
1198
  function readGerritIntegrationConfig(config) {
1199
+ var _a;
1198
1200
  const host = config.getString("host");
1199
1201
  let baseUrl = config.getOptionalString("baseUrl");
1200
1202
  let cloneUrl = config.getOptionalString("cloneUrl");
1201
1203
  let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
1202
1204
  const username = config.getOptionalString("username");
1203
- const password = config.getOptionalString("password");
1205
+ const password = (_a = config.getOptionalString("password")) == null ? void 0 : _a.trim();
1204
1206
  if (!isValidHost(host)) {
1205
1207
  throw new Error(
1206
1208
  `Invalid Gerrit integration config, '${host}' is not a valid host`
@@ -1401,10 +1403,11 @@ __publicField$7(_GerritIntegration, "factory", ({ config }) => {
1401
1403
  let GerritIntegration = _GerritIntegration;
1402
1404
 
1403
1405
  function readGiteaConfig(config) {
1406
+ var _a;
1404
1407
  const host = config.getString("host");
1405
1408
  let baseUrl = config.getOptionalString("baseUrl");
1406
1409
  const username = config.getOptionalString("username");
1407
- const password = config.getOptionalString("password");
1410
+ const password = (_a = config.getOptionalString("password")) == null ? void 0 : _a.trim();
1408
1411
  if (!isValidHost(host)) {
1409
1412
  throw new Error(
1410
1413
  `Invalid Gitea integration config, '${host}' is not a valid host`
@@ -1512,12 +1515,12 @@ const GITHUB_HOST = "github.com";
1512
1515
  const GITHUB_API_BASE_URL = "https://api.github.com";
1513
1516
  const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
1514
1517
  function readGithubIntegrationConfig(config) {
1515
- var _a, _b;
1518
+ var _a, _b, _c;
1516
1519
  const host = (_a = config.getOptionalString("host")) != null ? _a : GITHUB_HOST;
1517
1520
  let apiBaseUrl = config.getOptionalString("apiBaseUrl");
1518
1521
  let rawBaseUrl = config.getOptionalString("rawBaseUrl");
1519
- const token = config.getOptionalString("token");
1520
- const apps = (_b = config.getOptionalConfigArray("apps")) == null ? void 0 : _b.map((c) => ({
1522
+ const token = (_b = config.getOptionalString("token")) == null ? void 0 : _b.trim();
1523
+ const apps = (_c = config.getOptionalConfigArray("apps")) == null ? void 0 : _c.map((c) => ({
1521
1524
  appId: c.getNumber("appId"),
1522
1525
  clientId: c.getString("clientId"),
1523
1526
  clientSecret: c.getString("clientSecret"),
@@ -1878,6 +1881,11 @@ const _GithubIntegration = class _GithubIntegration {
1878
1881
  resolveEditUrl(url) {
1879
1882
  return replaceGithubUrlType(url, "edit");
1880
1883
  }
1884
+ parseRateLimitInfo(response) {
1885
+ return {
1886
+ isRateLimited: response.status === 429 || response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0"
1887
+ };
1888
+ }
1881
1889
  };
1882
1890
  __publicField$4(_GithubIntegration, "factory", ({ config }) => {
1883
1891
  var _a;
@@ -1922,9 +1930,10 @@ const replaceGitHubUrlType = replaceGithubUrlType;
1922
1930
  const GITLAB_HOST = "gitlab.com";
1923
1931
  const GITLAB_API_BASE_URL = "https://gitlab.com/api/v4";
1924
1932
  function readGitLabIntegrationConfig(config) {
1933
+ var _a;
1925
1934
  const host = config.getString("host");
1926
1935
  let apiBaseUrl = config.getOptionalString("apiBaseUrl");
1927
- const token = config.getOptionalString("token");
1936
+ const token = (_a = config.getOptionalString("token")) == null ? void 0 : _a.trim();
1928
1937
  let baseUrl = config.getOptionalString("baseUrl");
1929
1938
  if (apiBaseUrl) {
1930
1939
  apiBaseUrl = lodash.trimEnd(apiBaseUrl, "/");