@backstage/integration 1.21.0-next.0 → 2.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/config.d.ts +3 -60
- package/dist/ScmIntegrations.cjs.js +1 -17
- package/dist/ScmIntegrations.cjs.js.map +1 -1
- package/dist/ScmIntegrations.esm.js +1 -17
- package/dist/ScmIntegrations.esm.js.map +1 -1
- package/dist/azure/config.cjs.js +14 -35
- package/dist/azure/config.cjs.js.map +1 -1
- package/dist/azure/config.esm.js +14 -35
- package/dist/azure/config.esm.js.map +1 -1
- package/dist/bitbucketCloud/core.cjs.js +3 -2
- package/dist/bitbucketCloud/core.cjs.js.map +1 -1
- package/dist/bitbucketCloud/core.esm.js +3 -2
- package/dist/bitbucketCloud/core.esm.js.map +1 -1
- package/dist/bitbucketServer/core.cjs.js +8 -2
- package/dist/bitbucketServer/core.cjs.js.map +1 -1
- package/dist/bitbucketServer/core.esm.js +8 -2
- package/dist/bitbucketServer/core.esm.js.map +1 -1
- package/dist/gerrit/core.cjs.js +6 -33
- package/dist/gerrit/core.cjs.js.map +1 -1
- package/dist/gerrit/core.esm.js +7 -32
- package/dist/gerrit/core.esm.js.map +1 -1
- package/dist/github/core.cjs.js +2 -17
- package/dist/github/core.cjs.js.map +1 -1
- package/dist/github/core.esm.js +3 -13
- package/dist/github/core.esm.js.map +1 -1
- package/dist/helpers.cjs.js +23 -1
- package/dist/helpers.cjs.js.map +1 -1
- package/dist/helpers.esm.js +23 -2
- package/dist/helpers.esm.js.map +1 -1
- package/dist/index.cjs.js +61 -76
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -222
- package/dist/index.esm.js +2 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/azure/deprecated.cjs.js +0 -26
- package/dist/azure/deprecated.cjs.js.map +0 -1
- package/dist/azure/deprecated.esm.js +0 -24
- package/dist/azure/deprecated.esm.js.map +0 -1
- package/dist/bitbucket/BitbucketIntegration.cjs.js +0 -65
- package/dist/bitbucket/BitbucketIntegration.cjs.js.map +0 -1
- package/dist/bitbucket/BitbucketIntegration.esm.js +0 -59
- package/dist/bitbucket/BitbucketIntegration.esm.js.map +0 -1
- package/dist/bitbucket/config.cjs.js +0 -48
- package/dist/bitbucket/config.cjs.js.map +0 -1
- package/dist/bitbucket/config.esm.js +0 -45
- package/dist/bitbucket/config.esm.js.map +0 -1
- package/dist/bitbucket/core.cjs.js +0 -95
- package/dist/bitbucket/core.cjs.js.map +0 -1
- package/dist/bitbucket/core.esm.js +0 -85
- package/dist/bitbucket/core.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @backstage/integration
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1513a0b: Fixed a security vulnerability where path traversal sequences in SCM URLs could be used to access unintended API endpoints using server-side integration credentials.
|
|
8
|
+
|
|
9
|
+
## 2.0.0-next.1
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 527cf88: **BREAKING** Removed deprecated Azure DevOps, Bitbucket, Gerrit and GitHub code:
|
|
14
|
+
|
|
15
|
+
- For Azure DevOps, the long deprecated `token` string and `credential` object have been removed from the `config.d.ts`. Use the `credentials` array object instead.
|
|
16
|
+
- For Bitbucket, the long deprecated `bitbucket` object has been removed from the `config.d.ts`. Use the `bitbucketCloud` or `bitbucketServer` objects instead.
|
|
17
|
+
- For Gerrit, the `parseGerritGitilesUrl` function has been removed, use `parseGitilesUrlRef` instead. The `buildGerritGitilesArchiveUrl` function has also been removed, use `buildGerritGitilesArchiveUrlFromLocation` instead.
|
|
18
|
+
- For GitHub, the `getGitHubRequestOptions` function has been removed.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 993a598: Fixed Azure integration config schema visibility annotations to use per-field `@visibility secret` instead of `@deepVisibility secret` on parent objects, so that non-secret fields like `clientId`, `tenantId`, `organizations`, and `managedIdentityClientId` are no longer incorrectly marked as secret.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @backstage/config@1.3.6
|
|
25
|
+
- @backstage/errors@1.2.7
|
|
26
|
+
|
|
3
27
|
## 1.21.0-next.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
package/config.d.ts
CHANGED
|
@@ -27,40 +27,20 @@ export interface Config {
|
|
|
27
27
|
* @visibility frontend
|
|
28
28
|
*/
|
|
29
29
|
host: string;
|
|
30
|
-
/**
|
|
31
|
-
* Token used to authenticate requests.
|
|
32
|
-
* @visibility secret
|
|
33
|
-
* @deprecated Use `credentials` instead.
|
|
34
|
-
*/
|
|
35
|
-
token?: string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The credential to use for requests.
|
|
39
|
-
*
|
|
40
|
-
* If no credential is specified anonymous access is used.
|
|
41
|
-
*
|
|
42
|
-
* @deepVisibility secret
|
|
43
|
-
* @deprecated Use `credentials` instead.
|
|
44
|
-
*/
|
|
45
|
-
credential?: {
|
|
46
|
-
clientId?: string;
|
|
47
|
-
clientSecret?: string;
|
|
48
|
-
tenantId?: string;
|
|
49
|
-
personalAccessToken?: string;
|
|
50
|
-
};
|
|
51
30
|
|
|
52
31
|
/**
|
|
53
32
|
* The credentials to use for requests. If multiple credentials are specified the first one that matches the organization is used.
|
|
54
33
|
* If no organization matches the first credential without an organization is used.
|
|
55
34
|
*
|
|
56
35
|
* If no credentials are specified at all, either a default credential (for Azure DevOps) or anonymous access (for Azure DevOps Server) is used.
|
|
57
|
-
* @deepVisibility secret
|
|
58
36
|
*/
|
|
59
37
|
credentials?: {
|
|
60
38
|
organizations?: string[];
|
|
61
39
|
clientId?: string;
|
|
40
|
+
/** @visibility secret */
|
|
62
41
|
clientSecret?: string;
|
|
63
42
|
tenantId?: string;
|
|
43
|
+
/** @visibility secret */
|
|
64
44
|
personalAccessToken?: string;
|
|
65
45
|
managedIdentityClientId?: string;
|
|
66
46
|
}[];
|
|
@@ -111,7 +91,6 @@ export interface Config {
|
|
|
111
91
|
endpoint?: string;
|
|
112
92
|
/**
|
|
113
93
|
* Optional credential to use for Azure Active Directory authentication.
|
|
114
|
-
* @deepVisibility secret
|
|
115
94
|
*/
|
|
116
95
|
aadCredential?: {
|
|
117
96
|
/**
|
|
@@ -126,48 +105,12 @@ export interface Config {
|
|
|
126
105
|
|
|
127
106
|
/**
|
|
128
107
|
* The client secret for the Azure AD application.
|
|
108
|
+
* @visibility secret
|
|
129
109
|
*/
|
|
130
110
|
clientSecret: string;
|
|
131
111
|
};
|
|
132
112
|
}>;
|
|
133
113
|
|
|
134
|
-
/**
|
|
135
|
-
* Integration configuration for Bitbucket
|
|
136
|
-
* @deprecated replaced by bitbucketCloud and bitbucketServer
|
|
137
|
-
*/
|
|
138
|
-
bitbucket?: Array<{
|
|
139
|
-
/**
|
|
140
|
-
* The hostname of the given Bitbucket instance
|
|
141
|
-
* @visibility frontend
|
|
142
|
-
*/
|
|
143
|
-
host: string;
|
|
144
|
-
/**
|
|
145
|
-
* Token used to authenticate requests.
|
|
146
|
-
* @visibility secret
|
|
147
|
-
*/
|
|
148
|
-
token?: string;
|
|
149
|
-
/**
|
|
150
|
-
* The base url for the Bitbucket API, for example https://api.bitbucket.org/2.0
|
|
151
|
-
* @visibility frontend
|
|
152
|
-
*/
|
|
153
|
-
apiBaseUrl?: string;
|
|
154
|
-
/**
|
|
155
|
-
* The username to use for authenticated requests.
|
|
156
|
-
* @visibility secret
|
|
157
|
-
*/
|
|
158
|
-
username?: string;
|
|
159
|
-
/**
|
|
160
|
-
* Bitbucket app password used to authenticate requests.
|
|
161
|
-
* @visibility secret
|
|
162
|
-
*/
|
|
163
|
-
appPassword?: string;
|
|
164
|
-
/**
|
|
165
|
-
* PGP signing key for signing commits.
|
|
166
|
-
* @visibility secret
|
|
167
|
-
*/
|
|
168
|
-
commitSigningKey?: string;
|
|
169
|
-
}>;
|
|
170
|
-
|
|
171
114
|
/** Integration configuration for Bitbucket Cloud */
|
|
172
115
|
bitbucketCloud?: Array<{
|
|
173
116
|
/**
|
|
@@ -4,7 +4,6 @@ var AwsS3Integration = require('./awsS3/AwsS3Integration.cjs.js');
|
|
|
4
4
|
var AwsCodeCommitIntegration = require('./awsCodeCommit/AwsCodeCommitIntegration.cjs.js');
|
|
5
5
|
var AzureIntegration = require('./azure/AzureIntegration.cjs.js');
|
|
6
6
|
var BitbucketCloudIntegration = require('./bitbucketCloud/BitbucketCloudIntegration.cjs.js');
|
|
7
|
-
var BitbucketIntegration = require('./bitbucket/BitbucketIntegration.cjs.js');
|
|
8
7
|
var BitbucketServerIntegration = require('./bitbucketServer/BitbucketServerIntegration.cjs.js');
|
|
9
8
|
var GerritIntegration = require('./gerrit/GerritIntegration.cjs.js');
|
|
10
9
|
var GithubIntegration = require('./github/GithubIntegration.cjs.js');
|
|
@@ -25,7 +24,6 @@ class ScmIntegrations {
|
|
|
25
24
|
awsCodeCommit: AwsCodeCommitIntegration.AwsCodeCommitIntegration.factory({ config }),
|
|
26
25
|
azureBlobStorage: AzureBlobStorageIntegration.AzureBlobStorageIntergation.factory({ config }),
|
|
27
26
|
azure: AzureIntegration.AzureIntegration.factory({ config }),
|
|
28
|
-
bitbucket: BitbucketIntegration.BitbucketIntegration.factory({ config }),
|
|
29
27
|
bitbucketCloud: BitbucketCloudIntegration.BitbucketCloudIntegration.factory({ config }),
|
|
30
28
|
bitbucketServer: BitbucketServerIntegration.BitbucketServerIntegration.factory({ config }),
|
|
31
29
|
gerrit: GerritIntegration.GerritIntegration.factory({ config }),
|
|
@@ -51,12 +49,6 @@ class ScmIntegrations {
|
|
|
51
49
|
get azure() {
|
|
52
50
|
return this.byType.azure;
|
|
53
51
|
}
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
|
|
56
|
-
*/
|
|
57
|
-
get bitbucket() {
|
|
58
|
-
return this.byType.bitbucket;
|
|
59
|
-
}
|
|
60
52
|
get bitbucketCloud() {
|
|
61
53
|
return this.byType.bitbucketCloud;
|
|
62
54
|
}
|
|
@@ -87,15 +79,7 @@ class ScmIntegrations {
|
|
|
87
79
|
);
|
|
88
80
|
}
|
|
89
81
|
byUrl(url) {
|
|
90
|
-
|
|
91
|
-
if (candidates.length > 1) {
|
|
92
|
-
const filteredCandidates = candidates.filter(
|
|
93
|
-
(x) => !(x instanceof BitbucketIntegration.BitbucketIntegration)
|
|
94
|
-
);
|
|
95
|
-
if (filteredCandidates.length !== 0) {
|
|
96
|
-
candidates = filteredCandidates;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
82
|
+
const candidates = Object.values(this.byType).map((i) => i.byUrl(url)).filter(Boolean);
|
|
99
83
|
return candidates[0];
|
|
100
84
|
}
|
|
101
85
|
byHost(host) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScmIntegrations.cjs.js","sources":["../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 { 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';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\nimport { GoogleGcsIntegration } from './googleGcs/GoogleGcsIntegration';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\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 googleGcs: ScmIntegrationsGroup<GoogleGcsIntegration>;\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 azureBlobStorage: AzureBlobStorageIntergation.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 googleGcs: GoogleGcsIntegration.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 azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\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 googleGcs(): ScmIntegrationsGroup<GoogleGcsIntegration> {\n return this.byType.googleGcs;\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":["AwsS3Integration","AwsCodeCommitIntegration","AzureBlobStorageIntergation","AzureIntegration","BitbucketIntegration","BitbucketCloudIntegration","BitbucketServerIntegration","GerritIntegration","GithubIntegration","GitLabIntegration","GiteaIntegration","GoogleGcsIntegration","HarnessIntegration","defaultScmResolveUrl"],"mappings":";;;;;;;;;;;;;;;;;;;AA+DO,MAAM,eAAA,CAAkD;AAAA,EAC5C,MAAA;AAAA,EAEjB,OAAO,WAAW,MAAA,EAAiC;AACjD,IAAA,OAAO,IAAI,eAAA,CAAgB;AAAA,MACzB,KAAA,EAAOA,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,aAAA,EAAeC,iDAAA,CAAyB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1D,gBAAA,EAAkBC,uDAAA,CAA4B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAChE,KAAA,EAAOC,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,SAAA,EAAWC,yCAAA,CAAqB,OAAA,C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,GAAa,kBAAA;AAAA,MACf;AAAA,IACF;AAEA,IAAA,OAAO,WAAW,CAAC,CAAA;AAAA,EACrB;AAAA,EAEA,OAAO,IAAA,EAA0C;AAC/C,IAAA,OAAO,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAC7B,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,MAAA,CAAO,IAAI,CAAC,CAAA,CACvB,KAAK,OAAO,CAAA;AAAA,EACjB;AAAA,EAEA,WAAW,OAAA,EAIA;AACT,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA;AAC3C,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAOS,6BAAqB,OAAO,CAAA;AAAA,IACrC;AAEA,IAAA,OAAO,WAAA,CAAY,WAAW,OAAO,CAAA;AAAA,EACvC;AAAA,EAEA,eAAe,GAAA,EAAqB;AAClC,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAClC,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,GAAA;AAAA,IACT;AAEA,IAAA,OAAO,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA,EACvC;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"ScmIntegrations.cjs.js","sources":["../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 { 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 { 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';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\nimport { GoogleGcsIntegration } from './googleGcs/GoogleGcsIntegration';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\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 googleGcs: ScmIntegrationsGroup<GoogleGcsIntegration>;\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 azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),\n azure: AzureIntegration.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 googleGcs: GoogleGcsIntegration.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 azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\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 googleGcs(): ScmIntegrationsGroup<GoogleGcsIntegration> {\n return this.byType.googleGcs;\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 const candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\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":["AwsS3Integration","AwsCodeCommitIntegration","AzureBlobStorageIntergation","AzureIntegration","BitbucketCloudIntegration","BitbucketServerIntegration","GerritIntegration","GithubIntegration","GitLabIntegration","GiteaIntegration","GoogleGcsIntegration","HarnessIntegration","defaultScmResolveUrl"],"mappings":";;;;;;;;;;;;;;;;;;AA0DO,MAAM,eAAA,CAAkD;AAAA,EAC5C,MAAA;AAAA,EAEjB,OAAO,WAAW,MAAA,EAAiC;AACjD,IAAA,OAAO,IAAI,eAAA,CAAgB;AAAA,MACzB,KAAA,EAAOA,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,aAAA,EAAeC,iDAAA,CAAyB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1D,gBAAA,EAAkBC,uDAAA,CAA4B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAChE,KAAA,EAAOC,iCAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,cAAA,EAAgBC,mDAAA,CAA0B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5D,eAAA,EAAiBC,qDAAA,CAA2B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC9D,MAAA,EAAQC,mCAAA,CAAkB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5C,MAAA,EAAQC,mCAAA,CAAkB,O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C,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,GAAA;AAAA,IACT;AAEA,IAAA,OAAO,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA,EACvC;AACF;;;;"}
|
|
@@ -2,7 +2,6 @@ import { AwsS3Integration } from './awsS3/AwsS3Integration.esm.js';
|
|
|
2
2
|
import { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration.esm.js';
|
|
3
3
|
import { AzureIntegration } from './azure/AzureIntegration.esm.js';
|
|
4
4
|
import { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration.esm.js';
|
|
5
|
-
import { BitbucketIntegration } from './bitbucket/BitbucketIntegration.esm.js';
|
|
6
5
|
import { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration.esm.js';
|
|
7
6
|
import { GerritIntegration } from './gerrit/GerritIntegration.esm.js';
|
|
8
7
|
import { GithubIntegration } from './github/GithubIntegration.esm.js';
|
|
@@ -23,7 +22,6 @@ class ScmIntegrations {
|
|
|
23
22
|
awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),
|
|
24
23
|
azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),
|
|
25
24
|
azure: AzureIntegration.factory({ config }),
|
|
26
|
-
bitbucket: BitbucketIntegration.factory({ config }),
|
|
27
25
|
bitbucketCloud: BitbucketCloudIntegration.factory({ config }),
|
|
28
26
|
bitbucketServer: BitbucketServerIntegration.factory({ config }),
|
|
29
27
|
gerrit: GerritIntegration.factory({ config }),
|
|
@@ -49,12 +47,6 @@ class ScmIntegrations {
|
|
|
49
47
|
get azure() {
|
|
50
48
|
return this.byType.azure;
|
|
51
49
|
}
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
|
|
54
|
-
*/
|
|
55
|
-
get bitbucket() {
|
|
56
|
-
return this.byType.bitbucket;
|
|
57
|
-
}
|
|
58
50
|
get bitbucketCloud() {
|
|
59
51
|
return this.byType.bitbucketCloud;
|
|
60
52
|
}
|
|
@@ -85,15 +77,7 @@ class ScmIntegrations {
|
|
|
85
77
|
);
|
|
86
78
|
}
|
|
87
79
|
byUrl(url) {
|
|
88
|
-
|
|
89
|
-
if (candidates.length > 1) {
|
|
90
|
-
const filteredCandidates = candidates.filter(
|
|
91
|
-
(x) => !(x instanceof BitbucketIntegration)
|
|
92
|
-
);
|
|
93
|
-
if (filteredCandidates.length !== 0) {
|
|
94
|
-
candidates = filteredCandidates;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
80
|
+
const candidates = Object.values(this.byType).map((i) => i.byUrl(url)).filter(Boolean);
|
|
97
81
|
return candidates[0];
|
|
98
82
|
}
|
|
99
83
|
byHost(host) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScmIntegrations.esm.js","sources":["../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 { 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 {
|
|
1
|
+
{"version":3,"file":"ScmIntegrations.esm.js","sources":["../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 { 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 { 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';\nimport { AzureBlobStorageIntergation } from './azureBlobStorage';\nimport { GoogleGcsIntegration } from './googleGcs/GoogleGcsIntegration';\n\n/**\n * The set of supported integrations.\n *\n * @public\n */\nexport interface IntegrationsByType {\n awsS3: ScmIntegrationsGroup<AwsS3Integration>;\n awsCodeCommit: ScmIntegrationsGroup<AwsCodeCommitIntegration>;\n azureBlobStorage: ScmIntegrationsGroup<AzureBlobStorageIntergation>;\n azure: ScmIntegrationsGroup<AzureIntegration>;\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 googleGcs: ScmIntegrationsGroup<GoogleGcsIntegration>;\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 azureBlobStorage: AzureBlobStorageIntergation.factory({ config }),\n azure: AzureIntegration.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 googleGcs: GoogleGcsIntegration.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 azureBlobStorage(): ScmIntegrationsGroup<AzureBlobStorageIntergation> {\n return this.byType.azureBlobStorage;\n }\n\n get azure(): ScmIntegrationsGroup<AzureIntegration> {\n return this.byType.azure;\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 googleGcs(): ScmIntegrationsGroup<GoogleGcsIntegration> {\n return this.byType.googleGcs;\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 const candidates = Object.values(this.byType)\n .map(i => i.byUrl(url))\n .filter(Boolean);\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":[],"mappings":";;;;;;;;;;;;;;;;AA0DO,MAAM,eAAA,CAAkD;AAAA,EAC5C,MAAA;AAAA,EAEjB,OAAO,WAAW,MAAA,EAAiC;AACjD,IAAA,OAAO,IAAI,eAAA,CAAgB;AAAA,MACzB,KAAA,EAAO,gBAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,aAAA,EAAe,wBAAA,CAAyB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1D,gBAAA,EAAkB,2BAAA,CAA4B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAChE,KAAA,EAAO,gBAAA,CAAiB,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC1C,cAAA,EAAgB,yBAAA,CAA0B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC5D,eAAA,EAAiB,0BAAA,CAA2B,OAAA,CAAQ,EAAE,QAAQ,CAAA;AAAA,MAC9D,MAAA,EAAQ,iBAAA,CAAkB,OAAA,CAA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AA,MAAM,WAAA,GAAc,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAClC,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,GAAA;AAAA,IACT;AAEA,IAAA,OAAO,WAAA,CAAY,eAAe,GAAG,CAAA;AAAA,EACvC;AACF;;;;"}
|
package/dist/azure/config.cjs.js
CHANGED
|
@@ -39,8 +39,14 @@ function asAzureDevOpsCredential(credential) {
|
|
|
39
39
|
throw new Error("is not a valid credential");
|
|
40
40
|
}
|
|
41
41
|
function readAzureIntegrationConfig(config) {
|
|
42
|
+
deprecatedConfigCheck(config);
|
|
42
43
|
const host = config.getOptionalString("host") ?? AZURE_HOST;
|
|
43
|
-
|
|
44
|
+
if (!helpers.isValidHost(host)) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Invalid Azure integration config, '${host}' is not a valid host`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const credentialConfigs = config.getOptionalConfigArray("credentials")?.map((credential) => {
|
|
44
50
|
const result = {
|
|
45
51
|
organizations: credential.getOptionalStringArray("organizations"),
|
|
46
52
|
personalAccessToken: credential.getOptionalString("personalAccessToken")?.trim(),
|
|
@@ -51,40 +57,6 @@ function readAzureIntegrationConfig(config) {
|
|
|
51
57
|
};
|
|
52
58
|
return result;
|
|
53
59
|
});
|
|
54
|
-
const token = config.getOptionalString("token")?.trim();
|
|
55
|
-
if (config.getOptional("credential") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
56
|
-
throw new Error(
|
|
57
|
-
`Invalid Azure integration config, 'credential' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
if (config.getOptional("token") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Invalid Azure integration config, 'token' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
if (token !== void 0) {
|
|
66
|
-
const mapped = [{ personalAccessToken: token }];
|
|
67
|
-
credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;
|
|
68
|
-
}
|
|
69
|
-
if (config.getOptional("credential") !== void 0) {
|
|
70
|
-
const mapped = [
|
|
71
|
-
{
|
|
72
|
-
organizations: config.getOptionalStringArray(
|
|
73
|
-
"credential.organizations"
|
|
74
|
-
),
|
|
75
|
-
token: config.getOptionalString("credential.token")?.trim(),
|
|
76
|
-
tenantId: config.getOptionalString("credential.tenantId"),
|
|
77
|
-
clientId: config.getOptionalString("credential.clientId"),
|
|
78
|
-
clientSecret: config.getOptionalString("credential.clientSecret")?.trim()
|
|
79
|
-
}
|
|
80
|
-
];
|
|
81
|
-
credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;
|
|
82
|
-
}
|
|
83
|
-
if (!helpers.isValidHost(host)) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`Invalid Azure integration config, '${host}' is not a valid host`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
60
|
let credentials = void 0;
|
|
89
61
|
if (credentialConfigs !== void 0) {
|
|
90
62
|
const errors = credentialConfigs?.reduce((acc, credentialConfig, index) => {
|
|
@@ -154,6 +126,13 @@ function readAzureIntegrationConfigs(configs) {
|
|
|
154
126
|
}
|
|
155
127
|
return result;
|
|
156
128
|
}
|
|
129
|
+
function deprecatedConfigCheck(config) {
|
|
130
|
+
if (config.getOptional("credential") || config.getOptional("token")) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Invalid Azure integration config, 'credential' and 'token' have been removed. Use 'credentials' instead.`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
157
136
|
|
|
158
137
|
exports.readAzureIntegrationConfig = readAzureIntegrationConfig;
|
|
159
138
|
exports.readAzureIntegrationConfigs = readAzureIntegrationConfigs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs.js","sources":["../../src/azure/config.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 { 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 * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * The kind of Azure DevOps credential.\n * @public\n */\nexport type AzureDevOpsCredentialKind =\n | 'PersonalAccessToken'\n | 'ClientSecret'\n | 'ManagedIdentity'\n | 'ManagedIdentityClientAssertion';\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 client assertion credential that uses a managed identity to generate a client assertion (JWT).\n * @public\n */\nexport type AzureManagedIdentityClientAssertionCredential =\n AzureCredentialBase & {\n kind: 'ManagedIdentityClientAssertion';\n /**\n * The Entra ID tenant\n */\n tenantId: string;\n\n /**\n * The client ID of the app registration you want to authenticate as.\n */\n clientId: string;\n\n /**\n * The client ID of the managed identity used to generate a client assertion (JWT).\n * Set to \"system-assigned\" to automatically use the system-assigned managed identity.\n * For user-assigned managed identities, specify the client ID of the managed identity you want to use.\n */\n managedIdentityClientId: 'system-assigned' | 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: 'system-assigned' | 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<AzureManagedIdentityClientAssertionCredential> &\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 | AzureManagedIdentityClientAssertionCredential\n | AzureManagedIdentityCredential\n | PersonalAccessTokenCredential;\n\nconst AzureDevOpsCredentialFields = [\n 'clientId',\n 'clientSecret',\n 'managedIdentityClientId',\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 [\n 'ManagedIdentityClientAssertion',\n ['clientId', 'managedIdentityClientId', 'tenantId'],\n ],\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')?.trim(),\n clientId: credential.getOptionalString('clientId')?.trim(),\n clientSecret: credential.getOptionalString('clientSecret')?.trim(),\n managedIdentityClientId: credential\n .getOptionalString('managedIdentityClientId')\n ?.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 commitSigningKey: config.getOptionalString('commitSigningKey'),\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"],"names":["isValidHost"],"mappings":";;;;AAmBA,MAAM,UAAA,GAAa,eAAA;AAiKnB,MAAM,2BAAA,GAA8B;AAAA,EAClC,UAAA;AAAA,EACA,cAAA;AAAA,EACA,yBAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA;AAGA,MAAM,6BAAA,uBAAoC,GAAA,CAGxC;AAAA,EACA,CAAC,cAAA,EAAgB,CAAC,UAAA,EAAY,cAAA,EAAgB,UAAU,CAAC,CAAA;AAAA,EACzD,CAAC,iBAAA,EAAmB,CAAC,UAAU,CAAC,CAAA;AAAA,EAChC;AAAA,IACE,gCAAA;AAAA,IACA,CAAC,UAAA,EAAY,yBAAA,EAA2B,UAAU;AAAA,GACpD;AAAA,EACA,CAAC,qBAAA,EA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AAA,UAAA,KAAc,WAAW,IAAA,KAAS;AAAA,KACpC,IACA,SAAS,UAAA,EACT;AACA,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,qCAAA,EAAwC,IAAI,CAAA,gEAAA,EAAmE,UAAU,CAAA;AAAA,OAC3H;AAAA,IACF;AAEA,IAAA,IACE,WAAA,CAAY,MAAA;AAAA,MACV,gBACE,UAAA,CAAW,aAAA,KAAkB,MAAA,IAC7B,UAAA,CAAW,cAAc,MAAA,KAAW;AAAA,KACxC,CAAE,SAAS,CAAA,EACX;AACA,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,wCAAwC,IAAI,CAAA,+DAAA;AAAA,OAC9C;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AASO,SAAS,4BACd,OAAA,EAC0B;AAE1B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA;AAIrD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,UAAU,CAAA,EAAG;AAC5C,IAAA,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,UAAA,EAAY,CAAA;AAAA,EAClC;AAEA,EAAA,OAAO,MAAA;AACT;;;;;"}
|
|
1
|
+
{"version":3,"file":"config.cjs.js","sources":["../../src/azure/config.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 { 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 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 * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * The kind of Azure DevOps credential.\n * @public\n */\nexport type AzureDevOpsCredentialKind =\n | 'PersonalAccessToken'\n | 'ClientSecret'\n | 'ManagedIdentity'\n | 'ManagedIdentityClientAssertion';\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 client assertion credential that uses a managed identity to generate a client assertion (JWT).\n * @public\n */\nexport type AzureManagedIdentityClientAssertionCredential =\n AzureCredentialBase & {\n kind: 'ManagedIdentityClientAssertion';\n /**\n * The Entra ID tenant\n */\n tenantId: string;\n\n /**\n * The client ID of the app registration you want to authenticate as.\n */\n clientId: string;\n\n /**\n * The client ID of the managed identity used to generate a client assertion (JWT).\n * Set to \"system-assigned\" to automatically use the system-assigned managed identity.\n * For user-assigned managed identities, specify the client ID of the managed identity you want to use.\n */\n managedIdentityClientId: 'system-assigned' | 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: 'system-assigned' | 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<AzureManagedIdentityClientAssertionCredential> &\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 | AzureManagedIdentityClientAssertionCredential\n | AzureManagedIdentityCredential\n | PersonalAccessTokenCredential;\n\nconst AzureDevOpsCredentialFields = [\n 'clientId',\n 'clientSecret',\n 'managedIdentityClientId',\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 [\n 'ManagedIdentityClientAssertion',\n ['clientId', 'managedIdentityClientId', 'tenantId'],\n ],\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 deprecatedConfigCheck(config);\n\n const host = config.getOptionalString('host') ?? AZURE_HOST;\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Azure integration config, '${host}' is not a valid host`,\n );\n }\n\n const 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')?.trim(),\n clientId: credential.getOptionalString('clientId')?.trim(),\n clientSecret: credential.getOptionalString('clientSecret')?.trim(),\n managedIdentityClientId: credential\n .getOptionalString('managedIdentityClientId')\n ?.trim(),\n };\n\n return result;\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 commitSigningKey: config.getOptionalString('commitSigningKey'),\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/**\n * These config sections have been removed but to ensure they\n * don't leak sensitive tokens we have this check in place\n * to throw an error if found\n *\n * @internal\n * @deprecated To be removed at a later date\n */\nfunction deprecatedConfigCheck(config: Config) {\n if (config.getOptional('credential') || config.getOptional('token')) {\n throw new Error(\n `Invalid Azure integration config, 'credential' and 'token' have been removed. Use 'credentials' instead.`,\n );\n }\n}\n"],"names":["isValidHost"],"mappings":";;;;AAmBA,MAAM,UAAA,GAAa,eAAA;AA+InB,MAA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AAA,EAAG;AAC5C,IAAA,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,UAAA,EAAY,CAAA;AAAA,EAClC;AAEA,EAAA,OAAO,MAAA;AACT;AAUA,SAAS,sBAAsB,MAAA,EAAgB;AAC7C,EAAA,IAAI,OAAO,WAAA,CAAY,YAAY,KAAK,MAAA,CAAO,WAAA,CAAY,OAAO,CAAA,EAAG;AACnE,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,wGAAA;AAAA,KACF;AAAA,EACF;AACF;;;;;"}
|
package/dist/azure/config.esm.js
CHANGED
|
@@ -37,8 +37,14 @@ function asAzureDevOpsCredential(credential) {
|
|
|
37
37
|
throw new Error("is not a valid credential");
|
|
38
38
|
}
|
|
39
39
|
function readAzureIntegrationConfig(config) {
|
|
40
|
+
deprecatedConfigCheck(config);
|
|
40
41
|
const host = config.getOptionalString("host") ?? AZURE_HOST;
|
|
41
|
-
|
|
42
|
+
if (!isValidHost(host)) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Invalid Azure integration config, '${host}' is not a valid host`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const credentialConfigs = config.getOptionalConfigArray("credentials")?.map((credential) => {
|
|
42
48
|
const result = {
|
|
43
49
|
organizations: credential.getOptionalStringArray("organizations"),
|
|
44
50
|
personalAccessToken: credential.getOptionalString("personalAccessToken")?.trim(),
|
|
@@ -49,40 +55,6 @@ function readAzureIntegrationConfig(config) {
|
|
|
49
55
|
};
|
|
50
56
|
return result;
|
|
51
57
|
});
|
|
52
|
-
const token = config.getOptionalString("token")?.trim();
|
|
53
|
-
if (config.getOptional("credential") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Invalid Azure integration config, 'credential' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
if (config.getOptional("token") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
`Invalid Azure integration config, 'token' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
if (token !== void 0) {
|
|
64
|
-
const mapped = [{ personalAccessToken: token }];
|
|
65
|
-
credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;
|
|
66
|
-
}
|
|
67
|
-
if (config.getOptional("credential") !== void 0) {
|
|
68
|
-
const mapped = [
|
|
69
|
-
{
|
|
70
|
-
organizations: config.getOptionalStringArray(
|
|
71
|
-
"credential.organizations"
|
|
72
|
-
),
|
|
73
|
-
token: config.getOptionalString("credential.token")?.trim(),
|
|
74
|
-
tenantId: config.getOptionalString("credential.tenantId"),
|
|
75
|
-
clientId: config.getOptionalString("credential.clientId"),
|
|
76
|
-
clientSecret: config.getOptionalString("credential.clientSecret")?.trim()
|
|
77
|
-
}
|
|
78
|
-
];
|
|
79
|
-
credentialConfigs = credentialConfigs?.concat(mapped) ?? mapped;
|
|
80
|
-
}
|
|
81
|
-
if (!isValidHost(host)) {
|
|
82
|
-
throw new Error(
|
|
83
|
-
`Invalid Azure integration config, '${host}' is not a valid host`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
58
|
let credentials = void 0;
|
|
87
59
|
if (credentialConfigs !== void 0) {
|
|
88
60
|
const errors = credentialConfigs?.reduce((acc, credentialConfig, index) => {
|
|
@@ -152,6 +124,13 @@ function readAzureIntegrationConfigs(configs) {
|
|
|
152
124
|
}
|
|
153
125
|
return result;
|
|
154
126
|
}
|
|
127
|
+
function deprecatedConfigCheck(config) {
|
|
128
|
+
if (config.getOptional("credential") || config.getOptional("token")) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Invalid Azure integration config, 'credential' and 'token' have been removed. Use 'credentials' instead.`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
155
134
|
|
|
156
135
|
export { readAzureIntegrationConfig, readAzureIntegrationConfigs };
|
|
157
136
|
//# sourceMappingURL=config.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.esm.js","sources":["../../src/azure/config.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 { 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 * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * The kind of Azure DevOps credential.\n * @public\n */\nexport type AzureDevOpsCredentialKind =\n | 'PersonalAccessToken'\n | 'ClientSecret'\n | 'ManagedIdentity'\n | 'ManagedIdentityClientAssertion';\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 client assertion credential that uses a managed identity to generate a client assertion (JWT).\n * @public\n */\nexport type AzureManagedIdentityClientAssertionCredential =\n AzureCredentialBase & {\n kind: 'ManagedIdentityClientAssertion';\n /**\n * The Entra ID tenant\n */\n tenantId: string;\n\n /**\n * The client ID of the app registration you want to authenticate as.\n */\n clientId: string;\n\n /**\n * The client ID of the managed identity used to generate a client assertion (JWT).\n * Set to \"system-assigned\" to automatically use the system-assigned managed identity.\n * For user-assigned managed identities, specify the client ID of the managed identity you want to use.\n */\n managedIdentityClientId: 'system-assigned' | 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: 'system-assigned' | 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<AzureManagedIdentityClientAssertionCredential> &\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 | AzureManagedIdentityClientAssertionCredential\n | AzureManagedIdentityCredential\n | PersonalAccessTokenCredential;\n\nconst AzureDevOpsCredentialFields = [\n 'clientId',\n 'clientSecret',\n 'managedIdentityClientId',\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 [\n 'ManagedIdentityClientAssertion',\n ['clientId', 'managedIdentityClientId', 'tenantId'],\n ],\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')?.trim(),\n clientId: credential.getOptionalString('clientId')?.trim(),\n clientSecret: credential.getOptionalString('clientSecret')?.trim(),\n managedIdentityClientId: credential\n .getOptionalString('managedIdentityClientId')\n ?.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 commitSigningKey: config.getOptionalString('commitSigningKey'),\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"],"names":[],"mappings":";;AAmBA,MAAM,UAAA,GAAa,eAAA;AAiKnB,MAAM,2BAAA,GAA8B;AAAA,EAClC,UAAA;AAAA,EACA,cAAA;AAAA,EACA,yBAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA;AAGA,MAAM,6BAAA,uBAAoC,GAAA,CAGxC;AAAA,EACA,CAAC,cAAA,EAAgB,CAAC,UAAA,EAAY,cAAA,EAAgB,UAAU,CAAC,CAAA;AAAA,EACzD,CAAC,iBAAA,EAAmB,CAAC,UAAU,CAAC,CAAA;AAAA,EAChC;AAA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AAI,CAAA,gBAAA,KAClC,wBAAwB,gBAAgB;AAAA,KAC1C;AAEA,IAAA,IACE,WAAA,CAAY,IAAA;AAAA,MACV,CAAA,UAAA,KAAc,WAAW,IAAA,KAAS;AAAA,KACpC,IACA,SAAS,UAAA,EACT;AACA,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,qCAAA,EAAwC,IAAI,CAAA,gEAAA,EAAmE,UAAU,CAAA;AAAA,OAC3H;AAAA,IACF;AAEA,IAAA,IACE,WAAA,CAAY,MAAA;AAAA,MACV,gBACE,UAAA,CAAW,aAAA,KAAkB,MAAA,IAC7B,UAAA,CAAW,cAAc,MAAA,KAAW;AAAA,KACxC,CAAE,SAAS,CAAA,EACX;AACA,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,wCAAwC,IAAI,CAAA,+DAAA;AAAA,OAC9C;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA,EAAkB,MAAA,CAAO,iBAAA,CAAkB,kBAAkB;AAAA,GAC/D;AACF;AASO,SAAS,4BACd,OAAA,EAC0B;AAE1B,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,0BAA0B,CAAA;AAIrD,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAK,CAAA,CAAE,IAAA,KAAS,UAAU,CAAA,EAAG;AAC5C,IAAA,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,UAAA,EAAY,CAAA;AAAA,EAClC;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"config.esm.js","sources":["../../src/azure/config.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 { 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 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 * Signing key for commits\n */\n commitSigningKey?: string;\n};\n\n/**\n * The kind of Azure DevOps credential.\n * @public\n */\nexport type AzureDevOpsCredentialKind =\n | 'PersonalAccessToken'\n | 'ClientSecret'\n | 'ManagedIdentity'\n | 'ManagedIdentityClientAssertion';\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 client assertion credential that uses a managed identity to generate a client assertion (JWT).\n * @public\n */\nexport type AzureManagedIdentityClientAssertionCredential =\n AzureCredentialBase & {\n kind: 'ManagedIdentityClientAssertion';\n /**\n * The Entra ID tenant\n */\n tenantId: string;\n\n /**\n * The client ID of the app registration you want to authenticate as.\n */\n clientId: string;\n\n /**\n * The client ID of the managed identity used to generate a client assertion (JWT).\n * Set to \"system-assigned\" to automatically use the system-assigned managed identity.\n * For user-assigned managed identities, specify the client ID of the managed identity you want to use.\n */\n managedIdentityClientId: 'system-assigned' | 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: 'system-assigned' | 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<AzureManagedIdentityClientAssertionCredential> &\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 | AzureManagedIdentityClientAssertionCredential\n | AzureManagedIdentityCredential\n | PersonalAccessTokenCredential;\n\nconst AzureDevOpsCredentialFields = [\n 'clientId',\n 'clientSecret',\n 'managedIdentityClientId',\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 [\n 'ManagedIdentityClientAssertion',\n ['clientId', 'managedIdentityClientId', 'tenantId'],\n ],\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 deprecatedConfigCheck(config);\n\n const host = config.getOptionalString('host') ?? AZURE_HOST;\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Azure integration config, '${host}' is not a valid host`,\n );\n }\n\n const 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')?.trim(),\n clientId: credential.getOptionalString('clientId')?.trim(),\n clientSecret: credential.getOptionalString('clientSecret')?.trim(),\n managedIdentityClientId: credential\n .getOptionalString('managedIdentityClientId')\n ?.trim(),\n };\n\n return result;\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 commitSigningKey: config.getOptionalString('commitSigningKey'),\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/**\n * These config sections have been removed but to ensure they\n * don't leak sensitive tokens we have this check in place\n * to throw an error if found\n *\n * @internal\n * @deprecated To be removed at a later date\n */\nfunction deprecatedConfigCheck(config: Config) {\n if (config.getOptional('credential') || config.getOptional('token')) {\n throw new Error(\n `Invalid Azure integration config, 'credential' and 'token' have been removed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