@backstage/integration 1.15.1-next.0 → 1.15.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/ScmIntegrations.cjs.js +110 -0
  3. package/dist/ScmIntegrations.cjs.js.map +1 -0
  4. package/dist/awsCodeCommit/AwsCodeCommitIntegration.cjs.js +58 -0
  5. package/dist/awsCodeCommit/AwsCodeCommitIntegration.cjs.js.map +1 -0
  6. package/dist/awsCodeCommit/config.cjs.js +26 -0
  7. package/dist/awsCodeCommit/config.cjs.js.map +1 -0
  8. package/dist/awsS3/AwsS3Integration.cjs.js +38 -0
  9. package/dist/awsS3/AwsS3Integration.cjs.js.map +1 -0
  10. package/dist/awsS3/config.cjs.js +53 -0
  11. package/dist/awsS3/config.cjs.js.map +1 -0
  12. package/dist/azure/AzureIntegration.cjs.js +62 -0
  13. package/dist/azure/AzureIntegration.cjs.js.map +1 -0
  14. package/dist/azure/AzureUrl.cjs.js +189 -0
  15. package/dist/azure/AzureUrl.cjs.js.map +1 -0
  16. package/dist/azure/CachedAzureDevOpsCredentialsProvider.cjs.js +76 -0
  17. package/dist/azure/CachedAzureDevOpsCredentialsProvider.cjs.js.map +1 -0
  18. package/dist/azure/DefaultAzureDevOpsCredentialsProvider.cjs.js +75 -0
  19. package/dist/azure/DefaultAzureDevOpsCredentialsProvider.cjs.js.map +1 -0
  20. package/dist/azure/config.cjs.js +153 -0
  21. package/dist/azure/config.cjs.js.map +1 -0
  22. package/dist/azure/core.cjs.js +18 -0
  23. package/dist/azure/core.cjs.js.map +1 -0
  24. package/dist/azure/deprecated.cjs.js +26 -0
  25. package/dist/azure/deprecated.cjs.js.map +1 -0
  26. package/dist/bitbucket/BitbucketIntegration.cjs.js +65 -0
  27. package/dist/bitbucket/BitbucketIntegration.cjs.js.map +1 -0
  28. package/dist/bitbucket/config.cjs.js +47 -0
  29. package/dist/bitbucket/config.cjs.js.map +1 -0
  30. package/dist/bitbucket/core.cjs.js +95 -0
  31. package/dist/bitbucket/core.cjs.js.map +1 -0
  32. package/dist/bitbucketCloud/BitbucketCloudIntegration.cjs.js +54 -0
  33. package/dist/bitbucketCloud/BitbucketCloudIntegration.cjs.js.map +1 -0
  34. package/dist/bitbucketCloud/config.cjs.js +30 -0
  35. package/dist/bitbucketCloud/config.cjs.js.map +1 -0
  36. package/dist/bitbucketCloud/core.cjs.js +78 -0
  37. package/dist/bitbucketCloud/core.cjs.js.map +1 -0
  38. package/dist/bitbucketServer/BitbucketServerIntegration.cjs.js +48 -0
  39. package/dist/bitbucketServer/BitbucketServerIntegration.cjs.js.map +1 -0
  40. package/dist/bitbucketServer/config.cjs.js +36 -0
  41. package/dist/bitbucketServer/config.cjs.js.map +1 -0
  42. package/dist/bitbucketServer/core.cjs.js +73 -0
  43. package/dist/bitbucketServer/core.cjs.js.map +1 -0
  44. package/dist/gerrit/GerritIntegration.cjs.js +52 -0
  45. package/dist/gerrit/GerritIntegration.cjs.js.map +1 -0
  46. package/dist/gerrit/config.cjs.js +60 -0
  47. package/dist/gerrit/config.cjs.js.map +1 -0
  48. package/dist/gerrit/core.cjs.js +179 -0
  49. package/dist/gerrit/core.cjs.js.map +1 -0
  50. package/dist/gitea/GiteaIntegration.cjs.js +34 -0
  51. package/dist/gitea/GiteaIntegration.cjs.js.map +1 -0
  52. package/dist/gitea/config.cjs.js +34 -0
  53. package/dist/gitea/config.cjs.js.map +1 -0
  54. package/dist/gitea/core.cjs.js +59 -0
  55. package/dist/gitea/core.cjs.js.map +1 -0
  56. package/dist/github/DefaultGithubCredentialsProvider.cjs.js +54 -0
  57. package/dist/github/DefaultGithubCredentialsProvider.cjs.js.map +1 -0
  58. package/dist/github/GithubIntegration.cjs.js +51 -0
  59. package/dist/github/GithubIntegration.cjs.js.map +1 -0
  60. package/dist/github/SingleInstanceGithubCredentialsProvider.cjs.js +211 -0
  61. package/dist/github/SingleInstanceGithubCredentialsProvider.cjs.js.map +1 -0
  62. package/dist/github/config.cjs.js +55 -0
  63. package/dist/github/config.cjs.js.map +1 -0
  64. package/dist/github/core.cjs.js +46 -0
  65. package/dist/github/core.cjs.js.map +1 -0
  66. package/dist/gitlab/DefaultGitlabCredentialsProvider.cjs.js +30 -0
  67. package/dist/gitlab/DefaultGitlabCredentialsProvider.cjs.js.map +1 -0
  68. package/dist/gitlab/GitLabIntegration.cjs.js +41 -0
  69. package/dist/gitlab/GitLabIntegration.cjs.js.map +1 -0
  70. package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.cjs.js +24 -0
  71. package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.cjs.js.map +1 -0
  72. package/dist/gitlab/config.cjs.js +60 -0
  73. package/dist/gitlab/config.cjs.js.map +1 -0
  74. package/dist/gitlab/core.cjs.js +84 -0
  75. package/dist/gitlab/core.cjs.js.map +1 -0
  76. package/dist/googleGcs/config.cjs.js +16 -0
  77. package/dist/googleGcs/config.cjs.js.map +1 -0
  78. package/dist/harness/HarnessIntegration.cjs.js +34 -0
  79. package/dist/harness/HarnessIntegration.cjs.js.map +1 -0
  80. package/dist/harness/config.cjs.js +22 -0
  81. package/dist/harness/config.cjs.js.map +1 -0
  82. package/dist/harness/core.cjs.js +101 -0
  83. package/dist/harness/core.cjs.js.map +1 -0
  84. package/dist/helpers.cjs.js +71 -0
  85. package/dist/helpers.cjs.js.map +1 -0
  86. package/dist/index.cjs.js +124 -2451
  87. package/dist/index.cjs.js.map +1 -1
  88. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/helpers.ts","../src/awsS3/config.ts","../src/awsS3/AwsS3Integration.ts","../src/awsCodeCommit/config.ts","../src/awsCodeCommit/AwsCodeCommitIntegration.ts","../src/azure/AzureUrl.ts","../src/azure/config.ts","../src/azure/AzureIntegration.ts","../src/azure/core.ts","../src/azure/CachedAzureDevOpsCredentialsProvider.ts","../src/azure/DefaultAzureDevOpsCredentialsProvider.ts","../src/azure/deprecated.ts","../src/bitbucket/config.ts","../src/bitbucket/BitbucketIntegration.ts","../src/bitbucket/core.ts","../src/bitbucketCloud/config.ts","../src/bitbucketCloud/BitbucketCloudIntegration.ts","../src/bitbucketCloud/core.ts","../src/bitbucketServer/config.ts","../src/bitbucketServer/BitbucketServerIntegration.ts","../src/bitbucketServer/core.ts","../src/gerrit/config.ts","../src/gerrit/core.ts","../src/gerrit/GerritIntegration.ts","../src/gitea/config.ts","../src/gitea/core.ts","../src/gitea/GiteaIntegration.ts","../src/github/config.ts","../src/github/core.ts","../src/github/SingleInstanceGithubCredentialsProvider.ts","../src/github/DefaultGithubCredentialsProvider.ts","../src/github/GithubIntegration.ts","../src/gitlab/config.ts","../src/gitlab/core.ts","../src/gitlab/GitLabIntegration.ts","../src/gitlab/SingleInstanceGitlabCredentialsProvider.ts","../src/gitlab/DefaultGitlabCredentialsProvider.ts","../src/googleGcs/config.ts","../src/harness/config.ts","../src/harness/core.ts","../src/harness/HarnessIntegration.ts","../src/ScmIntegrations.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { trimEnd } from 'lodash';\nimport { ScmIntegration, ScmIntegrationsGroup } from './types';\n\n/** Checks whether the given argument is a valid URL hostname */\nexport function isValidHost(host: string): boolean {\n const check = new URL('http://example.com');\n check.host = host;\n return check.host === host;\n}\n\n/** Checks whether the given argument is a valid URL */\nexport function isValidUrl(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function basicIntegrations<T extends ScmIntegration>(\n integrations: T[],\n getHost: (integration: T) => string,\n): ScmIntegrationsGroup<T> {\n return {\n list(): T[] {\n return integrations;\n },\n byUrl(url: string | URL): T | undefined {\n try {\n const parsed = typeof url === 'string' ? new URL(url) : url;\n return integrations.find(i => getHost(i) === parsed.host);\n } catch {\n return undefined;\n }\n },\n byHost(host: string): T | undefined {\n return integrations.find(i => getHost(i) === host);\n },\n };\n}\n\n/**\n * Default implementation of {@link ScmIntegration} `resolveUrl`, that only\n * works with URL pathname based providers.\n *\n * @public\n */\nexport function defaultScmResolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n}): string {\n const { url, base, lineNumber } = options;\n\n // If it is a fully qualified URL - then return it verbatim\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return url;\n } catch {\n // ignore intentionally\n }\n\n let updated: URL;\n\n if (url.startsWith('/')) {\n // If it is an absolute path, move relative to the repo root\n const { href, filepath } = parseGitUrl(base);\n\n updated = new URL(href);\n\n const repoRootPath = trimEnd(\n updated.pathname.substring(0, updated.pathname.length - filepath.length),\n '/',\n );\n updated.pathname = `${repoRootPath}${url}`;\n } else {\n // For relative URLs, just let the default URL constructor handle the\n // resolving. Note that this essentially will treat the last segment of the\n // base as a file - NOT a folder - unless the url ends in a slash.\n updated = new URL(url, base);\n }\n\n updated.search = new URL(base).search;\n if (lineNumber) {\n updated.hash = `L${lineNumber}`;\n }\n return updated.toString();\n}\n\n/**\n * Sets up handlers for request mocking\n *\n * Copied from test-utils, as that is a frontend-only package\n *\n * @param worker - service worker\n */\nexport function registerMswTestHooks(worker: {\n listen: (t: any) => void;\n close: () => void;\n resetHandlers: () => void;\n}) {\n beforeAll(() => worker.listen({ onUnhandledRequest: 'error' }));\n afterAll(() => worker.close());\n afterEach(() => worker.resetHandlers());\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst AMAZON_AWS_HOST = 'amazonaws.com';\n\n/**\n * The configuration parameters for a single AWS S3 provider.\n *\n * @public\n */\nexport type AwsS3IntegrationConfig = {\n /**\n * Host, derived from endpoint, and defaults to amazonaws.com\n */\n host: string;\n\n /**\n * (Optional) AWS Endpoint.\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property\n *\n * Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566\n */\n endpoint?: string;\n\n /**\n * (Optional) Whether to use path style URLs when communicating with S3.\n * Defaults to false.\n * This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.\n */\n s3ForcePathStyle?: boolean;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n};\n\n/**\n * Reads a single Aws S3 integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsS3IntegrationConfig(\n config: Config,\n): AwsS3IntegrationConfig {\n const endpoint = config.getOptionalString('endpoint');\n const s3ForcePathStyle =\n config.getOptionalBoolean('s3ForcePathStyle') ?? false;\n let host;\n let pathname;\n if (endpoint) {\n try {\n const url = new URL(endpoint);\n host = url.host;\n pathname = url.pathname;\n } catch {\n throw new Error(\n `invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`,\n );\n }\n if (pathname !== '/') {\n throw new Error(\n `invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`,\n );\n }\n } else {\n host = AMAZON_AWS_HOST;\n }\n\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n\n return {\n host,\n endpoint,\n s3ForcePathStyle,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n };\n}\n\n/**\n * Reads a set of AWS S3 integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsS3IntegrationConfigs(\n configs: Config[],\n): AwsS3IntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAwsS3IntegrationConfig);\n\n // If no explicit amazonaws.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AMAZON_AWS_HOST)) {\n result.push({\n host: AMAZON_AWS_HOST,\n });\n }\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AwsS3IntegrationConfig, readAwsS3IntegrationConfigs } from './config';\n\n/**\n * Integrates with AWS S3 or compatible solutions.\n *\n * @public\n */\nexport class AwsS3Integration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsS3Integration> = ({ config }) => {\n const configs = readAwsS3IntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsS3') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsS3Integration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsS3';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AwsS3IntegrationConfig {\n return this.integrationConfig;\n }\n\n constructor(private readonly integrationConfig: AwsS3IntegrationConfig) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for awsS3\n return url;\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst AMAZON_AWS_CODECOMMIT_HOST = 'console.aws.amazon.com';\n\n/**\n * The configuration parameters for a single AWS CodeCommit provider.\n *\n * @public\n */\nexport type AwsCodeCommitIntegrationConfig = {\n /**\n * Host, git host derived from region\n */\n host: string;\n\n /**\n * (Optional) User access key id\n */\n accessKeyId?: string;\n\n /**\n * (Optional) User secret access key\n */\n secretAccessKey?: string;\n\n /**\n * (Optional) ARN of role to be assumed\n */\n roleArn?: string;\n\n /**\n * (Optional) External ID to use when assuming role\n */\n externalId?: string;\n\n /**\n * region to use for AWS (default: us-east-1)\n */\n region: string;\n};\n\n/**\n * Reads a single Aws CodeCommit integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\n\nexport function readAwsCodeCommitIntegrationConfig(\n config: Config,\n): AwsCodeCommitIntegrationConfig {\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey')?.trim();\n const roleArn = config.getOptionalString('roleArn');\n const externalId = config.getOptionalString('externalId');\n const region = config.getString('region');\n const host =\n config.getOptionalString('host') ||\n `${region}.${AMAZON_AWS_CODECOMMIT_HOST}`;\n\n return {\n host,\n accessKeyId,\n secretAccessKey,\n roleArn,\n externalId,\n region,\n };\n}\n\n/**\n * Reads a set of AWS CodeCommit integration configs, and inserts some defaults for\n * public Amazon AWS if not specified.\n *\n * @param configs - The config objects of the integrations\n * @public\n */\nexport function readAwsCodeCommitIntegrationConfigs(\n configs: Config[],\n): AwsCodeCommitIntegrationConfig[] {\n return configs.map(readAwsCodeCommitIntegrationConfig);\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n AwsCodeCommitIntegrationConfig,\n readAwsCodeCommitIntegrationConfigs,\n} from './config';\n\n/**\n * Integrates with AWS CodeCommit.\n *\n * @public\n */\nexport class AwsCodeCommitIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AwsCodeCommitIntegration> = ({\n config,\n }) => {\n const configs = readAwsCodeCommitIntegrationConfigs(\n config.getOptionalConfigArray('integrations.awsCodeCommit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new AwsCodeCommitIntegration(c)),\n i => i.config.host,\n );\n };\n\n get type(): string {\n return 'awsCodeCommit';\n }\n\n get config(): AwsCodeCommitIntegrationConfig {\n return this.integrationConfig;\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n constructor(\n private readonly integrationConfig: AwsCodeCommitIntegrationConfig,\n ) {}\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n return resolved;\n }\n resolveEditUrl(url: string): string {\n const parsedUrl = new URL(url);\n const pathMatch = parsedUrl.pathname.match(\n /^\\/codesuite\\/codecommit\\/repositories\\/([^\\/]+)\\//,\n );\n if (!pathMatch) {\n throw new Error(``);\n }\n const [, repositoryName] = pathMatch;\n return replaceCodeCommitUrlType(url, repositoryName, 'edit');\n }\n}\n\n/**\n * Takes a CodeCommit URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'edit'\n * @public\n */\nexport function replaceCodeCommitUrlType(\n url: string,\n repositoryName: string,\n type: 'browse' | 'edit',\n): string {\n const newString = type === 'edit' ? `files/edit` : type;\n return url.replace(\n new RegExp(\n `\\/codesuite\\/codecommit\\/repositories\\/${repositoryName}\\/(browse|files\\/edit)\\/`,\n ),\n `/codesuite/codecommit/repositories/${repositoryName}/${newString}/`,\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst VERSION_PREFIX_GIT_BRANCH = 'GB';\n\nexport class AzureUrl {\n /**\n * Parses an azure URL as copied from the browser address bar.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n static fromRepoUrl(repoUrl: string): AzureUrl {\n const url = new URL(repoUrl);\n\n let owner;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n owner = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n owner = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n owner = `${parts[1]}/${parts[2]}`;\n project = parts[3];\n repo = parts[5];\n }\n\n if (!owner || !project || !repo) {\n throw new Error('Azure URL must point to a git repository');\n }\n\n const path = url.searchParams.get('path') ?? undefined;\n\n let ref;\n const version = url.searchParams.get('version');\n if (version) {\n const prefix = version.slice(0, 2);\n if (prefix !== 'GB') {\n throw new Error('Azure URL version must point to a git branch');\n }\n ref = version.slice(2);\n }\n\n return new AzureUrl(url.origin, owner, project, repo, path, ref);\n }\n\n #origin: string;\n #owner: string;\n #project: string;\n #repo: string;\n #path?: string;\n #ref?: string;\n\n private constructor(\n origin: string,\n owner: string,\n project: string,\n repo: string,\n path?: string,\n ref?: string,\n ) {\n this.#origin = origin;\n this.#owner = owner;\n this.#project = project;\n this.#repo = repo;\n this.#path = path;\n this.#ref = ref;\n }\n\n #baseUrl = (...parts: string[]): URL => {\n const url = new URL(this.#origin);\n url.pathname = parts.map(part => encodeURIComponent(part)).join('/');\n return url;\n };\n\n /**\n * Returns a repo URL that can be used to navigate to the resource in azure.\n *\n * Throws an error if the URL is not a valid azure repo URL.\n */\n toRepoUrl(): string {\n let url;\n if (this.#project === this.#repo) {\n url = this.#baseUrl(this.#owner, '_git', this.#repo);\n } else {\n url = this.#baseUrl(this.#owner, this.#project, '_git', this.#repo);\n }\n\n if (this.#path) {\n url.searchParams.set('path', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', VERSION_PREFIX_GIT_BRANCH + this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the file download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a file.\n */\n toFileUrl(): string {\n if (!this.#path) {\n throw new Error(\n 'Azure URL must point to a specific path to be able to download a file',\n );\n }\n\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('api-version', '6.0');\n url.searchParams.set('path', this.#path);\n\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the archive download URL for this azure resource.\n *\n * Throws an error if the URL does not point to a repo.\n */\n toArchiveUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'items',\n );\n url.searchParams.set('recursionLevel', 'full');\n url.searchParams.set('download', 'true');\n url.searchParams.set('api-version', '6.0');\n\n if (this.#path) {\n url.searchParams.set('scopePath', this.#path);\n }\n if (this.#ref) {\n url.searchParams.set('version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the API url for fetching commits from a branch for this azure resource.\n *\n * Throws an error if the URL does not point to a commit.\n */\n toCommitsUrl(): string {\n const url = this.#baseUrl(\n this.#owner,\n this.#project,\n '_apis',\n 'git',\n 'repositories',\n this.#repo,\n 'commits',\n );\n url.searchParams.set('api-version', '6.0');\n\n if (this.#ref) {\n url.searchParams.set('searchCriteria.itemVersion.version', this.#ref);\n }\n\n return url.toString();\n }\n\n /**\n * Returns the name of the owner, a user or an organization.\n */\n getOwner(): string {\n return this.#owner;\n }\n\n /**\n * Returns the name of the project.\n */\n getProject(): string {\n return this.#project;\n }\n\n /**\n * Returns the name of the repo.\n */\n getRepo(): string {\n return this.#repo;\n }\n\n /**\n * Returns the file path within the repo if the URL contains one.\n */\n getPath(): string | undefined {\n return this.#path;\n }\n\n /**\n * Returns the git ref in the repo if the URL contains one.\n */\n getRef(): string | undefined {\n return this.#ref;\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { isValidHost } from '../helpers';\n\nconst AZURE_HOST = 'dev.azure.com';\n\n/**\n * The configuration parameters for a single Azure provider.\n *\n * @public\n */\nexport type AzureIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"dev.azure.com\".\n *\n * Currently only \"dev.azure.com\" is supported.\n */\n host: string;\n\n /**\n * The authorization token to use for requests.\n *\n * If no token is specified, anonymous access is used.\n *\n * @deprecated Use `credentials` instead.\n */\n token?: string;\n\n /**\n * The credential to use for requests.\n *\n * If no credential is specified anonymous access is used.\n *\n * @deprecated Use `credentials` instead.\n */\n credential?: AzureDevOpsCredential;\n\n /**\n * The credentials to use for requests. If multiple credentials are specified the first one that matches the organization is used.\n * If not organization matches the first credential without an organization is used.\n *\n * If no credentials are specified at all, either a default credential (for Azure DevOps) or anonymous access (for Azure DevOps Server) is used.\n */\n credentials?: AzureDevOpsCredential[];\n};\n\n/**\n * The kind of Azure DevOps credential.\n * @public\n */\nexport type AzureDevOpsCredentialKind =\n | 'PersonalAccessToken'\n | 'ClientSecret'\n | 'ManagedIdentity';\n\n/**\n * Common fields for the Azure DevOps credentials.\n * @public\n */\nexport type AzureCredentialBase = {\n /**\n * The kind of credential.\n */\n kind: AzureDevOpsCredentialKind;\n /**\n * The Azure DevOps organizations for which to use this credential.\n */\n organizations?: string[];\n};\n\n/**\n * A client secret credential that was generated for an App Registration.\n * @public\n */\nexport type AzureClientSecretCredential = AzureCredentialBase & {\n kind: 'ClientSecret';\n /**\n * The Entra ID tenant\n */\n tenantId: string;\n /**\n * The client id\n */\n clientId: string;\n\n /**\n * The client secret\n */\n clientSecret: string;\n};\n\n/**\n * A managed identity credential.\n * @public\n */\nexport type AzureManagedIdentityCredential = AzureCredentialBase & {\n kind: 'ManagedIdentity';\n /**\n * The clientId\n */\n clientId: string;\n};\n\n/**\n * A personal access token credential.\n * @public\n */\nexport type PersonalAccessTokenCredential = AzureCredentialBase & {\n kind: 'PersonalAccessToken';\n personalAccessToken: string;\n};\n\n/**\n * The general shape of a credential that can be used to authenticate to Azure DevOps.\n * @public\n */\nexport type AzureDevOpsCredentialLike = Omit<\n Partial<AzureClientSecretCredential> &\n Partial<AzureManagedIdentityCredential> &\n Partial<PersonalAccessTokenCredential>,\n 'kind'\n>;\n\n/**\n * Credential used to authenticate to Azure DevOps.\n * @public\n */\nexport type AzureDevOpsCredential =\n | AzureClientSecretCredential\n | AzureManagedIdentityCredential\n | PersonalAccessTokenCredential;\n\nconst AzureDevOpsCredentialFields = [\n 'clientId',\n 'clientSecret',\n 'tenantId',\n 'personalAccessToken',\n] as const;\ntype AzureDevOpsCredentialField = (typeof AzureDevOpsCredentialFields)[number];\n\nconst AzureDevopsCredentialFieldMap = new Map<\n AzureDevOpsCredentialKind,\n AzureDevOpsCredentialField[]\n>([\n ['ClientSecret', ['clientId', 'clientSecret', 'tenantId']],\n ['ManagedIdentity', ['clientId']],\n ['PersonalAccessToken', ['personalAccessToken']],\n]);\n\nfunction asAzureDevOpsCredential(\n credential: AzureDevOpsCredentialLike,\n): AzureDevOpsCredential {\n for (const entry of AzureDevopsCredentialFieldMap.entries()) {\n const [kind, requiredFields] = entry;\n\n const forbiddenFields = AzureDevOpsCredentialFields.filter(\n field => !requiredFields.includes(field as AzureDevOpsCredentialField),\n );\n\n if (\n requiredFields.every(field => credential[field] !== undefined) &&\n forbiddenFields.every(field => credential[field] === undefined)\n ) {\n return {\n kind,\n organizations: credential.organizations,\n ...requiredFields.reduce((acc, field) => {\n acc[field] = credential[field];\n return acc;\n }, {} as Record<string, any>),\n } as AzureDevOpsCredential;\n }\n }\n throw new Error('is not a valid credential');\n}\n\n/**\n * Reads a single Azure integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readAzureIntegrationConfig(\n config: Config,\n): AzureIntegrationConfig {\n const host = config.getOptionalString('host') ?? AZURE_HOST;\n\n let credentialConfigs = config\n .getOptionalConfigArray('credentials')\n ?.map(credential => {\n const result: Partial<AzureDevOpsCredentialLike> = {\n organizations: credential.getOptionalStringArray('organizations'),\n personalAccessToken: credential\n .getOptionalString('personalAccessToken')\n ?.trim(),\n tenantId: credential.getOptionalString('tenantId'),\n clientId: credential.getOptionalString('clientId'),\n clientSecret: credential.getOptionalString('clientSecret')?.trim(),\n };\n\n return result;\n });\n\n const token = config.getOptionalString('token')?.trim();\n\n if (\n config.getOptional('credential') !== undefined &&\n config.getOptional('credentials') !== undefined\n ) {\n throw new Error(\n `Invalid Azure integration config, 'credential' and 'credentials' cannot be used together. Use 'credentials' instead.`,\n );\n }\n\n if (\n config.getOptional('token') !== undefined &&\n config.getOptional('credentials') !== undefined\n ) {\n throw new Error(\n `Invalid Azure integration config, 'token' and 'credentials' cannot be used together. Use 'credentials' instead.`,\n );\n }\n\n if (token !== undefined) {\n const mapped = [{ personalAccessToken: token }];\n credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;\n }\n\n if (config.getOptional('credential') !== undefined) {\n const mapped = [\n {\n organizations: config.getOptionalStringArray(\n 'credential.organizations',\n ),\n token: config.getOptionalString('credential.token')?.trim(),\n tenantId: config.getOptionalString('credential.tenantId'),\n clientId: config.getOptionalString('credential.clientId'),\n clientSecret: config\n .getOptionalString('credential.clientSecret')\n ?.trim(),\n },\n ];\n credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;\n }\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Azure integration config, '${host}' is not a valid host`,\n );\n }\n\n let credentials: AzureDevOpsCredential[] | undefined = undefined;\n if (credentialConfigs !== undefined) {\n const errors = credentialConfigs\n ?.reduce((acc, credentialConfig, index) => {\n let error: string | undefined = undefined;\n try {\n asAzureDevOpsCredential(credentialConfig);\n } catch (e) {\n error = e.message;\n }\n\n if (error !== undefined) {\n acc.push(`credential at position ${index + 1} ${error}`);\n }\n\n return acc;\n }, Array.of<string>())\n .concat(\n Object.entries(\n credentialConfigs\n .filter(\n credential =>\n credential.organizations !== undefined &&\n credential.organizations.length > 0,\n )\n .reduce((acc, credential, index) => {\n credential.organizations?.forEach(organization => {\n if (!acc[organization]) {\n acc[organization] = [];\n }\n\n acc[organization].push(index + 1);\n });\n\n return acc;\n }, {} as Record<string, number[]>),\n )\n .filter(([_, indexes]) => indexes.length > 1)\n .reduce((acc, [org, indexes]) => {\n acc.push(\n `organization ${org} is specified multiple times in credentials at positions ${indexes\n .slice(0, indexes.length - 1)\n .join(', ')} and ${indexes[indexes.length - 1]}`,\n );\n return acc;\n }, Array.of<string>()),\n );\n\n if (errors?.length > 0) {\n throw new Error(\n `Invalid Azure integration config for ${host}: ${errors.join('; ')}`,\n );\n }\n\n credentials = credentialConfigs.map(credentialConfig =>\n asAzureDevOpsCredential(credentialConfig),\n );\n\n if (\n credentials.some(\n credential => credential.kind !== 'PersonalAccessToken',\n ) &&\n host !== AZURE_HOST\n ) {\n throw new Error(\n `Invalid Azure integration config for ${host}, only personal access tokens can be used with hosts other than ${AZURE_HOST}`,\n );\n }\n\n if (\n credentials.filter(\n credential =>\n credential.organizations === undefined ||\n credential.organizations.length === 0,\n ).length > 1\n ) {\n throw new Error(\n `Invalid Azure integration config for ${host}, you cannot specify multiple credentials without organizations`,\n );\n }\n }\n\n return {\n host,\n credentials,\n };\n}\n\n/**\n * Reads a set of Azure integration configs, and inserts some defaults for\n * public Azure if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readAzureIntegrationConfigs(\n configs: Config[],\n): AzureIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readAzureIntegrationConfig);\n\n // If no explicit dev.azure.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === AZURE_HOST)) {\n result.push({ host: AZURE_HOST });\n }\n\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations, isValidUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { AzureUrl } from './AzureUrl';\nimport { AzureIntegrationConfig, readAzureIntegrationConfigs } from './config';\n\n/**\n * Microsoft Azure based integration.\n *\n * @public\n */\nexport class AzureIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<AzureIntegration> = ({ config }) => {\n const configs = readAzureIntegrationConfigs(\n config.getOptionalConfigArray('integrations.azure') ?? [],\n );\n\n return basicIntegrations(\n configs.map(c => new AzureIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: AzureIntegrationConfig) {}\n\n get type(): string {\n return 'azure';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): AzureIntegrationConfig {\n return this.integrationConfig;\n }\n\n /*\n * Azure repo URLs on the form with a `path` query param are treated specially.\n *\n * Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml\n */\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base } = options;\n\n // If we can parse the url, it is absolute - then return it verbatim\n if (isValidUrl(url)) {\n return url;\n }\n\n try {\n const azureUrl = AzureUrl.fromRepoUrl(base);\n const newUrl = new URL(base);\n\n // We lean on the URL path resolution logic to resolve the path param\n const mockBaseUrl = new URL(`https://a.com${azureUrl.getPath() ?? ''}`);\n const updatedPath = new URL(url, mockBaseUrl).pathname;\n newUrl.searchParams.set('path', updatedPath);\n\n if (options.lineNumber) {\n newUrl.searchParams.set('line', String(options.lineNumber));\n newUrl.searchParams.set('lineEnd', String(options.lineNumber + 1));\n newUrl.searchParams.set('lineStartColumn', '1');\n newUrl.searchParams.set('lineEndColumn', '1');\n }\n\n return newUrl.toString();\n } catch {\n // If not an actual file path within a repo, treat the URL as raw\n return new URL(url, base).toString();\n }\n }\n\n resolveEditUrl(url: string): string {\n // TODO: Implement edit URL for Azure, fallback to view url as I don't know\n // how azure works.\n return url;\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AzureUrl } from './AzureUrl';\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * - from: `https://dev.azure.com/{organization}/{project}/_git/reponame?path={path}&version=GB{commitOrBranch}&_a=contents`\n * - to: `https://dev.azure.com/{organization}/{project}/_apis/git/repositories/reponame/items?path={path}&version={commitOrBranch}`\n *\n * @param url - A URL pointing to a file\n * @public\n */\nexport function getAzureFileFetchUrl(url: string): string {\n return AzureUrl.fromRepoUrl(url).toFileUrl();\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @public\n */\nexport function getAzureDownloadUrl(url: string): string {\n return AzureUrl.fromRepoUrl(url).toArchiveUrl();\n}\n\n/**\n * Given a URL, return the API URL to fetch commits on the branch.\n *\n * @param url - A URL pointing to a repository or a sub-path\n * @public\n */\nexport function getAzureCommitsUrl(url: string): string {\n return AzureUrl.fromRepoUrl(url).toCommitsUrl();\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { AzureDevOpsCredential, PersonalAccessTokenCredential } from './config';\nimport {\n ClientSecretCredential,\n ManagedIdentityCredential,\n TokenCredential,\n} from '@azure/identity';\nimport {\n AzureDevOpsCredentials,\n AzureDevOpsCredentialsProvider,\n} from './types';\n\ntype CachedAzureDevOpsCredentials = AzureDevOpsCredentials & {\n expiresAt?: number;\n};\n\nfunction exhaustiveCheck(_param: never) {}\n\nconst tenMinutes = 1000 * 60 * 10;\n\n/**\n * A credentials provider that caches the credentials for as long as it is valid.\n *\n * @public\n */\nexport class CachedAzureDevOpsCredentialsProvider\n implements AzureDevOpsCredentialsProvider\n{\n azureDevOpsScope = '499b84ac-1321-427f-aa17-267ca6975798/.default';\n cached: CachedAzureDevOpsCredentials | undefined;\n\n static fromAzureDevOpsCredential(\n credential: AzureDevOpsCredential,\n ): CachedAzureDevOpsCredentialsProvider {\n switch (credential.kind) {\n case 'PersonalAccessToken':\n return CachedAzureDevOpsCredentialsProvider.fromPersonalAccessTokenCredential(\n credential,\n );\n case 'ClientSecret':\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new ClientSecretCredential(\n credential.tenantId,\n credential.clientId,\n credential.clientSecret,\n ),\n );\n case 'ManagedIdentity':\n return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new ManagedIdentityCredential(credential.clientId),\n );\n default:\n exhaustiveCheck(credential);\n\n throw new Error(\n `Credential kind '${(credential as any).kind}' not supported`,\n );\n }\n }\n\n static fromTokenCredential(\n credential: TokenCredential,\n ): CachedAzureDevOpsCredentialsProvider {\n return new CachedAzureDevOpsCredentialsProvider(credential);\n }\n\n static fromPersonalAccessTokenCredential(\n credential: PersonalAccessTokenCredential,\n ) {\n return new CachedAzureDevOpsCredentialsProvider(\n credential.personalAccessToken,\n );\n }\n\n private constructor(private readonly credential: TokenCredential | string) {}\n\n async getCredentials(): Promise<AzureDevOpsCredentials> {\n if (\n this.cached === undefined ||\n (this.cached.expiresAt !== undefined &&\n Date.now() > this.cached.expiresAt)\n ) {\n if (typeof this.credential === 'string') {\n this.cached = {\n headers: {\n Authorization: `Basic ${btoa(`:${this.credential}`)}`,\n },\n type: 'pat',\n token: this.credential,\n };\n } else {\n const accessToken = await this.credential.getToken(\n this.azureDevOpsScope,\n );\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n this.cached = {\n expiresAt: accessToken.expiresOnTimestamp - tenMinutes,\n headers: {\n Authorization: `Bearer ${accessToken.token}`,\n },\n type: 'bearer',\n token: accessToken.token,\n };\n }\n }\n\n return this.cached;\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n AzureDevOpsCredentials,\n AzureDevOpsCredentialsProvider,\n} from './types';\nimport { CachedAzureDevOpsCredentialsProvider } from './CachedAzureDevOpsCredentialsProvider';\nimport { ScmIntegrationRegistry } from '../registry';\nimport { DefaultAzureCredential } from '@azure/identity';\n\n/**\n * Default implementation of AzureDevOpsCredentialsProvider.\n * @public\n */\nexport class DefaultAzureDevOpsCredentialsProvider\n implements AzureDevOpsCredentialsProvider\n{\n static fromIntegrations(\n integrations: ScmIntegrationRegistry,\n ): DefaultAzureDevOpsCredentialsProvider {\n const providers = integrations.azure.list().reduce((acc, integration) => {\n integration.config.credentials?.forEach(credential => {\n if (\n credential.organizations === undefined ||\n credential.organizations.length === 0\n ) {\n if (acc.get(integration.config.host) === undefined) {\n acc.set(\n integration.config.host,\n CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(\n credential,\n ),\n );\n }\n } else {\n const provider =\n CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(\n credential,\n );\n credential.organizations?.forEach(organization => {\n acc.set(`${integration.config.host}/${organization}`, provider);\n });\n }\n });\n\n if (\n integration.config.host === 'dev.azure.com' &&\n acc.get(integration.config.host) === undefined\n ) {\n acc.set(\n integration.config.host,\n CachedAzureDevOpsCredentialsProvider.fromTokenCredential(\n new DefaultAzureCredential(),\n ),\n );\n }\n\n return acc;\n }, new Map<string, CachedAzureDevOpsCredentialsProvider>());\n\n return new DefaultAzureDevOpsCredentialsProvider(providers);\n }\n\n private constructor(\n private readonly providers: Map<\n string,\n CachedAzureDevOpsCredentialsProvider\n >,\n ) {}\n\n private forAzureDevOpsServerOrganization(\n url: URL,\n ): AzureDevOpsCredentialsProvider | undefined {\n const parts = url.pathname.split('/').filter(part => part !== '');\n if (url.host !== 'dev.azure.com' && parts.length > 0) {\n if (parts[0] !== 'tfs') {\n // url format: https://{host}/{organization}\n return this.providers.get(`${url.host}/${parts[0]}`);\n } else if (parts[0] === 'tfs' && parts.length > 1) {\n // url format: https://{host}/tfs/{organization}\n return this.providers.get(`${url.host}/${parts[1]}`);\n }\n }\n\n return undefined;\n }\n\n private forAzureDevOpsOrganization(\n url: URL,\n ): AzureDevOpsCredentialsProvider | undefined {\n const parts = url.pathname.split('/').filter(part => part !== '');\n if (url.host === 'dev.azure.com' && parts.length > 0) {\n // url format: https://{host}/{organization}\n return this.providers.get(`${url.host}/${parts[0]}`);\n }\n\n return undefined;\n }\n\n private forHost(url: URL): AzureDevOpsCredentialsProvider | undefined {\n return this.providers.get(url.host);\n }\n\n async getCredentials(opts: {\n url: string;\n }): Promise<AzureDevOpsCredentials | undefined> {\n const url = new URL(opts.url);\n const provider =\n this.forAzureDevOpsOrganization(url) ??\n this.forAzureDevOpsServerOrganization(url) ??\n this.forHost(url);\n\n if (provider === undefined) {\n return undefined;\n }\n\n return provider.getCredentials(opts);\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { AzureIntegrationConfig } from './config';\nimport { CachedAzureDevOpsCredentialsProvider } from './CachedAzureDevOpsCredentialsProvider';\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @param additionalHeaders - Additional headers for the request\n * @public\n * @deprecated Use {@link AzureDevOpsCredentialsProvider} instead.\n */\nexport async function getAzureRequestOptions(\n config: AzureIntegrationConfig,\n additionalHeaders?: Record<string, string>,\n): Promise<{ headers: Record<string, string> }> {\n const headers: Record<string, string> = additionalHeaders\n ? { ...additionalHeaders }\n : {};\n\n /*\n * Since we do not have a way to determine which organization the request is for,\n * we will use the first credential that does not have an organization specified.\n */\n const credentialConfig = config.credentials?.filter(\n credential =>\n credential.organizations === undefined ||\n credential.organizations.length === 0,\n )[0];\n\n if (credentialConfig) {\n const credentialsProvider =\n CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(\n credentialConfig,\n );\n const credentials = await credentialsProvider.getCredentials();\n\n return {\n headers: {\n ...credentials?.headers,\n ...headers,\n },\n };\n }\n\n return { headers };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDefaultBranch(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project, resource } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184\n let branchUrl = isHosted\n ? `${config.apiBaseUrl}/repositories/${project}/${repoName}`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;\n\n let response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n\n if (response.status === 404 && !isHosted) {\n // First try the new format, and then if it gets specifically a 404 it should try the old format\n // (to support old Atlassian Bitbucket v5.11.1 format )\n branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;\n response = await fetch(branchUrl, getBitbucketRequestOptions(config));\n }\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n let defaultBranch;\n if (isHosted) {\n const repoInfo = await response.json();\n defaultBranch = repoInfo.mainbranch.name;\n } else {\n const { displayId } = await response.json();\n defaultBranch = displayId;\n }\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport async function getBitbucketDownloadUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n filepath,\n } = parseGitUrl(url);\n\n const isHosted = resource === 'bitbucket.org';\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketDefaultBranch(url, config);\n }\n // path will limit the downloaded content\n // /docs will only download the docs folder and everything below it\n // /docs/index.md will download the docs folder and everything below it\n const path = filepath\n ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}`\n : '';\n const archiveUrl = isHosted\n ? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`\n : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;\n\n return archiveUrl;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketFileFetchUrl(\n url: string,\n config: BitbucketIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n (filepathtype !== 'browse' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'src')\n ) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (config.host === 'bitbucket.org') {\n if (!ref) {\n throw new Error('Invalid Bitbucket URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n }\n return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n * @deprecated no longer in use, bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function getBitbucketRequestOptions(\n config: BitbucketIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.token) {\n headers.Authorization = `Bearer ${config.token}`;\n } else if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n\n /**\n * The access token to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n token?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketCloudIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDefaultBranch(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project } = parseGitUrl(url);\n\n const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;\n const response = await fetch(\n branchUrl,\n getBitbucketCloudRequestOptions(config),\n );\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n const repoInfo = await response.json();\n const defaultBranch = repoInfo.mainbranch.name;\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketCloudDownloadUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): Promise<string> {\n const {\n name: repoName,\n owner: project,\n ref,\n protocol,\n resource,\n } = parseGitUrl(url);\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketCloudDefaultBranch(url, config);\n }\n return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.org/orgname/reponame/src/master/file.yaml\n * to: https://api.bitbucket.org/2.0/repositories/orgname/reponame/src/master/file.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudFileFetchUrl(\n url: string,\n config: BitbucketCloudIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (!owner || !name || (filepathtype !== 'src' && filepathtype !== 'raw')) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n\n if (!ref) {\n throw new Error('Invalid Bitbucket Cloud URL or file path');\n }\n return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketCloudRequestOptions(\n config: BitbucketCloudIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\n/**\n * The configuration parameters for a single Bitbucket Server API provider.\n *\n * @public\n */\nexport type BitbucketServerIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.company.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://<host>/rest/api/1.0\",\n * with no trailing slash.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n username?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n password?: string;\n};\n\n/**\n * Reads a single Bitbucket Server integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketServerIntegrationConfig(\n config: Config,\n): BitbucketServerIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket Server integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Bitbucket Server integration configs.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketServerIntegrationConfigs(\n configs: Config[],\n): BitbucketServerIntegrationConfig[] {\n // Read all the explicit integrations\n // No default integration will be added\n return configs.map(readBitbucketServerIntegrationConfig);\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetch from 'cross-fetch';\nimport parseGitUrl from 'git-url-parse';\nimport { BitbucketServerIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a path on a provider, returns the default branch.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketServerDefaultBranch(\n url: string,\n config: BitbucketServerIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project } = parseGitUrl(url);\n\n // Bitbucket Server https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp184\n let branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;\n\n let response = await fetch(\n branchUrl,\n getBitbucketServerRequestOptions(config),\n );\n\n if (response.status === 404) {\n // First try the new format, and then if it gets specifically a 404 it should try the old format\n // (to support old Atlassian Bitbucket Server v5.11.1 format )\n branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;\n response = await fetch(branchUrl, getBitbucketServerRequestOptions(config));\n }\n\n if (!response.ok) {\n const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;\n throw new Error(message);\n }\n\n const { displayId } = await response.json();\n const defaultBranch = displayId;\n if (!defaultBranch) {\n throw new Error(\n `Failed to read default branch from ${branchUrl}. ` +\n `Response ${response.status} ${response.json()}`,\n );\n }\n return defaultBranch;\n}\n\n/**\n * Given a URL pointing to a path on a provider, returns a URL that is suitable\n * for downloading the subtree.\n *\n * @param url - A URL pointing to a path\n * @param config - The relevant provider config\n * @public\n */\nexport async function getBitbucketServerDownloadUrl(\n url: string,\n config: BitbucketServerIntegrationConfig,\n): Promise<string> {\n const { name: repoName, owner: project, ref, filepath } = parseGitUrl(url);\n\n let branch = ref;\n if (!branch) {\n branch = await getBitbucketServerDefaultBranch(url, config);\n }\n // path will limit the downloaded content\n // /docs will only download the docs folder and everything below it\n // /docs/index.md will download the docs folder and everything below it\n const path = filepath\n ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}`\n : '';\n return `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;\n}\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://bitbucket.company.com/projectname/reponame/src/main/file.yaml\n * to: https://bitbucket.company.com/rest/api/1.0/project/projectname/reponame/raw/file.yaml?at=main\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketServerFileFetchUrl(\n url: string,\n config: BitbucketServerIntegrationConfig,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n (filepathtype !== 'browse' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'src')\n ) {\n throw new Error('Invalid Bitbucket Server URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getBitbucketServerRequestOptions(\n config: BitbucketServerIntegrationConfig,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (config.token) {\n headers.Authorization = `Bearer ${config.token}`;\n } else if (config.username && config.password) {\n const buffer = Buffer.from(`${config.username}:${config.password}`, 'utf8');\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return {\n headers,\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\n/**\n * The configuration parameters for a single Gerrit API provider.\n *\n * @public\n */\nexport type GerritIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gerrit-review.com\"\n */\n host: string;\n\n /**\n * The optional base URL of the Gerrit instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gerrit instance, e.g.\n * \"https://gerrit-review.com/gerrit\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n\n /**\n * The optional base url to use for cloning a repository. If not set the\n * baseUrl will be used.\n */\n cloneUrl?: string;\n\n /**\n * Base url for Gitiles. This is needed for creating a valid\n * user-friendly url that can be used for browsing the content of the\n * provider.\n */\n gitilesBaseUrl: string;\n\n /**\n * The username to use for requests to gerrit.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Reads a single Gerrit integration config.\n *\n * @param config - The config object of a single integration\n *\n * @public\n */\nexport function readGerritIntegrationConfig(\n config: Config,\n): GerritIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n let cloneUrl = config.getOptionalString('cloneUrl');\n let gitilesBaseUrl = config.getString('gitilesBaseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gerrit integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n } else if (cloneUrl && !isValidUrl(cloneUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`,\n );\n } else if (!isValidUrl(gitilesBaseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`,\n );\n }\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n if (gitilesBaseUrl) {\n gitilesBaseUrl = trimEnd(gitilesBaseUrl, '/');\n } else {\n gitilesBaseUrl = `https://${host}`;\n }\n if (cloneUrl) {\n cloneUrl = trimEnd(cloneUrl, '/');\n } else {\n cloneUrl = baseUrl;\n }\n\n return {\n host,\n baseUrl,\n cloneUrl,\n gitilesBaseUrl,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Gerrit integration configs.\n *\n * @param configs - All of the integration config objects\n *\n * @public\n */\nexport function readGerritIntegrationConfigs(\n configs: Config[],\n): GerritIntegrationConfig[] {\n return configs.map(readGerritIntegrationConfig);\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { join, takeWhile, trimEnd, trimStart } from 'lodash';\nimport { GerritIntegrationConfig } from './config';\n\nconst GERRIT_BODY_PREFIX = \")]}'\";\n\n/**\n * Parse a Gitiles URL and return branch, file path and project.\n *\n * @remarks\n *\n * Gerrit only handles code reviews so it does not have a native way to browse\n * or showing the content of gits. Image if Github only had the \"pull requests\"\n * tab.\n *\n * Any source code browsing is instead handled by optional services outside\n * Gerrit. The url format chosen for the Gerrit url reader is the one used by\n * the Gitiles project. Gerrit will work perfectly with Backstage without\n * having Gitiles installed but there are some places in the Backstage GUI\n * with links to the url used by the url reader. These will not work unless\n * the urls point to an actual Gitiles installation.\n *\n * Gitiles url:\n * https://g.com/optional_path/\\{project\\}/+/refs/heads/\\{branch\\}/\\{filePath\\}\n * https://g.com/a/optional_path/\\{project\\}/+/refs/heads/\\{branch\\}/\\{filePath\\}\n *\n *\n * @param url - An URL pointing to a file stored in git.\n * @public\n */\n\nexport function parseGerritGitilesUrl(\n config: GerritIntegrationConfig,\n url: string,\n): { branch: string; filePath: string; project: string } {\n const baseUrlParse = new URL(config.gitilesBaseUrl!);\n const urlParse = new URL(url);\n\n // Remove the gerrit authentication prefix '/a/' from the url\n // In case of the gitilesBaseUrl is https://review.gerrit.com/plugins/gitiles\n // and the url provided is https://review.gerrit.com/a/plugins/gitiles/...\n // remove the prefix only if the pathname start with '/a/'\n const urlPath = urlParse.pathname\n .substring(urlParse.pathname.startsWith('/a/') ? 2 : 0)\n .replace(baseUrlParse.pathname, '');\n\n const parts = urlPath.split('/').filter(p => !!p);\n\n const projectEndIndex = parts.indexOf('+');\n\n if (projectEndIndex <= 0) {\n throw new Error(`Unable to parse project from url: ${url}`);\n }\n const project = trimStart(parts.slice(0, projectEndIndex).join('/'), '/');\n\n const branchIndex = parts.indexOf('heads');\n if (branchIndex <= 0) {\n throw new Error(`Unable to parse branch from url: ${url}`);\n }\n const branch = parts[branchIndex + 1];\n const filePath = parts.slice(branchIndex + 2).join('/');\n\n return {\n branch,\n filePath: filePath === '' ? '/' : filePath,\n project,\n };\n}\n\n/**\n * Parses Gitiles urls and returns the following:\n *\n * - The project\n * - The type of ref. I.e: branch name, SHA, HEAD or tag.\n * - The file path from the repo root.\n * - The base path as the path that points to the repo root.\n *\n * Supported types of gitiles urls that point to:\n *\n * - Branches\n * - Tags\n * - A commit SHA\n * - HEAD\n *\n * @param config - A Gerrit provider config.\n * @param url - An url to a file or folder in Gitiles.\n * @public\n */\nexport function parseGitilesUrlRef(\n config: GerritIntegrationConfig,\n url: string,\n): {\n project: string;\n path: string;\n ref: string;\n refType: 'sha' | 'branch' | 'tag' | 'head';\n basePath: string;\n} {\n const baseUrlParse = new URL(config.gitilesBaseUrl!);\n const urlParse = new URL(url);\n // Remove the gerrit authentication prefix '/a/' from the url\n // In case of the gitilesBaseUrl is https://review.gerrit.com/plugins/gitiles\n // and the url provided is https://review.gerrit.com/a/plugins/gitiles/...\n // remove the prefix only if the pathname start with '/a/'\n const urlPath = trimStart(\n urlParse.pathname\n .substring(urlParse.pathname.startsWith('/a/') ? 2 : 0)\n .replace(baseUrlParse.pathname, ''),\n '/',\n );\n\n // Find the project by taking everything up to \"/+/\".\n const parts = urlPath.split('/').filter(p => !!p);\n const projectParts = takeWhile(parts, p => p !== '+');\n if (projectParts.length === 0) {\n throw new Error(`Unable to parse gitiles url: ${url}`);\n }\n // Also remove the \"+\" after the project.\n const rest = parts.slice(projectParts.length + 1);\n const project = join(projectParts, '/');\n\n // match <project>/+/HEAD/<path>\n if (rest.length > 0 && rest[0] === 'HEAD') {\n const ref = rest.shift()!;\n const path = join(rest, '/');\n return {\n project,\n ref,\n refType: 'head' as const,\n path: path || '/',\n basePath: trimEnd(url.replace(path, ''), '/'),\n };\n }\n // match <project>/+/<sha>/<path>\n if (rest.length > 0 && rest[0].length === 40) {\n const ref = rest.shift()!;\n const path = join(rest, '/');\n return {\n project,\n ref,\n refType: 'sha' as const,\n path: path || '/',\n basePath: trimEnd(url.replace(path, ''), '/'),\n };\n }\n const remainingPath = join(rest, '/');\n // Regexp for matching \"refs/tags/<tag>\" or \"refs/heads/<branch>/\"\n const refsRegexp = /^refs\\/(?<refsReference>heads|tags)\\/(?<ref>.*?)(\\/|$)/;\n const result = refsRegexp.exec(remainingPath);\n if (result) {\n const matchString = result[0];\n let refType;\n const { refsReference, ref } = result.groups || {};\n const path = remainingPath.replace(matchString, '');\n switch (refsReference) {\n case 'heads':\n refType = 'branch' as const;\n break;\n case 'tags':\n refType = 'tag' as const;\n break;\n default:\n throw new Error(`Unable to parse gitiles url: ${url}`);\n }\n return {\n project,\n ref,\n refType,\n path: path || '/',\n basePath: trimEnd(url.replace(path, ''), '/'),\n };\n }\n throw new Error(`Unable to parse gitiles : ${url}`);\n}\n\n/**\n * Build a Gerrit Gitiles url that targets a specific path.\n *\n * @param config - A Gerrit provider config.\n * @param project - The name of the git project\n * @param branch - The branch we will target.\n * @param filePath - The absolute file path.\n * @public\n */\nexport function buildGerritGitilesUrl(\n config: GerritIntegrationConfig,\n project: string,\n branch: string,\n filePath: string,\n): string {\n return `${\n config.gitilesBaseUrl\n }/${project}/+/refs/heads/${branch}/${trimStart(filePath, '/')}`;\n}\n\n/**\n * Build a Gerrit Gitiles archive url that targets a specific branch and path\n *\n * @param config - A Gerrit provider config.\n * @param project - The name of the git project\n * @param branch - The branch we will target.\n * @param filePath - The absolute file path.\n * @public\n */\nexport function buildGerritGitilesArchiveUrl(\n config: GerritIntegrationConfig,\n project: string,\n branch: string,\n filePath: string,\n): string {\n const archiveName =\n filePath === '/' || filePath === '' ? '.tar.gz' : `/${filePath}.tar.gz`;\n return `${getGitilesAuthenticationUrl(\n config,\n )}/${project}/+archive/refs/heads/${branch}${archiveName}`;\n}\n\n/**\n * Return the authentication prefix.\n *\n * @remarks\n *\n * To authenticate with a password the API url must be prefixed with \"/a/\".\n * If no password is set anonymous access (without the prefix) will\n * be used.\n *\n * @param config - A Gerrit provider config.\n * @public\n */\nexport function getAuthenticationPrefix(\n config: GerritIntegrationConfig,\n): string {\n return config.password ? '/a/' : '/';\n}\n\n/**\n * Return the authentication gitiles url.\n *\n * @remarks\n *\n * To authenticate with a password the API url must be prefixed with \"/a/\".\n * If no password is set anonymous access (without the prefix) will\n * be used.\n *\n * @param config - A Gerrit provider config.\n */\nexport function getGitilesAuthenticationUrl(\n config: GerritIntegrationConfig,\n): string {\n if (!config.baseUrl || !config.gitilesBaseUrl) {\n throw new Error(\n 'Unexpected Gerrit config values. baseUrl or gitilesBaseUrl not set.',\n );\n }\n if (config.gitilesBaseUrl.startsWith(config.baseUrl)) {\n return config.gitilesBaseUrl.replace(\n config.baseUrl.concat('/'),\n config.baseUrl.concat(getAuthenticationPrefix(config)),\n );\n }\n if (config.password) {\n throw new Error(\n 'Since the baseUrl (Gerrit) is not part of the gitilesBaseUrl, an authentication URL could not be constructed.',\n );\n }\n return config.gitilesBaseUrl!;\n}\n\n/**\n * Return the url to get branch info from the Gerrit API.\n *\n * @param config - A Gerrit provider config.\n * @param url - An url pointing to a file in git.\n * @public\n */\nexport function getGerritBranchApiUrl(\n config: GerritIntegrationConfig,\n url: string,\n) {\n const { branch, project } = parseGerritGitilesUrl(config, url);\n\n return `${config.baseUrl}${getAuthenticationPrefix(\n config,\n )}projects/${encodeURIComponent(project)}/branches/${branch}`;\n}\n\n/**\n * Return the url to clone the repo that is referenced by the url.\n *\n * @param url - An url pointing to a file in git.\n * @public\n */\nexport function getGerritCloneRepoUrl(\n config: GerritIntegrationConfig,\n url: string,\n) {\n const { project } = parseGerritGitilesUrl(config, url);\n\n return `${config.cloneUrl}${getAuthenticationPrefix(config)}${project}`;\n}\n\n/**\n * Return the url to fetch the contents of a file using the Gerrit API.\n *\n * @param config - A Gerrit provider config.\n * @param url - An url pointing to a file in git.\n * @public\n */\nexport function getGerritFileContentsApiUrl(\n config: GerritIntegrationConfig,\n url: string,\n) {\n const { branch, filePath, project } = parseGerritGitilesUrl(config, url);\n\n return `${config.baseUrl}${getAuthenticationPrefix(\n config,\n )}projects/${encodeURIComponent(\n project,\n )}/branches/${branch}/files/${encodeURIComponent(filePath)}/content`;\n}\n\n/**\n * Return the url to query available projects using the Gerrit API.\n *\n * @param config - A Gerrit provider config.\n * @public\n */\nexport function getGerritProjectsApiUrl(config: GerritIntegrationConfig) {\n return `${config.baseUrl}${getAuthenticationPrefix(config)}projects/`;\n}\n\n/**\n * Return request headers for a Gerrit provider.\n *\n * @param config - A Gerrit provider config\n * @public\n */\nexport function getGerritRequestOptions(config: GerritIntegrationConfig): {\n headers?: Record<string, string>;\n} {\n const headers: Record<string, string> = {};\n\n if (!config.password) {\n return headers;\n }\n const buffer = Buffer.from(`${config.username}:${config.password}`, 'utf8');\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n return {\n headers,\n };\n}\n\n/**\n * Parse the json response from Gerrit and strip the magic prefix.\n *\n * @remarks\n *\n * To prevent against XSSI attacks the JSON response body from Gerrit starts\n * with a magic prefix that must be stripped before it can be fed to a JSON\n * parser.\n *\n * @param response - An API response.\n * @public\n */\nexport async function parseGerritJsonResponse(\n response: Response,\n): Promise<unknown> {\n const responseBody = await response.text();\n if (responseBody.startsWith(GERRIT_BODY_PREFIX)) {\n try {\n return JSON.parse(responseBody.slice(GERRIT_BODY_PREFIX.length));\n } catch (ex) {\n throw new Error(\n `Invalid response from Gerrit: ${responseBody.slice(0, 10)} - ${ex}`,\n );\n }\n }\n throw new Error(\n `Gerrit JSON body prefix missing. Found: ${responseBody.slice(0, 10)}`,\n );\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n GerritIntegrationConfig,\n readGerritIntegrationConfigs,\n} from './config';\nimport { parseGitilesUrlRef } from './core';\n\n/**\n * A Gerrit based integration.\n *\n * @public\n */\nexport class GerritIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GerritIntegration> = ({ config }) => {\n const configs = readGerritIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gerrit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GerritIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GerritIntegrationConfig) {}\n\n get type(): string {\n return 'gerrit';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GerritIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base, lineNumber } = options;\n let updated;\n if (url.startsWith('/')) {\n const { basePath } = parseGitilesUrlRef(this.config, base);\n return basePath + url;\n }\n if (url) {\n updated = new URL(url, base);\n } else {\n updated = new URL(base);\n }\n if (lineNumber) {\n updated.hash = lineNumber.toString();\n }\n return updated.toString();\n }\n\n resolveEditUrl(url: string): string {\n // Not applicable for gerrit.\n return url;\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\n/**\n * The configuration for a single Gitea integration.\n *\n * @public\n */\nexport type GiteaIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gitea.website.com\"\n */\n host: string;\n /**\n * The optional base URL of the Gitea instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gitea instance, e.g.\n * \"https://gitea.website.com/\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n /**\n * The username to use for requests to gitea.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Parses a location config block for use in GiteaIntegration\n *\n * @public\n */\nexport function readGiteaConfig(config: Config): GiteaIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gitea integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gitea integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n return {\n host,\n baseUrl,\n username,\n password,\n };\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { GiteaIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a file, returns a URL\n * for editing the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://gitea.com/a/b/src/branchname/path/to/c.yaml\n * or: https://gitea.com/a/b/_edit/branchname/path/to/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGiteaEditContentsUrl(\n config: GiteaIntegrationConfig,\n url: string,\n) {\n const giteaUrl = parseGiteaUrl(config, url);\n return `${giteaUrl.url}/${giteaUrl.owner}/${giteaUrl.name}/_edit/${giteaUrl.ref}/${giteaUrl.path}`;\n}\n\n/**\n * Given a URL pointing to a file, returns an api URL\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://gitea.com/a/b/src/branch/branchname/path/to/c.yaml\n * to: https://gitea.com/api/v1/repos/a/b/contents/path/to/c.yaml?ref=branchname\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGiteaFileContentsUrl(\n config: GiteaIntegrationConfig,\n url: string,\n) {\n const giteaUrl = parseGiteaUrl(config, url);\n return `${giteaUrl.url}/api/v1/repos/${giteaUrl.owner}/${giteaUrl.name}/contents/${giteaUrl.path}?ref=${giteaUrl.ref}`;\n}\n\n/**\n * Given a URL pointing to a repository/path, returns a URL\n * for archive contents of the repository.\n *\n * @remarks\n *\n * Converts\n * from: https://gitea.com/a/b/src/branchname\n * or: https://gitea.com/api/v1/repos/a/b/archive/branchname.tar.gz\n *\n * @param url - A URL pointing to a repository/path\n * @param config - The relevant provider config\n * @public\n */\nexport function getGiteaArchiveUrl(\n config: GiteaIntegrationConfig,\n url: string,\n) {\n const giteaUrl = parseGiteaUrl(config, url);\n return `${giteaUrl.url}/api/v1/repos/${giteaUrl.owner}/${giteaUrl.name}/archive/${giteaUrl.ref}.tar.gz`;\n}\n\n/**\n * Given a URL pointing to a repository branch, returns a URL\n * for latest commit information.\n *\n * @remarks\n *\n * Converts\n * from: https://gitea.com/a/b/src/branchname\n * or: https://gitea.com/api/v1/repos/a/b/git/commits/branchname\n *\n * @param url - A URL pointing to a repository branch\n * @param config - The relevant provider config\n * @public\n */\nexport function getGiteaLatestCommitUrl(\n config: GiteaIntegrationConfig,\n url: string,\n) {\n const giteaUrl = parseGiteaUrl(config, url);\n return `${giteaUrl.url}/api/v1/repos/${giteaUrl.owner}/${giteaUrl.name}/git/commits/${giteaUrl.ref}`;\n}\n\n/**\n * Return request headers for a Gitea provider.\n *\n * @param config - A Gitea provider config\n * @public\n */\nexport function getGiteaRequestOptions(config: GiteaIntegrationConfig): {\n headers?: Record<string, string>;\n} {\n const headers: Record<string, string> = {};\n const { username, password } = config;\n\n if (!password) {\n return headers;\n }\n\n if (username) {\n headers.Authorization = `basic ${Buffer.from(\n `${username}:${password}`,\n ).toString('base64')}`;\n } else {\n headers.Authorization = `token ${password}`;\n }\n\n return {\n headers,\n };\n}\n\n/**\n * Return parsed git url properties.\n *\n * @param config - A Gitea provider config\n * @param url - A URL pointing to a repository\n * @public\n */\nexport function parseGiteaUrl(\n config: GiteaIntegrationConfig,\n url: string,\n): {\n url: string;\n owner: string;\n name: string;\n ref: string;\n path: string;\n} {\n const baseUrl = config.baseUrl ?? `https://${config.host}`;\n try {\n const [_blank, owner, name, _src, _branch, ref, ...path] = url\n .replace(baseUrl, '')\n .split('/');\n const pathWithoutSlash = path.join('/').replace(/^\\//, '');\n\n return {\n url: baseUrl,\n owner: owner,\n name: name,\n ref: ref,\n path: pathWithoutSlash,\n };\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { GiteaIntegrationConfig, readGiteaConfig } from './config';\nimport { getGiteaEditContentsUrl } from './core';\n\n/**\n * A Gitea based integration.\n *\n * @public\n */\nexport class GiteaIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GiteaIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.gitea') ?? [];\n const giteaConfigs = configs.map(c => readGiteaConfig(c));\n\n return basicIntegrations(\n giteaConfigs.map(c => new GiteaIntegration(c)),\n (gitea: GiteaIntegration) => gitea.config.host,\n );\n };\n\n constructor(readonly config: GiteaIntegrationConfig) {}\n\n get type(): string {\n return 'gitea';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getGiteaEditContentsUrl(this.config, url);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst GITHUB_HOST = 'github.com';\nconst GITHUB_API_BASE_URL = 'https://api.github.com';\nconst GITHUB_RAW_BASE_URL = 'https://raw.githubusercontent.com';\n\n/**\n * The configuration parameters for a single GitHub integration.\n *\n * @public\n */\nexport type GithubIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"github.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.github.com\",\n * with no trailing slash.\n *\n * May be omitted specifically for GitHub; then it will be deduced.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n apiBaseUrl?: string;\n\n /**\n * The base URL of the raw fetch endpoint of this provider, e.g.\n * \"https://raw.githubusercontent.com\", with no trailing slash.\n *\n * May be omitted specifically for GitHub; then it will be deduced.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n rawBaseUrl?: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The GitHub Apps configuration to use for requests to this provider.\n *\n * If no apps are specified, token or anonymous is used.\n */\n apps?: GithubAppConfig[];\n};\n\n/**\n * The configuration parameters for authenticating a GitHub Application.\n *\n * @remarks\n *\n * A GitHub Apps configuration can be generated using the `backstage-cli create-github-app` command.\n *\n * @public\n */\nexport type GithubAppConfig = {\n /**\n * Unique app identifier, found at https://github.com/organizations/$org/settings/apps/$AppName\n */\n appId: number;\n /**\n * The private key is used by the GitHub App integration to authenticate the app.\n * A private key can be generated from the app at https://github.com/organizations/$org/settings/apps/$AppName\n */\n privateKey: string;\n /**\n * Webhook secret can be configured at https://github.com/organizations/$org/settings/apps/$AppName\n */\n webhookSecret: string;\n /**\n * Found at https://github.com/organizations/$org/settings/apps/$AppName\n */\n clientId: string;\n /**\n * Client secrets can be generated at https://github.com/organizations/$org/settings/apps/$AppName\n */\n clientSecret: string;\n /**\n * List of installation owners allowed to be used by this GitHub app. The GitHub UI does not provide a way to list the installations.\n * However you can list the installations with the GitHub API. You can find the list of installations here:\n * https://api.github.com/app/installations\n * The relevant documentation for this is here.\n * https://docs.github.com/en/rest/reference/apps#list-installations-for-the-authenticated-app--code-samples\n */\n allowedInstallationOwners?: string[];\n};\n\n/**\n * Reads a single GitHub integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGithubIntegrationConfig(\n config: Config,\n): GithubIntegrationConfig {\n const host = config.getOptionalString('host') ?? GITHUB_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n let rawBaseUrl = config.getOptionalString('rawBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const apps = config.getOptionalConfigArray('apps')?.map(c => ({\n appId: c.getNumber('appId'),\n clientId: c.getString('clientId'),\n clientSecret: c.getString('clientSecret'),\n webhookSecret: c.getString('webhookSecret'),\n privateKey: c.getString('privateKey'),\n allowedInstallationOwners: c.getOptionalStringArray(\n 'allowedInstallationOwners',\n ),\n }));\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitHub integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITHUB_HOST) {\n apiBaseUrl = GITHUB_API_BASE_URL;\n }\n\n if (rawBaseUrl) {\n rawBaseUrl = trimEnd(rawBaseUrl, '/');\n } else if (host === GITHUB_HOST) {\n rawBaseUrl = GITHUB_RAW_BASE_URL;\n }\n\n return { host, apiBaseUrl, rawBaseUrl, token, apps };\n}\n\n/**\n * Reads a set of GitHub integration configs, and inserts some defaults for\n * public GitHub if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGithubIntegrationConfigs(\n configs: Config[],\n): GithubIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGithubIntegrationConfig);\n\n // If no explicit github.com integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === GITHUB_HOST)) {\n result.push({\n host: GITHUB_HOST,\n apiBaseUrl: GITHUB_API_BASE_URL,\n rawBaseUrl: GITHUB_RAW_BASE_URL,\n });\n }\n\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { GithubIntegrationConfig } from './config';\nimport { GithubCredentials } from './types';\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://github.com/a/b/blob/branchname/path/to/c.yaml\n * to: https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname\n * or: https://raw.githubusercontent.com/a/b/branchname/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getGithubFileFetchUrl(\n url: string,\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): string {\n try {\n const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);\n if (\n !owner ||\n !name ||\n !ref ||\n // GitHub is automatically redirecting tree urls to blob urls so it's\n // fine to pass a tree url.\n (filepathtype !== 'blob' &&\n filepathtype !== 'raw' &&\n filepathtype !== 'tree')\n ) {\n throw new Error('Invalid GitHub URL or file path');\n }\n\n const pathWithoutSlash = filepath.replace(/^\\//, '');\n if (chooseEndpoint(config, credentials) === 'api') {\n return `${config.apiBaseUrl}/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;\n }\n return `${config.rawBaseUrl}/${owner}/${name}/${ref}/${pathWithoutSlash}`;\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @deprecated This function is no longer used internally\n * @param config - The relevant provider config\n * @public\n */\nexport function getGitHubRequestOptions(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): { headers: Record<string, string> } {\n const headers: Record<string, string> = {};\n\n if (chooseEndpoint(config, credentials) === 'api') {\n headers.Accept = 'application/vnd.github.v3.raw';\n }\n\n if (credentials.token) {\n headers.Authorization = `token ${credentials.token}`;\n }\n\n return { headers };\n}\n\nexport function chooseEndpoint(\n config: GithubIntegrationConfig,\n credentials: GithubCredentials,\n): 'api' | 'raw' {\n if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) {\n return 'api';\n }\n return 'raw';\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport parseGitUrl from 'git-url-parse';\nimport { GithubAppConfig, GithubIntegrationConfig } from './config';\nimport { createAppAuth } from '@octokit/auth-app';\nimport { Octokit, RestEndpointMethodTypes } from '@octokit/rest';\nimport { DateTime } from 'luxon';\nimport {\n GithubCredentials,\n GithubCredentialsProvider,\n GithubCredentialType,\n} from './types';\n\ntype InstallationData = {\n installationId: number;\n suspended: boolean;\n};\n\ntype InstallationTokenData = {\n token: string;\n expiresAt: DateTime;\n repositories?: String[];\n};\n\nclass Cache {\n private readonly tokenCache = new Map<string, InstallationTokenData>();\n\n async getOrCreateToken(\n owner: string,\n repo: string | undefined,\n supplier: () => Promise<InstallationTokenData>,\n ): Promise<{ accessToken: string }> {\n let existingInstallationData = this.tokenCache.get(owner);\n\n if (\n !existingInstallationData ||\n this.isExpired(existingInstallationData.expiresAt)\n ) {\n existingInstallationData = await supplier();\n // Allow 10 minutes grace to account for clock skew\n existingInstallationData.expiresAt =\n existingInstallationData.expiresAt.minus({ minutes: 10 });\n this.tokenCache.set(owner, existingInstallationData);\n }\n\n if (!this.appliesToRepo(existingInstallationData, repo)) {\n throw new Error(\n `The Backstage GitHub application used in the ${owner} organization does not have access to a repository with the name ${repo}`,\n );\n }\n\n return { accessToken: existingInstallationData.token };\n }\n\n private isExpired = (date: DateTime) => DateTime.local() > date;\n\n private appliesToRepo(tokenData: InstallationTokenData, repo?: string) {\n // If no specific repo has been requested the token is applicable\n if (repo === undefined) {\n return true;\n }\n // If the token is restricted to repositories, the token only applies if the repo is in the allow list\n if (tokenData.repositories !== undefined) {\n return tokenData.repositories.includes(repo);\n }\n // Otherwise the token is applicable\n return true;\n }\n}\n\n/**\n * This accept header is required when calling App APIs in GitHub Enterprise.\n * It has no effect on calls to github.com and can probably be removed entirely\n * once GitHub Apps is out of preview.\n */\nconst HEADERS = {\n Accept: 'application/vnd.github.machine-man-preview+json',\n};\n\n/**\n * GithubAppManager issues and caches tokens for a specific GitHub App.\n */\nclass GithubAppManager {\n private readonly appClient: Octokit;\n private readonly baseUrl?: string;\n private readonly baseAuthConfig: { appId: number; privateKey: string };\n private readonly cache = new Cache();\n private readonly allowedInstallationOwners: string[] | undefined; // undefined allows all installations\n\n constructor(config: GithubAppConfig, baseUrl?: string) {\n this.allowedInstallationOwners = config.allowedInstallationOwners;\n this.baseUrl = baseUrl;\n this.baseAuthConfig = {\n appId: config.appId,\n privateKey: config.privateKey.replace(/\\\\n/gm, '\\n'),\n };\n this.appClient = new Octokit({\n baseUrl,\n headers: HEADERS,\n authStrategy: createAppAuth,\n auth: this.baseAuthConfig,\n });\n }\n\n async getInstallationCredentials(\n owner: string,\n repo?: string,\n ): Promise<{ accessToken: string | undefined }> {\n if (this.allowedInstallationOwners) {\n if (!this.allowedInstallationOwners?.includes(owner)) {\n return { accessToken: undefined }; // An empty token allows anonymous access to public repos\n }\n }\n\n // Go and grab an access token for the app scoped to a repository if provided, if not use the organisation installation.\n return this.cache.getOrCreateToken(owner, repo, async () => {\n const { installationId, suspended } = await this.getInstallationData(\n owner,\n );\n if (suspended) {\n throw new Error(`The GitHub application for ${owner} is suspended`);\n }\n\n const result = await this.appClient.apps.createInstallationAccessToken({\n installation_id: installationId,\n headers: HEADERS,\n });\n\n let repositoryNames;\n\n if (result.data.repository_selection === 'selected') {\n const installationClient = new Octokit({\n baseUrl: this.baseUrl,\n auth: result.data.token,\n });\n const repos = await installationClient.paginate(\n installationClient.apps.listReposAccessibleToInstallation,\n );\n // The return type of the paginate method is incorrect.\n const repositories: RestEndpointMethodTypes['apps']['listReposAccessibleToInstallation']['response']['data']['repositories'] =\n repos.repositories ?? repos;\n\n repositoryNames = repositories.map(repository => repository.name);\n }\n return {\n token: result.data.token,\n expiresAt: DateTime.fromISO(result.data.expires_at),\n repositories: repositoryNames,\n };\n });\n }\n\n getInstallations(): Promise<\n RestEndpointMethodTypes['apps']['listInstallations']['response']['data']\n > {\n return this.appClient.paginate(this.appClient.apps.listInstallations);\n }\n\n private async getInstallationData(owner: string): Promise<InstallationData> {\n const allInstallations = await this.getInstallations();\n const installation = allInstallations.find(\n inst =>\n inst.account &&\n 'login' in inst.account &&\n inst.account.login?.toLocaleLowerCase('en-US') ===\n owner.toLocaleLowerCase('en-US'),\n );\n if (installation) {\n return {\n installationId: installation.id,\n suspended: Boolean(installation.suspended_by),\n };\n }\n const notFoundError = new Error(\n `No app installation found for ${owner} in ${this.baseAuthConfig.appId}`,\n );\n notFoundError.name = 'NotFoundError';\n throw notFoundError;\n }\n}\n\n/**\n * Corresponds to a Github installation which internally could hold several GitHub Apps.\n *\n * @public\n */\nexport class GithubAppCredentialsMux {\n private readonly apps: GithubAppManager[];\n\n constructor(config: GithubIntegrationConfig) {\n this.apps =\n config.apps?.map(ac => new GithubAppManager(ac, config.apiBaseUrl)) ?? [];\n }\n\n async getAllInstallations(): Promise<\n RestEndpointMethodTypes['apps']['listInstallations']['response']['data']\n > {\n if (!this.apps.length) {\n return [];\n }\n\n const installs = await Promise.all(\n this.apps.map(app => app.getInstallations()),\n );\n\n return installs.flat();\n }\n\n async getAppToken(owner: string, repo?: string): Promise<string | undefined> {\n if (this.apps.length === 0) {\n return undefined;\n }\n\n const results = await Promise.all(\n this.apps.map(app =>\n app.getInstallationCredentials(owner, repo).then(\n credentials => ({ credentials, error: undefined }),\n error => ({ credentials: undefined, error }),\n ),\n ),\n );\n\n const result = results.find(\n resultItem => resultItem.credentials?.accessToken,\n );\n if (result) {\n return result.credentials!.accessToken;\n }\n\n const errors = results.map(r => r.error);\n const notNotFoundError = errors.find(err => err?.name !== 'NotFoundError');\n if (notNotFoundError) {\n throw notNotFoundError;\n }\n\n return undefined;\n }\n}\n\n/**\n * Handles the creation and caching of credentials for GitHub integrations.\n *\n * @public\n * @remarks\n *\n * TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake\n */\nexport class SingleInstanceGithubCredentialsProvider\n implements GithubCredentialsProvider\n{\n static create: (\n config: GithubIntegrationConfig,\n ) => GithubCredentialsProvider = config => {\n return new SingleInstanceGithubCredentialsProvider(\n new GithubAppCredentialsMux(config),\n config.token,\n );\n };\n\n private constructor(\n private readonly githubAppCredentialsMux: GithubAppCredentialsMux,\n private readonly token?: string,\n ) {}\n\n /**\n * Returns {@link GithubCredentials} for a given URL.\n *\n * @remarks\n *\n * Consecutive calls to this method with the same URL will return cached\n * credentials.\n *\n * The shortest lifetime for a token returned is 10 minutes.\n *\n * @example\n * ```ts\n * const { token, headers } = await getCredentials({\n * url: 'github.com/backstage/foobar'\n * })\n * ```\n *\n * @param opts - The organization or repository URL\n * @returns A promise of {@link GithubCredentials}.\n */\n async getCredentials(opts: { url: string }): Promise<GithubCredentials> {\n const parsed = parseGitUrl(opts.url);\n\n const owner = parsed.owner || parsed.name;\n const repo = parsed.owner ? parsed.name : undefined;\n\n let type: GithubCredentialType = 'app';\n let token = await this.githubAppCredentialsMux.getAppToken(owner, repo);\n if (!token) {\n type = 'token';\n token = this.token;\n }\n\n return {\n headers: token ? { Authorization: `Bearer ${token}` } : undefined,\n token,\n type,\n };\n }\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GithubCredentials, GithubCredentialsProvider } from './types';\nimport { ScmIntegrationRegistry } from '../registry';\nimport { SingleInstanceGithubCredentialsProvider } from './SingleInstanceGithubCredentialsProvider';\n\n/**\n * Handles the creation and caching of credentials for GitHub integrations.\n *\n * @public\n * @remarks\n *\n * TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake\n */\nexport class DefaultGithubCredentialsProvider\n implements GithubCredentialsProvider\n{\n static fromIntegrations(integrations: ScmIntegrationRegistry) {\n const credentialsProviders: Map<string, GithubCredentialsProvider> =\n new Map<string, GithubCredentialsProvider>();\n\n integrations.github.list().forEach(integration => {\n const credentialsProvider =\n SingleInstanceGithubCredentialsProvider.create(integration.config);\n credentialsProviders.set(integration.config.host, credentialsProvider);\n });\n return new DefaultGithubCredentialsProvider(credentialsProviders);\n }\n\n private constructor(\n private readonly providers: Map<string, GithubCredentialsProvider>,\n ) {}\n\n /**\n * Returns {@link GithubCredentials} for a given URL.\n *\n * @remarks\n *\n * Consecutive calls to this method with the same URL will return cached\n * credentials.\n *\n * The shortest lifetime for a token returned is 10 minutes.\n *\n * @example\n * ```ts\n * const { token, headers } = await getCredentials({\n * url: 'https://github.com/backstage/foobar'\n * })\n *\n * const { token, headers } = await getCredentials({\n * url: 'https://github.com/backstage'\n * })\n * ```\n *\n * @param opts - The organization or repository URL\n * @returns A promise of {@link GithubCredentials}.\n */\n async getCredentials(opts: { url: string }): Promise<GithubCredentials> {\n const parsed = new URL(opts.url);\n const provider = this.providers.get(parsed.host);\n\n if (!provider) {\n throw new Error(\n `There is no GitHub integration that matches ${opts.url}. Please add a configuration for an integration.`,\n );\n }\n\n return provider.getCredentials(opts);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport {\n RateLimitInfo,\n ScmIntegration,\n ScmIntegrationsFactory,\n} from '../types';\nimport {\n GithubIntegrationConfig,\n readGithubIntegrationConfigs,\n} from './config';\nimport { ConsumedResponse } from '@backstage/errors';\n\n/**\n * A GitHub based integration.\n *\n * @public\n */\nexport class GithubIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GithubIntegration> = ({ config }) => {\n const configs = readGithubIntegrationConfigs(\n config.getOptionalConfigArray('integrations.github') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GithubIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GithubIntegrationConfig) {}\n\n get type(): string {\n return 'github';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GithubIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n // GitHub uses blob URLs for files and tree urls for directory listings. But\n // there is a redirect from tree to blob for files, so we can always return\n // tree urls here.\n return replaceGithubUrlType(defaultScmResolveUrl(options), 'tree');\n }\n\n resolveEditUrl(url: string): string {\n return replaceGithubUrlType(url, 'edit');\n }\n\n parseRateLimitInfo(response: ConsumedResponse): RateLimitInfo {\n return {\n isRateLimited:\n response.status === 429 ||\n (response.status === 403 &&\n response.headers.get('x-ratelimit-remaining') === '0'),\n };\n }\n}\n\n/**\n * Takes a GitHub URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. \"blob\"\n * @public\n */\nexport function replaceGithubUrlType(\n url: string,\n type: 'blob' | 'tree' | 'edit',\n): string {\n return url.replace(\n /\\/\\/([^/]+)\\/([^/]+)\\/([^/]+)\\/(blob|tree|edit)\\//,\n (_, host, owner, repo) => {\n return `//${host}/${owner}/${repo}/${type}/`;\n },\n );\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\nconst GITLAB_HOST = 'gitlab.com';\nconst GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';\n\n/**\n * The configuration parameters for a single GitLab integration.\n *\n * @public\n */\nexport type GitLabIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. `gitlab.com`.\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g.\n * `https://gitlab.com/api/v4`, with no trailing slash.\n *\n * May be omitted specifically for public GitLab; then it will be deduced.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to this provider.\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed\n * into the GitLab client.\n *\n * If no baseUrl is provided, it will default to `https://${host}`\n */\n baseUrl: string;\n};\n\n/**\n * Reads a single GitLab integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGitLabIntegrationConfig(\n config: Config,\n): GitLabIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n let baseUrl = config.getOptionalString('baseUrl');\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === GITLAB_HOST) {\n apiBaseUrl = GITLAB_API_BASE_URL;\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid GitLab integration config, '${host}' is not a valid host`,\n );\n } else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`,\n );\n } else if (!isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid GitLab integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n return { host, token, apiBaseUrl, baseUrl };\n}\n\n/**\n * Reads a set of GitLab integration configs, and inserts some defaults for\n * public GitLab if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readGitLabIntegrationConfigs(\n configs: Config[],\n): GitLabIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readGitLabIntegrationConfig);\n\n // As a convenience we always make sure there's at least an unauthenticated\n // reader for public gitlab repos.\n if (!result.some(c => c.host === GITLAB_HOST)) {\n result.push({\n host: GITLAB_HOST,\n apiBaseUrl: GITLAB_API_BASE_URL,\n baseUrl: `https://${GITLAB_HOST}`,\n });\n }\n\n return result;\n}\n\n/**\n * Reads a GitLab integration config, and returns\n * relative path.\n *\n * @param config - GitLabIntegrationConfig object\n * @public\n */\nexport function getGitLabIntegrationRelativePath(\n config: GitLabIntegrationConfig,\n): string {\n let relativePath = '';\n if (config.host !== GITLAB_HOST) {\n relativePath = new URL(config.baseUrl).pathname;\n }\n return trimEnd(relativePath, '/');\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fetch from 'cross-fetch';\nimport {\n getGitLabIntegrationRelativePath,\n GitLabIntegrationConfig,\n} from './config';\n\n/**\n * Given a URL pointing to a file on a provider, returns a URL that is suitable\n * for fetching the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://gitlab.example.com/a/b/blob/master/c.yaml\n * to: https://gitlab.com/api/v4/projects/projectId/repository/c.yaml?ref=master\n * -or-\n * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport async function getGitLabFileFetchUrl(\n url: string,\n config: GitLabIntegrationConfig,\n): Promise<string> {\n const projectID = await getProjectId(url, config);\n return buildProjectUrl(url, projectID, config).toString();\n}\n\n/**\n * Gets the request options necessary to make requests to a given provider.\n *\n * @param config - The relevant provider config\n * @public\n */\nexport function getGitLabRequestOptions(\n config: GitLabIntegrationConfig,\n token?: string,\n): { headers: Record<string, string> } {\n if (token) {\n // If token comes from the user and starts with \"gl\", it's a private token (see https://docs.gitlab.com/ee/security/token_overview.html#token-prefixes)\n return {\n headers: token.startsWith('gl')\n ? { 'PRIVATE-TOKEN': token }\n : { Authorization: `Bearer ${token}` }, // Otherwise, it's a bearer token\n };\n }\n\n // If token not provided, fetch the integration token\n const { token: configToken = '' } = config;\n return {\n headers: { 'PRIVATE-TOKEN': configToken },\n };\n}\n\n// Converts\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch\nexport function buildProjectUrl(\n target: string,\n projectID: Number,\n config: GitLabIntegrationConfig,\n): URL {\n try {\n const url = new URL(target);\n\n const branchAndFilePath = url.pathname\n .split('/blob/')\n .slice(1)\n .join('/blob/');\n const [branch, ...filePath] = branchAndFilePath.split('/');\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n url.pathname = [\n ...(relativePath ? [relativePath] : []),\n 'api/v4/projects',\n projectID,\n 'repository/files',\n encodeURIComponent(decodeURIComponent(filePath.join('/'))),\n 'raw',\n ].join('/');\n\n url.search = `?ref=${branch}`;\n\n return url;\n } catch (e) {\n throw new Error(`Incorrect url: ${target}, ${e}`);\n }\n}\n\n// Convert\n// from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n// to: The project ID that corresponds to the URL\nexport async function getProjectId(\n target: string,\n config: GitLabIntegrationConfig,\n): Promise<number> {\n const url = new URL(target);\n\n if (!url.pathname.includes('/blob/')) {\n throw new Error(\n `Failed converting ${url.pathname} to a project id. Url path must include /blob/.`,\n );\n }\n\n try {\n let repo = url.pathname.split('/-/blob/')[0].split('/blob/')[0];\n\n // Get gitlab relative path\n const relativePath = getGitLabIntegrationRelativePath(config);\n\n // Check relative path exist and replace it if it's the case.\n if (relativePath) {\n repo = repo.replace(relativePath, '');\n }\n\n // Convert\n // to: https://gitlab.com/api/v4/projects/groupA%2Fteams%2FsubgroupA%2FteamA%2Frepo\n const repoIDLookup = new URL(\n `${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(\n repo.replace(/^\\//, ''),\n )}`,\n );\n\n const response = await fetch(\n repoIDLookup.toString(),\n getGitLabRequestOptions(config),\n );\n\n const data = await response.json();\n\n if (!response.ok) {\n throw new Error(\n `GitLab Error '${data.error}', ${data.error_description}`,\n );\n }\n\n return Number(data.id);\n } catch (e) {\n throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n GitLabIntegrationConfig,\n readGitLabIntegrationConfigs,\n} from './config';\n\n/**\n * A GitLab based integration.\n *\n * @public\n */\nexport class GitLabIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GitLabIntegration> = ({ config }) => {\n const configs = readGitLabIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gitlab') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GitLabIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GitLabIntegrationConfig) {}\n\n get type(): string {\n return 'gitlab';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GitLabIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return replaceGitLabUrlType(url, 'edit');\n }\n}\n\n/**\n * Takes a GitLab URL and replaces the type part (blob, tree etc).\n *\n * @param url - The original URL\n * @param type - The desired type, e.g. 'blob', 'tree', 'edit'\n * @public\n */\nexport function replaceGitLabUrlType(\n url: string,\n type: 'blob' | 'tree' | 'edit',\n): string {\n return url.replace(/\\/\\-\\/(blob|tree|edit)\\//, `/-/${type}/`);\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GitLabIntegrationConfig } from './config';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\nexport class SingleInstanceGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static create: (\n config: GitLabIntegrationConfig,\n ) => GitlabCredentialsProvider = config => {\n return new SingleInstanceGitlabCredentialsProvider(config.token);\n };\n\n private constructor(private readonly token?: string) {}\n\n async getCredentials(_opts: { url: string }): Promise<GitlabCredentials> {\n if (!this.token) {\n return {};\n }\n\n return {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n token: this.token,\n };\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScmIntegrationRegistry } from '../registry';\nimport { SingleInstanceGitlabCredentialsProvider } from './SingleInstanceGitlabCredentialsProvider';\nimport { GitlabCredentials, GitlabCredentialsProvider } from './types';\n\n/**\n * Handles the creation and caching of credentials for GitLab integrations.\n *\n * @public\n */\nexport class DefaultGitlabCredentialsProvider\n implements GitlabCredentialsProvider\n{\n static fromIntegrations(integrations: ScmIntegrationRegistry) {\n const credentialsProviders: Map<string, GitlabCredentialsProvider> =\n new Map<string, GitlabCredentialsProvider>();\n\n integrations.gitlab.list().forEach(integration => {\n const credentialsProvider =\n SingleInstanceGitlabCredentialsProvider.create(integration.config);\n credentialsProviders.set(integration.config.host, credentialsProvider);\n });\n return new DefaultGitlabCredentialsProvider(credentialsProviders);\n }\n\n private constructor(\n private readonly providers: Map<string, GitlabCredentialsProvider>,\n ) {}\n\n async getCredentials(opts: { url: string }): Promise<GitlabCredentials> {\n const parsed = new URL(opts.url);\n const provider = this.providers.get(parsed.host);\n\n if (!provider) {\n throw new Error(\n `There is no GitLab integration that matches ${opts.url}. Please add a configuration for an integration.`,\n );\n }\n\n return provider.getCredentials(opts);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\n/**\n * The configuration parameters for a single Google Cloud Storage provider.\n *\n * @public\n */\nexport type GoogleGcsIntegrationConfig = {\n /**\n * Service account email used to authenticate requests.\n */\n clientEmail?: string;\n /**\n * Service account private key used to authenticate requests.\n */\n privateKey?: string;\n};\n\n/**\n * Reads a single Google GCS integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readGoogleGcsIntegrationConfig(\n config: Config,\n): GoogleGcsIntegrationConfig {\n if (!config) {\n return {};\n }\n\n if (!config.has('clientEmail') && !config.has('privateKey')) {\n return {};\n }\n\n const privateKey = config.getString('privateKey').split('\\\\n').join('\\n');\n\n const clientEmail = config.getString('clientEmail');\n return { clientEmail: clientEmail, privateKey: privateKey };\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { isValidHost } from '../helpers';\n\n/**\n * The configuration for a single Harness integration.\n *\n * @public\n */\nexport type HarnessIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"app.harness.io\"\n */\n host: string;\n /**\n * The password or http token to use for authentication.\n */\n token?: string;\n /**\n * The API key to use for authentication.\n */\n apiKey?: string;\n};\n\n/**\n * Parses a location config block for use in HarnessIntegration\n *\n * @public\n */\nexport function readHarnessConfig(config: Config): HarnessIntegrationConfig {\n const host = config.getString('host');\n const token = config.getOptionalString('token');\n const apiKey = config.getOptionalString('apiKey');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Harness Code integration config, '${host}' is not a valid host`,\n );\n }\n\n return {\n host,\n apiKey,\n token,\n };\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { HarnessIntegrationConfig } from './config';\n\n/**\n * Given a URL pointing to a file, returns a URL\n * for editing the contents of the data.\n *\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/a/b/src/branchname/path/to/c.yaml\n * or: https://app.harness.io/a/b/_edit/branchname/path/to/c.yaml\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessEditContentsUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n return `${parsedUrl.baseUrl}/ng/account/${parsedUrl.accountId}/module/code${\n parsedUrl.orgName !== '' ? `/orgs/${parsedUrl.orgName}` : ''\n }${\n parsedUrl.projectName !== '' ? `/projects/${parsedUrl.projectName}` : ''\n }/repos/${parsedUrl.repoName}/files/${parsedUrl.branch}/~/${parsedUrl.path}`;\n}\n\n/**\n * Given a file path URL,\n * it returns an API URL which returns the contents of the file .\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projName/repos/repoName/files/refMain/~/all-apis.yaml\n * https://qa.harness.io/ng/account/bDCAuAjFSJCLFj_0ug3lCg/module/code/orgs/HiteshTest/repos/impoorter/files/main/~/catalog.yaml\n * to: https://app.harness.io/gateway/code/api/v1/repos/accountId/orgName/projName/repoName/+/content/all-apis.yaml?routingId=accountId&include_commit=false&ref=refMain\n *\n * @param url - A URL pointing to a file\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessFileContentsUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/raw/${parsedUrl.path}?routingId=${parsedUrl.accountId}&git_ref=refs/heads/${parsedUrl.refString}`;\n\n return constructedUrl;\n}\n\n/**\n * Given a URL pointing to a repository/path, returns a URL\n * for archive contents of the repository.\n *\n * @remarks\n *\n * Converts\n * from: https://qa.harness.io/ng/account/accountId/module/code/orgs/orgId/projects/projectName/repos/repoName/files/branch/~/fileName\n * to: https://qa.harness.io/gateway/code/api/v1/repos/accountId/orgId/projectName/repoName/+/archive/branch.zip?routingId=accountId\n *\n * @param url - A URL pointing to a repository/path\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessArchiveUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/archive/${parsedUrl.branch}.zip?routingId=${parsedUrl.accountId}`;\n\n return constructedUrl;\n}\n\n/**\n * Given a URL pointing to a repository branch, returns a URL\n * for latest commit information.\n *\n * @remarks\n *\n * Converts\n * from: https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projectName/repos/repoName/files/branchName\n * to: https://app.harness.io/gateway/code/api/v1/repos/accountId/orgName/projectName/repoName/+/content?routingId=accountId&include_commit=true&git_ref=refs/heads/branchName\n *\n * @param url - A URL pointing to a repository branch\n * @param config - The relevant provider config\n * @public\n */\nexport function getHarnessLatestCommitUrl(\n config: HarnessIntegrationConfig,\n url: string,\n) {\n const parsedUrl = parseHarnessUrl(config, url);\n\n let constructedUrl = `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}`;\n\n if (parsedUrl.orgName) {\n constructedUrl += `/${parsedUrl.orgName}`;\n }\n\n if (parsedUrl.projectName) {\n constructedUrl += `/${parsedUrl.projectName}`;\n }\n\n constructedUrl += `/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;\n\n return constructedUrl;\n}\n\n/**\n * Return request headers for a Harness Code provider.\n *\n * @param config - A Harness Code provider config\n * @public\n */\nexport function getHarnessRequestOptions(config: HarnessIntegrationConfig): {\n headers?: Record<string, string>;\n} {\n const headers: Record<string, string> = {};\n const { token, apiKey } = config;\n\n if (apiKey) {\n headers['x-api-key'] = apiKey;\n } else if (token) {\n headers.Authorization = `Bearer ${token}`;\n }\n\n return {\n headers,\n };\n}\n\n/**\n * Return parsed git url properties.\n *\n * @param config - A Harness provider config\n * @param url - A URL pointing to a repository\n * @public\n */\nexport function parseHarnessUrl(\n config: HarnessIntegrationConfig,\n url: string,\n): {\n baseUrl: string;\n accountId: string;\n orgName: string;\n projectName: string;\n refString: string;\n repoName: string;\n path: string;\n refDashStr: string;\n branch: string;\n} {\n const baseUrl = `https://${config.host}`;\n try {\n const pathUrl = new URL(url);\n const pathSegments = pathUrl.pathname\n .split('/')\n .filter(segment => segment !== '');\n const urlParts = pathUrl.pathname.split('/');\n\n const accountIdIndex =\n pathSegments.findIndex(segment => segment === 'account') + 1;\n const accountId = pathSegments[accountIdIndex];\n\n const orgNameIndex = pathSegments.findIndex(segment => segment === 'orgs');\n const orgName = orgNameIndex !== -1 ? pathSegments[orgNameIndex + 1] : '';\n const projectNameIndex = pathSegments.findIndex(\n segment => segment === 'projects',\n );\n\n const projectName =\n projectNameIndex !== -1 ? pathSegments[projectNameIndex + 1] : '';\n // Adjust repoNameIndex to correctly identify the repository name\n const repoNameIndex =\n pathSegments.findIndex(\n (segment, index) =>\n segment === 'repos' &&\n index > Math.max(accountIdIndex, orgNameIndex, projectNameIndex),\n ) + 1;\n const repoName = pathSegments[repoNameIndex];\n const refAndPath = urlParts.slice(\n urlParts.findIndex(i => i === 'files' || i === 'edit') + 1,\n );\n const refIndex = refAndPath.findIndex(item => item === '~');\n\n const refString = refAndPath.slice(0, refIndex).join('/');\n const pathWithoutSlash =\n refIndex !== -1\n ? refAndPath\n .slice(refIndex + 1)\n .join('/')\n .replace(/^\\//, '')\n : '';\n\n return {\n baseUrl: baseUrl,\n accountId: accountId,\n orgName: orgName,\n projectName: projectName,\n refString: refString,\n path: pathWithoutSlash,\n repoName: repoName,\n refDashStr: refAndPath.slice(0, refIndex).join('-'),\n branch:\n refIndex !== -1\n ? refAndPath.slice(0, refIndex).join('/')\n : refAndPath.join('/'),\n };\n } catch (e) {\n throw new Error(`Incorrect URL: ${url}, ${e}`);\n }\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { HarnessIntegrationConfig, readHarnessConfig } from './config';\nimport { getHarnessEditContentsUrl } from './core';\n\n/**\n * A Harness Code based integration.\n *\n * @public\n */\nexport class HarnessIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<HarnessIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.harness') ?? [];\n const harnessConfigs = configs.map(c => readHarnessConfig(c));\n\n return basicIntegrations(\n harnessConfigs.map(c => new HarnessIntegration(c)),\n (harness: HarnessIntegration) => harness.config.host,\n );\n };\n\n constructor(readonly config: HarnessIntegrationConfig) {}\n\n get type(): string {\n return 'harness';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getHarnessEditContentsUrl(this.config, url);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { AwsS3Integration } from './awsS3/AwsS3Integration';\nimport { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration';\nimport { AzureIntegration } from './azure/AzureIntegration';\nimport { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration';\nimport { BitbucketIntegration } from './bitbucket/BitbucketIntegration';\nimport { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration';\nimport { GerritIntegration } from './gerrit/GerritIntegration';\nimport { GithubIntegration } from './github/GithubIntegration';\nimport { GitLabIntegration } from './gitlab/GitLabIntegration';\nimport { defaultScmResolveUrl } from './helpers';\nimport { ScmIntegration, ScmIntegrationsGroup } from './types';\nimport { ScmIntegrationRegistry } from './registry';\nimport { GiteaIntegration } from './gitea';\nimport { HarnessIntegration } from './harness/HarnessIntegration';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\n /**\n * @deprecated in favor of `bitbucketCloud` and `bitbucketServer`\n */\n bitbucket: ScmIntegrationsGroup<BitbucketIntegration>;\n bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;\n bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;\n gerrit: ScmIntegrationsGroup<GerritIntegration>;\n github: ScmIntegrationsGroup<GithubIntegration>;\n gitlab: ScmIntegrationsGroup<GitLabIntegration>;\n gitea: ScmIntegrationsGroup<GiteaIntegration>;\n harness: ScmIntegrationsGroup<HarnessIntegration>;\n}\n\n/**\n * Exposes the set of supported integrations.\n *\n * @public\n */\nexport class ScmIntegrations implements ScmIntegrationRegistry {\n private readonly byType: IntegrationsByType;\n\n static fromConfig(config: Config): ScmIntegrations {\n return new ScmIntegrations({\n awsS3: AwsS3Integration.factory({ config }),\n awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),\n azure: AzureIntegration.factory({ config }),\n bitbucket: BitbucketIntegration.factory({ config }),\n bitbucketCloud: BitbucketCloudIntegration.factory({ config }),\n bitbucketServer: BitbucketServerIntegration.factory({ config }),\n gerrit: GerritIntegration.factory({ config }),\n github: GithubIntegration.factory({ config }),\n gitlab: GitLabIntegration.factory({ config }),\n gitea: GiteaIntegration.factory({ config }),\n harness: HarnessIntegration.factory({ config }),\n });\n }\n\n constructor(integrationsByType: IntegrationsByType) {\n this.byType = integrationsByType;\n }\n\n get awsS3(): ScmIntegrationsGroup<AwsS3Integration> {\n return this.byType.awsS3;\n }\n\n get awsCodeCommit(): ScmIntegrationsGroup<AwsCodeCommitIntegration> {\n return this.byType.awsCodeCommit;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\n }\n\n /**\n * @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`\n */\n get bitbucket(): ScmIntegrationsGroup<BitbucketIntegration> {\n return this.byType.bitbucket;\n }\n\n get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration> {\n return this.byType.bitbucketCloud;\n }\n\n get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration> {\n return this.byType.bitbucketServer;\n }\n\n get gerrit(): ScmIntegrationsGroup<GerritIntegration> {\n return this.byType.gerrit;\n }\n\n get github(): ScmIntegrationsGroup<GithubIntegration> {\n return this.byType.github;\n }\n\n get gitlab(): ScmIntegrationsGroup<GitLabIntegration> {\n return this.byType.gitlab;\n }\n\n get gitea(): ScmIntegrationsGroup<GiteaIntegration> {\n return this.byType.gitea;\n }\n\n get harness(): ScmIntegrationsGroup<HarnessIntegration> {\n return this.byType.harness;\n }\n\n list(): ScmIntegration[] {\n return Object.values(this.byType).flatMap(\n i => i.list() as ScmIntegration[],\n );\n }\n\n byUrl(url: string | URL): ScmIntegration | undefined {\n let candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\n\n // Do not return deprecated integrations if there are other options\n if (candidates.length > 1) {\n const filteredCandidates = candidates.filter(\n x => !(x instanceof BitbucketIntegration),\n );\n if (filteredCandidates.length !== 0) {\n candidates = filteredCandidates;\n }\n }\n\n return candidates[0];\n }\n\n byHost(host: string): ScmIntegration | undefined {\n return Object.values(this.byType)\n .map(i => i.byHost(host))\n .find(Boolean);\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const integration = this.byUrl(options.base);\n if (!integration) {\n return defaultScmResolveUrl(options);\n }\n\n return integration.resolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n const integration = this.byUrl(url);\n if (!integration) {\n return url;\n }\n\n return integration.resolveEditUrl(url);\n }\n}\n"],"names":["parseGitUrl","trimEnd","ClientSecretCredential","ManagedIdentityCredential","DefaultAzureCredential","fetch","trimStart","takeWhile","join","DateTime","Octokit","createAppAuth"],"mappings":";;;;;;;;;;;;;;;AAqBO,SAAS,YAAY,IAAuB,EAAA;AACjD,EAAM,MAAA,KAAA,GAAQ,IAAI,GAAA,CAAI,oBAAoB,CAAA,CAAA;AAC1C,EAAA,KAAA,CAAM,IAAO,GAAA,IAAA,CAAA;AACb,EAAA,OAAO,MAAM,IAAS,KAAA,IAAA,CAAA;AACxB,CAAA;AAGO,SAAS,WAAW,GAAsB,EAAA;AAC/C,EAAI,IAAA;AAEF,IAAA,IAAI,IAAI,GAAG,CAAA,CAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACD,CAAA,MAAA;AACN,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA;AAEgB,SAAA,iBAAA,CACd,cACA,OACyB,EAAA;AACzB,EAAO,OAAA;AAAA,IACL,IAAY,GAAA;AACV,MAAO,OAAA,YAAA,CAAA;AAAA,KACT;AAAA,IACA,MAAM,GAAkC,EAAA;AACtC,MAAI,IAAA;AACF,QAAA,MAAM,SAAS,O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