@backstage/integration-react 1.1.27 → 1.1.28-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @backstage/integration-react
2
2
 
3
+ ## 1.1.28-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/core-plugin-api@1.9.3-next.0
9
+ - @backstage/integration@1.12.0-next.0
10
+ - @backstage/config@1.2.0
11
+
3
12
  ## 1.1.27
4
13
 
5
14
  ### Patch Changes
@@ -1,33 +1,14 @@
1
1
  import { createApiFactory, githubAuthApiRef, gitlabAuthApiRef, microsoftAuthApiRef, bitbucketAuthApiRef } from '@backstage/core-plugin-api';
2
2
  import { scmAuthApiRef } from './ScmAuthApi.esm.js';
3
3
 
4
- var __accessCheck = (obj, member, msg) => {
5
- if (!member.has(obj))
6
- throw TypeError("Cannot " + msg);
7
- };
8
- var __privateGet = (obj, member, getter) => {
9
- __accessCheck(obj, member, "read from private field");
10
- return member.get(obj);
11
- };
12
- var __privateAdd = (obj, member, value) => {
13
- if (member.has(obj))
14
- throw TypeError("Cannot add the same private member more than once");
15
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
16
- };
17
- var __privateSet = (obj, member, value, setter) => {
18
- __accessCheck(obj, member, "write to private field");
19
- member.set(obj, value);
20
- return value;
21
- };
22
- var _providers, _api, _host, _scopeMapping, _providerName;
23
4
  class ScmAuthMux {
5
+ #providers;
24
6
  constructor(providers) {
25
- __privateAdd(this, _providers, void 0);
26
- __privateSet(this, _providers, providers);
7
+ this.#providers = providers;
27
8
  }
28
9
  async getCredentials(options) {
29
10
  const url = new URL(options.url);
30
- const provider = __privateGet(this, _providers).find((p) => p.isUrlSupported(url));
11
+ const provider = this.#providers.find((p) => p.isUrlSupported(url));
31
12
  if (!provider) {
32
13
  throw new Error(
33
14
  `No auth provider available for '${options.url}', see https://backstage.io/link?scm-auth`
@@ -36,18 +17,7 @@ class ScmAuthMux {
36
17
  return provider.getCredentials(options);
37
18
  }
38
19
  }
39
- _providers = new WeakMap();
40
- const _ScmAuth = class _ScmAuth {
41
- constructor(providerName, api, host, scopeMapping) {
42
- __privateAdd(this, _api, void 0);
43
- __privateAdd(this, _host, void 0);
44
- __privateAdd(this, _scopeMapping, void 0);
45
- __privateAdd(this, _providerName, void 0);
46
- __privateSet(this, _api, api);
47
- __privateSet(this, _host, host);
48
- __privateSet(this, _scopeMapping, scopeMapping);
49
- __privateSet(this, _providerName, providerName);
50
- }
20
+ class ScmAuth {
51
21
  /**
52
22
  * Creates an API factory that enables auth for each of the default SCM providers.
53
23
  */
@@ -60,11 +30,11 @@ const _ScmAuth = class _ScmAuth {
60
30
  azure: microsoftAuthApiRef,
61
31
  bitbucket: bitbucketAuthApiRef
62
32
  },
63
- factory: ({ github, gitlab, azure, bitbucket }) => _ScmAuth.merge(
64
- _ScmAuth.forGithub(github),
65
- _ScmAuth.forGitlab(gitlab),
66
- _ScmAuth.forAzure(azure),
67
- _ScmAuth.forBitbucket(bitbucket)
33
+ factory: ({ github, gitlab, azure, bitbucket }) => ScmAuth.merge(
34
+ ScmAuth.forGithub(github),
35
+ ScmAuth.forGitlab(gitlab),
36
+ ScmAuth.forAzure(azure),
37
+ ScmAuth.forBitbucket(bitbucket)
68
38
  )
69
39
  });
70
40
  }
@@ -72,7 +42,7 @@ const _ScmAuth = class _ScmAuth {
72
42
  * Creates a general purpose ScmAuth instance with a custom scope mapping.
73
43
  */
74
44
  static forAuthApi(authApi, options) {
75
- return new _ScmAuth("generic", authApi, options.host, options.scopeMapping);
45
+ return new ScmAuth("generic", authApi, options.host, options.scopeMapping);
76
46
  }
77
47
  /**
78
48
  * Creates a new ScmAuth instance that handles authentication towards GitHub.
@@ -88,9 +58,8 @@ const _ScmAuth = class _ScmAuth {
88
58
  * `gist`
89
59
  */
90
60
  static forGithub(githubAuthApi, options) {
91
- var _a;
92
- const host = (_a = options == null ? void 0 : options.host) != null ? _a : "github.com";
93
- return new _ScmAuth("github", githubAuthApi, host, {
61
+ const host = options?.host ?? "github.com";
62
+ return new ScmAuth("github", githubAuthApi, host, {
94
63
  default: ["repo", "read:org", "read:user"],
95
64
  repoWrite: ["gist"]
96
65
  });
@@ -109,9 +78,8 @@ const _ScmAuth = class _ScmAuth {
109
78
  * `write_repository api`
110
79
  */
111
80
  static forGitlab(gitlabAuthApi, options) {
112
- var _a;
113
- const host = (_a = options == null ? void 0 : options.host) != null ? _a : "gitlab.com";
114
- return new _ScmAuth("gitlab", gitlabAuthApi, host, {
81
+ const host = options?.host ?? "gitlab.com";
82
+ return new ScmAuth("gitlab", gitlabAuthApi, host, {
115
83
  default: ["read_user", "read_api", "read_repository"],
116
84
  repoWrite: ["write_repository", "api"]
117
85
  });
@@ -130,9 +98,8 @@ const _ScmAuth = class _ScmAuth {
130
98
  * `vso.code_manage`
131
99
  */
132
100
  static forAzure(microsoftAuthApi, options) {
133
- var _a;
134
- const host = (_a = options == null ? void 0 : options.host) != null ? _a : "dev.azure.com";
135
- return new _ScmAuth("azure", microsoftAuthApi, host, {
101
+ const host = options?.host ?? "dev.azure.com";
102
+ return new ScmAuth("azure", microsoftAuthApi, host, {
136
103
  default: [
137
104
  "499b84ac-1321-427f-aa17-267ca6975798/vso.build",
138
105
  "499b84ac-1321-427f-aa17-267ca6975798/vso.code",
@@ -157,9 +124,8 @@ const _ScmAuth = class _ScmAuth {
157
124
  * `pullrequest:write snippet:write issue:write`
158
125
  */
159
126
  static forBitbucket(bitbucketAuthApi, options) {
160
- var _a;
161
- const host = (_a = options == null ? void 0 : options.host) != null ? _a : "bitbucket.org";
162
- return new _ScmAuth("bitbucket", bitbucketAuthApi, host, {
127
+ const host = options?.host ?? "bitbucket.org";
128
+ return new ScmAuth("bitbucket", bitbucketAuthApi, host, {
163
129
  default: ["account", "team", "pullrequest", "snippet", "issue"],
164
130
  repoWrite: ["pullrequest:write", "snippet:write", "issue:write"]
165
131
  });
@@ -171,34 +137,43 @@ const _ScmAuth = class _ScmAuth {
171
137
  static merge(...providers) {
172
138
  return new ScmAuthMux(providers);
173
139
  }
140
+ #api;
141
+ #host;
142
+ #scopeMapping;
143
+ #providerName;
144
+ constructor(providerName, api, host, scopeMapping) {
145
+ this.#api = api;
146
+ this.#host = host;
147
+ this.#scopeMapping = scopeMapping;
148
+ this.#providerName = providerName;
149
+ }
174
150
  /**
175
151
  * Checks whether the implementation is able to provide authentication for the given URL.
176
152
  */
177
153
  isUrlSupported(url) {
178
- return url.host === __privateGet(this, _host);
154
+ return url.host === this.#host;
179
155
  }
180
156
  getAdditionalScopesForProvider(additionalScopes) {
181
- var _a, _b;
182
- if (!(additionalScopes == null ? void 0 : additionalScopes.customScopes) || __privateGet(this, _providerName) === "generic") {
157
+ if (!additionalScopes?.customScopes || this.#providerName === "generic") {
183
158
  return [];
184
159
  }
185
- return (_b = (_a = additionalScopes.customScopes) == null ? void 0 : _a[__privateGet(this, _providerName)]) != null ? _b : [];
160
+ return additionalScopes.customScopes?.[this.#providerName] ?? [];
186
161
  }
187
162
  /**
188
163
  * Fetches credentials for the given resource.
189
164
  */
190
165
  async getCredentials(options) {
191
166
  const { url, additionalScope, ...restOptions } = options;
192
- const scopes = __privateGet(this, _scopeMapping).default.slice();
193
- if (additionalScope == null ? void 0 : additionalScope.repoWrite) {
194
- scopes.push(...__privateGet(this, _scopeMapping).repoWrite);
167
+ const scopes = this.#scopeMapping.default.slice();
168
+ if (additionalScope?.repoWrite) {
169
+ scopes.push(...this.#scopeMapping.repoWrite);
195
170
  }
196
171
  const additionalScopes = this.getAdditionalScopesForProvider(additionalScope);
197
172
  if (additionalScopes.length) {
198
173
  scopes.push(...additionalScopes);
199
174
  }
200
175
  const uniqueScopes = [...new Set(scopes)];
201
- const token = await __privateGet(this, _api).getAccessToken(uniqueScopes, restOptions);
176
+ const token = await this.#api.getAccessToken(uniqueScopes, restOptions);
202
177
  return {
203
178
  token,
204
179
  headers: {
@@ -206,12 +181,7 @@ const _ScmAuth = class _ScmAuth {
206
181
  }
207
182
  };
208
183
  }
209
- };
210
- _api = new WeakMap();
211
- _host = new WeakMap();
212
- _scopeMapping = new WeakMap();
213
- _providerName = new WeakMap();
214
- let ScmAuth = _ScmAuth;
184
+ }
215
185
 
216
186
  export { ScmAuth };
217
187
  //# sourceMappingURL=ScmAuth.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScmAuth.esm.js","sources":["../../src/api/ScmAuth.ts"],"sourcesContent":["/*\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 {\n bitbucketAuthApiRef,\n createApiFactory,\n githubAuthApiRef,\n gitlabAuthApiRef,\n microsoftAuthApiRef,\n OAuthApi,\n} from '@backstage/core-plugin-api';\nimport {\n ScmAuthApi,\n scmAuthApiRef,\n ScmAuthTokenOptions,\n ScmAuthTokenResponse,\n} from './ScmAuthApi';\n\ntype ScopeMapping = {\n /** The base scopes used for all requests */\n default: string[];\n /** Additional scopes added if `repoWrite` is requested */\n repoWrite: string[];\n};\n\n// An enum of all supported providers\ntype ProviderName = 'generic' | 'github' | 'azure' | 'bitbucket' | 'gitlab';\n\nclass ScmAuthMux implements ScmAuthApi {\n #providers: Array<ScmAuth>;\n\n constructor(providers: ScmAuth[]) {\n this.#providers = providers;\n }\n\n async getCredentials(\n options: ScmAuthTokenOptions,\n ): Promise<ScmAuthTokenResponse> {\n const url = new URL(options.url);\n const provider = this.#providers.find(p => p.isUrlSupported(url));\n if (!provider) {\n throw new Error(\n `No auth provider available for '${options.url}', see https://backstage.io/link?scm-auth`,\n );\n }\n\n return provider.getCredentials(options);\n }\n}\n\n/**\n * An implementation of the ScmAuthApi that merges together OAuthApi instances\n * to form a single instance that can handles authentication for multiple providers.\n *\n * @public\n *\n * @example\n * ```\n * // Supports authentication towards both public GitHub and GHE:\n * createApiFactory({\n * api: scmAuthApiRef,\n * deps: {\n * gheAuthApi: gheAuthApiRef,\n * githubAuthApi: githubAuthApiRef,\n * },\n * factory: ({ githubAuthApi, gheAuthApi }) =>\n * ScmAuth.merge(\n * ScmAuth.forGithub(githubAuthApi),\n * ScmAuth.forGithub(gheAuthApi, {\n * host: 'ghe.example.com',\n * }),\n * )\n * })\n * ```\n */\nexport class ScmAuth implements ScmAuthApi {\n /**\n * Creates an API factory that enables auth for each of the default SCM providers.\n */\n static createDefaultApiFactory() {\n return createApiFactory({\n api: scmAuthApiRef,\n deps: {\n github: githubAuthApiRef,\n gitlab: gitlabAuthApiRef,\n azure: microsoftAuthApiRef,\n bitbucket: bitbucketAuthApiRef,\n },\n factory: ({ github, gitlab, azure, bitbucket }) =>\n ScmAuth.merge(\n ScmAuth.forGithub(github),\n ScmAuth.forGitlab(gitlab),\n ScmAuth.forAzure(azure),\n ScmAuth.forBitbucket(bitbucket),\n ),\n });\n }\n\n /**\n * Creates a general purpose ScmAuth instance with a custom scope mapping.\n */\n static forAuthApi(\n authApi: OAuthApi,\n options: {\n host: string;\n scopeMapping: {\n default: string[];\n repoWrite: string[];\n };\n },\n ): ScmAuth {\n return new ScmAuth('generic', authApi, options.host, options.scopeMapping);\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards GitHub.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `github.com`.\n *\n * The default scopes are:\n *\n * `repo read:org read:user`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `gist`\n */\n static forGithub(\n githubAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'github.com';\n return new ScmAuth('github', githubAuthApi, host, {\n default: ['repo', 'read:org', 'read:user'],\n repoWrite: ['gist'],\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards GitLab.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `gitlab.com`.\n *\n * The default scopes are:\n *\n * `read_user read_api read_repository`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `write_repository api`\n */\n static forGitlab(\n gitlabAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'gitlab.com';\n return new ScmAuth('gitlab', gitlabAuthApi, host, {\n default: ['read_user', 'read_api', 'read_repository'],\n repoWrite: ['write_repository', 'api'],\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards Azure.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `dev.azure.com`.\n *\n * The default scopes are:\n *\n * `vso.build vso.code vso.graph vso.project vso.profile`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `vso.code_manage`\n */\n static forAzure(\n microsoftAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'dev.azure.com';\n return new ScmAuth('azure', microsoftAuthApi, host, {\n default: [\n '499b84ac-1321-427f-aa17-267ca6975798/vso.build',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.code',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.graph',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.project',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.profile',\n ],\n repoWrite: ['499b84ac-1321-427f-aa17-267ca6975798/vso.code_manage'],\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards Bitbucket.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `bitbucket.org`.\n *\n * The default scopes are:\n *\n * `account team pullrequest snippet issue`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `pullrequest:write snippet:write issue:write`\n */\n static forBitbucket(\n bitbucketAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'bitbucket.org';\n return new ScmAuth('bitbucket', bitbucketAuthApi, host, {\n default: ['account', 'team', 'pullrequest', 'snippet', 'issue'],\n repoWrite: ['pullrequest:write', 'snippet:write', 'issue:write'],\n });\n }\n\n /**\n * Merges together multiple ScmAuth instances into one that\n * routes requests to the correct instance based on the URL.\n */\n static merge(...providers: ScmAuth[]): ScmAuthApi {\n return new ScmAuthMux(providers);\n }\n\n #api: OAuthApi;\n #host: string;\n #scopeMapping: ScopeMapping;\n #providerName: ProviderName;\n\n private constructor(\n providerName: ProviderName,\n api: OAuthApi,\n host: string,\n scopeMapping: ScopeMapping,\n ) {\n this.#api = api;\n this.#host = host;\n this.#scopeMapping = scopeMapping;\n this.#providerName = providerName;\n }\n\n /**\n * Checks whether the implementation is able to provide authentication for the given URL.\n */\n isUrlSupported(url: URL): boolean {\n return url.host === this.#host;\n }\n\n private getAdditionalScopesForProvider(\n additionalScopes: ScmAuthTokenOptions['additionalScope'],\n ): string[] {\n if (!additionalScopes?.customScopes || this.#providerName === 'generic') {\n return [];\n }\n\n return additionalScopes.customScopes?.[this.#providerName] ?? [];\n }\n\n /**\n * Fetches credentials for the given resource.\n */\n async getCredentials(\n options: ScmAuthTokenOptions,\n ): Promise<ScmAuthTokenResponse> {\n const { url, additionalScope, ...restOptions } = options;\n\n const scopes = this.#scopeMapping.default.slice();\n if (additionalScope?.repoWrite) {\n scopes.push(...this.#scopeMapping.repoWrite);\n }\n\n const additionalScopes =\n this.getAdditionalScopesForProvider(additionalScope);\n\n if (additionalScopes.length) {\n scopes.push(...additionalScopes);\n }\n\n const uniqueScopes = [...new Set(scopes)];\n\n const token = await this.#api.getAccessToken(uniqueScopes, restOptions);\n\n return {\n token,\n headers: {\n Authorization: `Bearer ${token}`,\n },\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,UAAA,EAAA,IAAA,EAAA,KAAA,EAAA,aAAA,EAAA,aAAA,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;AACA,aAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA,aAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AAhKK,IAAM,OAAN,GAAA;;;;"}
1
+ {"version":3,"file":"ScmAuth.esm.js","sources":["../../src/api/ScmAuth.ts"],"sourcesContent":["/*\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 {\n bitbucketAuthApiRef,\n createApiFactory,\n githubAuthApiRef,\n gitlabAuthApiRef,\n microsoftAuthApiRef,\n OAuthApi,\n} from '@backstage/core-plugin-api';\nimport {\n ScmAuthApi,\n scmAuthApiRef,\n ScmAuthTokenOptions,\n ScmAuthTokenResponse,\n} from './ScmAuthApi';\n\ntype ScopeMapping = {\n /** The base scopes used for all requests */\n default: string[];\n /** Additional scopes added if `repoWrite` is requested */\n repoWrite: string[];\n};\n\n// An enum of all supported providers\ntype ProviderName = 'generic' | 'github' | 'azure' | 'bitbucket' | 'gitlab';\n\nclass ScmAuthMux implements ScmAuthApi {\n #providers: Array<ScmAuth>;\n\n constructor(providers: ScmAuth[]) {\n this.#providers = providers;\n }\n\n async getCredentials(\n options: ScmAuthTokenOptions,\n ): Promise<ScmAuthTokenResponse> {\n const url = new URL(options.url);\n const provider = this.#providers.find(p => p.isUrlSupported(url));\n if (!provider) {\n throw new Error(\n `No auth provider available for '${options.url}', see https://backstage.io/link?scm-auth`,\n );\n }\n\n return provider.getCredentials(options);\n }\n}\n\n/**\n * An implementation of the ScmAuthApi that merges together OAuthApi instances\n * to form a single instance that can handles authentication for multiple providers.\n *\n * @public\n *\n * @example\n * ```\n * // Supports authentication towards both public GitHub and GHE:\n * createApiFactory({\n * api: scmAuthApiRef,\n * deps: {\n * gheAuthApi: gheAuthApiRef,\n * githubAuthApi: githubAuthApiRef,\n * },\n * factory: ({ githubAuthApi, gheAuthApi }) =>\n * ScmAuth.merge(\n * ScmAuth.forGithub(githubAuthApi),\n * ScmAuth.forGithub(gheAuthApi, {\n * host: 'ghe.example.com',\n * }),\n * )\n * })\n * ```\n */\nexport class ScmAuth implements ScmAuthApi {\n /**\n * Creates an API factory that enables auth for each of the default SCM providers.\n */\n static createDefaultApiFactory() {\n return createApiFactory({\n api: scmAuthApiRef,\n deps: {\n github: githubAuthApiRef,\n gitlab: gitlabAuthApiRef,\n azure: microsoftAuthApiRef,\n bitbucket: bitbucketAuthApiRef,\n },\n factory: ({ github, gitlab, azure, bitbucket }) =>\n ScmAuth.merge(\n ScmAuth.forGithub(github),\n ScmAuth.forGitlab(gitlab),\n ScmAuth.forAzure(azure),\n ScmAuth.forBitbucket(bitbucket),\n ),\n });\n }\n\n /**\n * Creates a general purpose ScmAuth instance with a custom scope mapping.\n */\n static forAuthApi(\n authApi: OAuthApi,\n options: {\n host: string;\n scopeMapping: {\n default: string[];\n repoWrite: string[];\n };\n },\n ): ScmAuth {\n return new ScmAuth('generic', authApi, options.host, options.scopeMapping);\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards GitHub.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `github.com`.\n *\n * The default scopes are:\n *\n * `repo read:org read:user`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `gist`\n */\n static forGithub(\n githubAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'github.com';\n return new ScmAuth('github', githubAuthApi, host, {\n default: ['repo', 'read:org', 'read:user'],\n repoWrite: ['gist'],\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards GitLab.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `gitlab.com`.\n *\n * The default scopes are:\n *\n * `read_user read_api read_repository`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `write_repository api`\n */\n static forGitlab(\n gitlabAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'gitlab.com';\n return new ScmAuth('gitlab', gitlabAuthApi, host, {\n default: ['read_user', 'read_api', 'read_repository'],\n repoWrite: ['write_repository', 'api'],\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards Azure.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `dev.azure.com`.\n *\n * The default scopes are:\n *\n * `vso.build vso.code vso.graph vso.project vso.profile`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `vso.code_manage`\n */\n static forAzure(\n microsoftAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'dev.azure.com';\n return new ScmAuth('azure', microsoftAuthApi, host, {\n default: [\n '499b84ac-1321-427f-aa17-267ca6975798/vso.build',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.code',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.graph',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.project',\n '499b84ac-1321-427f-aa17-267ca6975798/vso.profile',\n ],\n repoWrite: ['499b84ac-1321-427f-aa17-267ca6975798/vso.code_manage'],\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards Bitbucket.\n *\n * The host option determines which URLs that are handled by this instance and defaults to `bitbucket.org`.\n *\n * The default scopes are:\n *\n * `account team pullrequest snippet issue`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `pullrequest:write snippet:write issue:write`\n */\n static forBitbucket(\n bitbucketAuthApi: OAuthApi,\n options?: {\n host?: string;\n },\n ): ScmAuth {\n const host = options?.host ?? 'bitbucket.org';\n return new ScmAuth('bitbucket', bitbucketAuthApi, host, {\n default: ['account', 'team', 'pullrequest', 'snippet', 'issue'],\n repoWrite: ['pullrequest:write', 'snippet:write', 'issue:write'],\n });\n }\n\n /**\n * Merges together multiple ScmAuth instances into one that\n * routes requests to the correct instance based on the URL.\n */\n static merge(...providers: ScmAuth[]): ScmAuthApi {\n return new ScmAuthMux(providers);\n }\n\n #api: OAuthApi;\n #host: string;\n #scopeMapping: ScopeMapping;\n #providerName: ProviderName;\n\n private constructor(\n providerName: ProviderName,\n api: OAuthApi,\n host: string,\n scopeMapping: ScopeMapping,\n ) {\n this.#api = api;\n this.#host = host;\n this.#scopeMapping = scopeMapping;\n this.#providerName = providerName;\n }\n\n /**\n * Checks whether the implementation is able to provide authentication for the given URL.\n */\n isUrlSupported(url: URL): boolean {\n return url.host === this.#host;\n }\n\n private getAdditionalScopesForProvider(\n additionalScopes: ScmAuthTokenOptions['additionalScope'],\n ): string[] {\n if (!additionalScopes?.customScopes || this.#providerName === 'generic') {\n return [];\n }\n\n return additionalScopes.customScopes?.[this.#providerName] ?? [];\n }\n\n /**\n * Fetches credentials for the given resource.\n */\n async getCredentials(\n options: ScmAuthTokenOptions,\n ): Promise<ScmAuthTokenResponse> {\n const { url, additionalScope, ...restOptions } = options;\n\n const scopes = this.#scopeMapping.default.slice();\n if (additionalScope?.repoWrite) {\n scopes.push(...this.#scopeMapping.repoWrite);\n }\n\n const additionalScopes =\n this.getAdditionalScopesForProvider(additionalScope);\n\n if (additionalScopes.length) {\n scopes.push(...additionalScopes);\n }\n\n const uniqueScopes = [...new Set(scopes)];\n\n const token = await this.#api.getAccessToken(uniqueScopes, restOptions);\n\n return {\n token,\n headers: {\n Authorization: `Bearer ${token}`,\n },\n };\n }\n}\n"],"names":[],"mappings":";;;AAyCA,MAAM,UAAiC,CAAA;AAAA,EACrC,UAAA,CAAA;AAAA,EAEA,YAAY,SAAsB,EAAA;AAChC,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAA;AAAA,GACpB;AAAA,EAEA,MAAM,eACJ,OAC+B,EAAA;AAC/B,IAAA,MAAM,GAAM,GAAA,IAAI,GAA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AAC,CAAA;AAAA,KACV;AAEA,IAAA,OAAO,gBAAiB,CAAA,YAAA,GAAe,IAAK,CAAA,aAAa,KAAK,EAAC,CAAA;AAAA,GACjE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,eACJ,OAC+B,EAAA;AAC/B,IAAA,MAAM,EAAE,GAAA,EAAK,eAAiB,EAAA,GAAG,aAAgB,GAAA,OAAA,CAAA;AAEjD,IAAA,MAAM,MAAS,GAAA,IAAA,CAAK,aAAc,CAAA,OAAA,CAAQ,KAAM,EAAA,CAAA;AAChD,IAAA,IAAI,iBAAiB,SAAW,EAAA;AAC9B,MAAA,MAAA,CAAO,IAAK,CAAA,GAAG,IAAK,CAAA,aAAA,CAAc,SAAS,CAAA,CAAA;AAAA,KAC7C;AAEA,IAAM,MAAA,gBAAA,GACJ,IAAK,CAAA,8BAAA,CAA+B,eAAe,CAAA,CAAA;AAErD,IAAA,IAAI,iBAAiB,MAAQ,EAAA;AAC3B,MAAO,MAAA,CAAA,IAAA,CAAK,GAAG,gBAAgB,CAAA,CAAA;AAAA,KACjC;AAEA,IAAA,MAAM,eAAe,CAAC,GAAG,IAAI,GAAA,CAAI,MAAM,CAAC,CAAA,CAAA;AAExC,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,IAAK,CAAA,cAAA,CAAe,cAAc,WAAW,CAAA,CAAA;AAEtE,IAAO,OAAA;AAAA,MACL,KAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,aAAA,EAAe,UAAU,KAAK,CAAA,CAAA;AAAA,OAChC;AAAA,KACF,CAAA;AAAA,GACF;AACF;;;;"}
@@ -3,11 +3,10 @@ import React from 'react';
3
3
  import { useApp } from '@backstage/core-plugin-api';
4
4
 
5
5
  const ScmIntegrationIcon = (props) => {
6
- var _a;
7
6
  const { type } = props;
8
7
  const app = useApp();
9
8
  const DefaultIcon = CodeIcon;
10
- const Icon = type ? (_a = app.getSystemIcon(type)) != null ? _a : DefaultIcon : DefaultIcon;
9
+ const Icon = type ? app.getSystemIcon(type) ?? DefaultIcon : DefaultIcon;
11
10
  return /* @__PURE__ */ React.createElement(Icon, null);
12
11
  };
13
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"ScmIntegrationIcon.esm.js","sources":["../../../src/components/ScmIntegrationIcon/ScmIntegrationIcon.tsx"],"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 */\nimport CodeIcon from '@material-ui/icons/Code';\nimport React from 'react';\nimport { useApp } from '@backstage/core-plugin-api';\n\n/**\n * Props for {@link ScmIntegrationIcon}.\n *\n * @public\n */\nexport type ScmIntegrationIconProps = {\n /**\n * The integration type, e.g. \"github\".\n */\n type?: string;\n};\n\n/**\n * An icon that represents a certain SCM integration.\n *\n * @public\n */\nexport const ScmIntegrationIcon = (props: ScmIntegrationIconProps) => {\n const { type } = props;\n const app = useApp();\n const DefaultIcon = CodeIcon;\n const Icon = type ? app.getSystemIcon(type) ?? DefaultIcon : DefaultIcon;\n return <Icon />;\n};\n"],"names":[],"mappings":";;;;AAoCa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AApCtE,EAAA,IAAA,EAAA,CAAA;AAqCE,EAAM,MAAA,EAAE,MAAS,GAAA,KAAA,CAAA;AACjB,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAA,MAAM,WAAc,GAAA,QAAA,CAAA;AACpB,EAAA,MAAM,OAAO,IAAO,GAAA,CAAA,EAAA,GAAA,GAAA,CAAI,cAAc,IAAI,CAAA,KAAtB,YAA2B,WAAc,GAAA,WAAA,CAAA;AAC7D,EAAA,2CAAQ,IAAK,EAAA,IAAA,CAAA,CAAA;AACf;;;;"}
1
+ {"version":3,"file":"ScmIntegrationIcon.esm.js","sources":["../../../src/components/ScmIntegrationIcon/ScmIntegrationIcon.tsx"],"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 */\nimport CodeIcon from '@material-ui/icons/Code';\nimport React from 'react';\nimport { useApp } from '@backstage/core-plugin-api';\n\n/**\n * Props for {@link ScmIntegrationIcon}.\n *\n * @public\n */\nexport type ScmIntegrationIconProps = {\n /**\n * The integration type, e.g. \"github\".\n */\n type?: string;\n};\n\n/**\n * An icon that represents a certain SCM integration.\n *\n * @public\n */\nexport const ScmIntegrationIcon = (props: ScmIntegrationIconProps) => {\n const { type } = props;\n const app = useApp();\n const DefaultIcon = CodeIcon;\n const Icon = type ? app.getSystemIcon(type) ?? DefaultIcon : DefaultIcon;\n return <Icon />;\n};\n"],"names":[],"mappings":";;;;AAoCa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA,EAAE,MAAS,GAAA,KAAA,CAAA;AACjB,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAA,MAAM,WAAc,GAAA,QAAA,CAAA;AACpB,EAAA,MAAM,OAAO,IAAO,GAAA,GAAA,CAAI,aAAc,CAAA,IAAI,KAAK,WAAc,GAAA,WAAA,CAAA;AAC7D,EAAA,2CAAQ,IAAK,EAAA,IAAA,CAAA,CAAA;AACf;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/integration-react",
3
- "version": "1.1.27",
3
+ "version": "1.1.28-next.0",
4
4
  "description": "Frontend package for managing integrations towards external systems",
5
5
  "backstage": {
6
6
  "role": "web-library"
@@ -34,17 +34,17 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@backstage/config": "^1.2.0",
37
- "@backstage/core-plugin-api": "^1.9.2",
38
- "@backstage/integration": "^1.11.0",
37
+ "@backstage/core-plugin-api": "^1.9.3-next.0",
38
+ "@backstage/integration": "^1.12.0-next.0",
39
39
  "@material-ui/core": "^4.12.2",
40
40
  "@material-ui/icons": "^4.9.1",
41
41
  "@types/react": "^16.13.1 || ^17.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@backstage/cli": "^0.26.5",
45
- "@backstage/core-components": "^0.14.7",
46
- "@backstage/dev-utils": "^1.0.32",
47
- "@backstage/test-utils": "^1.5.5",
44
+ "@backstage/cli": "^0.26.7-next.2",
45
+ "@backstage/core-components": "^0.14.8-next.1",
46
+ "@backstage/dev-utils": "^1.0.33-next.1",
47
+ "@backstage/test-utils": "^1.5.6-next.1",
48
48
  "@testing-library/dom": "^10.0.0",
49
49
  "@testing-library/jest-dom": "^6.0.0",
50
50
  "msw": "^1.0.0"