@backstage/integration-react 1.2.9 → 1.2.10-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 +7 -0
- package/dist/api/ScmAuth.esm.js +1 -1
- package/dist/api/ScmAuth.esm.js.map +1 -1
- package/dist/api/ScmAuthApi.esm.js.map +1 -1
- package/dist/api/ScmIntegrationsApi.esm.js.map +1 -1
- package/dist/components/ScmIntegrationIcon/ScmIntegrationIcon.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
package/dist/api/ScmAuth.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createApiFactory,
|
|
1
|
+
import { createApiFactory, bitbucketAuthApiRef, microsoftAuthApiRef, gitlabAuthApiRef, githubAuthApiRef } from '@backstage/core-plugin-api';
|
|
2
2
|
import { scmAuthApiRef } from './ScmAuthApi.esm.js';
|
|
3
3
|
|
|
4
4
|
class ScmAuthMux {
|
|
@@ -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 scopeMapping?: {\n default?: string[];\n repoWrite?: string[];\n };\n },\n ): ScmAuth {\n const host = options?.host ?? 'bitbucket.org';\n const defaultScopes = options?.scopeMapping?.default ?? [\n 'account',\n 'team',\n 'pullrequest',\n 'snippet',\n 'issue',\n 'project',\n ];\n const repoWriteScopes = options?.scopeMapping?.repoWrite ?? [\n 'pullrequest:write',\n 'snippet:write',\n 'issue:write',\n ];\n return new ScmAuth('bitbucket', bitbucketAuthApi, host, {\n default: defaultScopes,\n repoWrite: repoWriteScopes,\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards Bitbucket Server.\n *\n * The host option determines which URLs that are handled by this instance.\n *\n * The default scopes are:\n *\n * `PUBLIC_REPOS REPO_READ`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `REPO_WRITE`\n */\n static forBitbucketServer(\n bitbucketAuthApi: OAuthApi,\n options: {\n host: string;\n scopeMapping?: {\n default?: string[];\n repoWrite?: string[];\n };\n },\n ): ScmAuth {\n return this.forBitbucket(bitbucketAuthApi, {\n host: options.host,\n scopeMapping: {\n default: options.scopeMapping?.default ?? ['PUBLIC_REPOS', 'REPO_READ'],\n repoWrite: options.scopeMapping?.repoWrite ?? ['REPO_WRITE'],\n },\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;AAAA,EAEA,YAAY,SAAsB,EAAA;AAChC,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA;AAAA;AACpB,EAEA,MAAM,eACJ,OAC+B,EAAA;AAC/B,IAAA,MAAM,GAAM,GAAA,IAAI,GAAI,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC/B,IAAM,MAAA,QAAA,GAAW,KAAK,UAAW,CA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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 scopeMapping?: {\n default?: string[];\n repoWrite?: string[];\n };\n },\n ): ScmAuth {\n const host = options?.host ?? 'bitbucket.org';\n const defaultScopes = options?.scopeMapping?.default ?? [\n 'account',\n 'team',\n 'pullrequest',\n 'snippet',\n 'issue',\n 'project',\n ];\n const repoWriteScopes = options?.scopeMapping?.repoWrite ?? [\n 'pullrequest:write',\n 'snippet:write',\n 'issue:write',\n ];\n return new ScmAuth('bitbucket', bitbucketAuthApi, host, {\n default: defaultScopes,\n repoWrite: repoWriteScopes,\n });\n }\n\n /**\n * Creates a new ScmAuth instance that handles authentication towards Bitbucket Server.\n *\n * The host option determines which URLs that are handled by this instance.\n *\n * The default scopes are:\n *\n * `PUBLIC_REPOS REPO_READ`\n *\n * If the additional `repoWrite` permission is requested, these scopes are added:\n *\n * `REPO_WRITE`\n */\n static forBitbucketServer(\n bitbucketAuthApi: OAuthApi,\n options: {\n host: string;\n scopeMapping?: {\n default?: string[];\n repoWrite?: string[];\n };\n },\n ): ScmAuth {\n return this.forBitbucket(bitbucketAuthApi, {\n host: options.host,\n scopeMapping: {\n default: options.scopeMapping?.default ?? ['PUBLIC_REPOS', 'REPO_READ'],\n repoWrite: options.scopeMapping?.repoWrite ?? ['REPO_WRITE'],\n },\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,UAAA,CAAiC;AAAA,EACrC,UAAA;AAAA,EAEA,YAAY,SAAA,EAAsB;AAChC,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACpB;AAAA,EAEA,MAAM,eACJ,OAAA,EAC+B;AAC/B,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA;AAC/B,IAAA,MAAM,QAAA,GAAW,KAAK,UAAA,CAAW,IAAA,CAAK,OAAK,CAAA,CAAE,cAAA,CAAe,GAAG,CAAC,CAAA;AAChE,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,gCAAA,EAAmC,QAAQ,GAAG,CAAA,yCAAA;AAAA,OAChD;AAAA,IACF;AAEA,IAAA,OAAO,QAAA,CAAS,eAAe,OAAO,CAAA;AAAA,EACxC;AACF;AA2BO,MAAM,OAAA,CAA8B;AAAA;AAAA;AAAA;AAAA,EAIzC,OAAO,uBAAA,GAA0B;AAC/B,IAAA,OAAO,gBAAA,CAAiB;AAAA,MACtB,GAAA,EAAK,aAAA;AAAA,MACL,IAAA,EAAM;AAAA,QACJ,MAAA,EAAQ,gBAAA;AAAA,QACR,MAAA,EAAQ,gBAAA;AAAA,QACR,KAAA,EAAO,mBAAA;AAAA,QACP,SAAA,EAAW;AAAA,OACb;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,MAAA,EAAQ,QAAQ,KAAA,EAAO,SAAA,OACjC,OAAA,CAAQ,KAAA;AAAA,QACN,OAAA,CAAQ,UAAU,MAAM,CAAA;AAAA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AAA,MAAA,CAAO,IAAA,CAAK,GAAG,IAAA,CAAK,aAAA,CAAc,SAAS,CAAA;AAAA,IAC7C;AAEA,IAAA,MAAM,gBAAA,GACJ,IAAA,CAAK,8BAAA,CAA+B,eAAe,CAAA;AAErD,IAAA,IAAI,iBAAiB,MAAA,EAAQ;AAC3B,MAAA,MAAA,CAAO,IAAA,CAAK,GAAG,gBAAgB,CAAA;AAAA,IACjC;AAEA,IAAA,MAAM,eAAe,CAAC,GAAG,IAAI,GAAA,CAAI,MAAM,CAAC,CAAA;AAExC,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,IAAA,CAAK,cAAA,CAAe,cAAc,WAAW,CAAA;AAEtE,IAAA,OAAO;AAAA,MACL,KAAA;AAAA,MACA,OAAA,EAAS;AAAA,QACP,aAAA,EAAe,UAAU,KAAK,CAAA;AAAA;AAChC,KACF;AAAA,EACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScmAuthApi.esm.js","sources":["../../src/api/ScmAuthApi.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 {\n ApiRef,\n createApiRef,\n AuthRequestOptions,\n} from '@backstage/core-plugin-api';\n\n/**\n * The options that control a {@link ScmAuthApi.getCredentials} call.\n *\n * @public\n */\nexport interface ScmAuthTokenOptions extends AuthRequestOptions {\n /**\n * The URL of the SCM resource to be accessed.\n *\n * @example https://github.com/backstage/backstage\n */\n url: string;\n\n /**\n * Whether to request additional access scope.\n *\n * Read access to user, organization, and repositories is always included.\n */\n additionalScope?: {\n /**\n * Requests access to be able to write repository content, including\n * the ability to create things like issues and pull requests.\n */\n repoWrite?: boolean;\n /**\n * Allow an arbitrary list of scopes provided from the user\n * to request from the provider.\n */\n customScopes?: {\n github?: string[];\n azure?: string[];\n bitbucket?: string[];\n gitlab?: string[];\n };\n };\n}\n\n/**\n * The response from a {@link ScmAuthApi.getCredentials} call.\n *\n * @public\n */\nexport interface ScmAuthTokenResponse {\n /**\n * An authorization token that can be used to authenticate requests.\n */\n token: string;\n\n /**\n * The set of HTTP headers that are needed to authenticate requests.\n */\n headers: { [name: string]: string };\n}\n\n/**\n * ScmAuthApi provides methods for authenticating towards source code management services.\n *\n * As opposed to using the GitHub, GitLab and other auth APIs\n * directly, this API allows for more generic access to SCM services.\n *\n * @public\n */\nexport interface ScmAuthApi {\n /**\n * Requests credentials for accessing an SCM resource.\n */\n getCredentials(options: ScmAuthTokenOptions): Promise<ScmAuthTokenResponse>;\n}\n\n/**\n * The ApiRef for the ScmAuthApi.\n *\n * @public\n */\nexport const scmAuthApiRef: ApiRef<ScmAuthApi> = createApiRef({\n id: 'core.scmauth',\n});\n"],"names":[],"mappings":";;AAgGO,MAAM,gBAAoC,
|
|
1
|
+
{"version":3,"file":"ScmAuthApi.esm.js","sources":["../../src/api/ScmAuthApi.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 {\n ApiRef,\n createApiRef,\n AuthRequestOptions,\n} from '@backstage/core-plugin-api';\n\n/**\n * The options that control a {@link ScmAuthApi.getCredentials} call.\n *\n * @public\n */\nexport interface ScmAuthTokenOptions extends AuthRequestOptions {\n /**\n * The URL of the SCM resource to be accessed.\n *\n * @example https://github.com/backstage/backstage\n */\n url: string;\n\n /**\n * Whether to request additional access scope.\n *\n * Read access to user, organization, and repositories is always included.\n */\n additionalScope?: {\n /**\n * Requests access to be able to write repository content, including\n * the ability to create things like issues and pull requests.\n */\n repoWrite?: boolean;\n /**\n * Allow an arbitrary list of scopes provided from the user\n * to request from the provider.\n */\n customScopes?: {\n github?: string[];\n azure?: string[];\n bitbucket?: string[];\n gitlab?: string[];\n };\n };\n}\n\n/**\n * The response from a {@link ScmAuthApi.getCredentials} call.\n *\n * @public\n */\nexport interface ScmAuthTokenResponse {\n /**\n * An authorization token that can be used to authenticate requests.\n */\n token: string;\n\n /**\n * The set of HTTP headers that are needed to authenticate requests.\n */\n headers: { [name: string]: string };\n}\n\n/**\n * ScmAuthApi provides methods for authenticating towards source code management services.\n *\n * As opposed to using the GitHub, GitLab and other auth APIs\n * directly, this API allows for more generic access to SCM services.\n *\n * @public\n */\nexport interface ScmAuthApi {\n /**\n * Requests credentials for accessing an SCM resource.\n */\n getCredentials(options: ScmAuthTokenOptions): Promise<ScmAuthTokenResponse>;\n}\n\n/**\n * The ApiRef for the ScmAuthApi.\n *\n * @public\n */\nexport const scmAuthApiRef: ApiRef<ScmAuthApi> = createApiRef({\n id: 'core.scmauth',\n});\n"],"names":[],"mappings":";;AAgGO,MAAM,gBAAoC,YAAA,CAAa;AAAA,EAC5D,EAAA,EAAI;AACN,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScmIntegrationsApi.esm.js","sources":["../../src/api/ScmIntegrationsApi.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 { Config } from '@backstage/config';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport { ApiRef, createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * Factory class for creating {@link @backstage/integration#ScmIntegrationRegistry} instances.\n *\n * @public\n */\nexport class ScmIntegrationsApi {\n /**\n * Instantiates an {@link @backstage/integration#ScmIntegrationRegistry}.\n *\n * @param config - The root of the config hierarchy.\n */\n static fromConfig(config: Config): ScmIntegrationRegistry {\n return ScmIntegrations.fromConfig(config);\n }\n}\n\n/**\n * The API that holds all configured SCM integrations.\n *\n * @public\n */\nexport const scmIntegrationsApiRef: ApiRef<ScmIntegrationRegistry> =\n createApiRef({\n id: 'integration.scmintegrations',\n });\n"],"names":[],"mappings":";;;AA4BO,MAAM,
|
|
1
|
+
{"version":3,"file":"ScmIntegrationsApi.esm.js","sources":["../../src/api/ScmIntegrationsApi.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 { Config } from '@backstage/config';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport { ApiRef, createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * Factory class for creating {@link @backstage/integration#ScmIntegrationRegistry} instances.\n *\n * @public\n */\nexport class ScmIntegrationsApi {\n /**\n * Instantiates an {@link @backstage/integration#ScmIntegrationRegistry}.\n *\n * @param config - The root of the config hierarchy.\n */\n static fromConfig(config: Config): ScmIntegrationRegistry {\n return ScmIntegrations.fromConfig(config);\n }\n}\n\n/**\n * The API that holds all configured SCM integrations.\n *\n * @public\n */\nexport const scmIntegrationsApiRef: ApiRef<ScmIntegrationRegistry> =\n createApiRef({\n id: 'integration.scmintegrations',\n });\n"],"names":[],"mappings":";;;AA4BO,MAAM,kBAAA,CAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM9B,OAAO,WAAW,MAAA,EAAwC;AACxD,IAAA,OAAO,eAAA,CAAgB,WAAW,MAAM,CAAA;AAAA,EAC1C;AACF;AAOO,MAAM,wBACX,YAAA,CAAa;AAAA,EACX,EAAA,EAAI;AACN,CAAC;;;;"}
|
|
@@ -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 { 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":";;;;
|
|
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 { 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":";;;;AAmCO,MAAM,kBAAA,GAAqB,CAAC,KAAA,KAAmC;AACpE,EAAA,MAAM,EAAE,MAAK,GAAI,KAAA;AACjB,EAAA,MAAM,MAAM,MAAA,EAAO;AACnB,EAAA,MAAM,WAAA,GAAc,QAAA;AACpB,EAAA,MAAM,OAAO,IAAA,GAAO,GAAA,CAAI,aAAA,CAAc,IAAI,KAAK,WAAA,GAAc,WAAA;AAC7D,EAAA,2BAAQ,IAAA,EAAA,EAAK,CAAA;AACf;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
2
|
-
import {
|
|
2
|
+
import { ApiRef, AuthRequestOptions, OAuthApi } from '@backstage/core-plugin-api';
|
|
3
3
|
import { Config } from '@backstage/config';
|
|
4
4
|
import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/integration-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10-next.0",
|
|
4
4
|
"description": "Frontend package for managing integrations towards external systems",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"test": "backstage-cli package test"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/config": "
|
|
37
|
-
"@backstage/core-plugin-api": "
|
|
38
|
-
"@backstage/integration": "
|
|
36
|
+
"@backstage/config": "1.3.3",
|
|
37
|
+
"@backstage/core-plugin-api": "1.10.9",
|
|
38
|
+
"@backstage/integration": "1.18.0-next.0",
|
|
39
39
|
"@material-ui/core": "^4.12.2",
|
|
40
40
|
"@material-ui/icons": "^4.9.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@backstage/cli": "
|
|
44
|
-
"@backstage/core-components": "
|
|
45
|
-
"@backstage/dev-utils": "
|
|
46
|
-
"@backstage/test-utils": "
|
|
43
|
+
"@backstage/cli": "0.34.2-next.1",
|
|
44
|
+
"@backstage/core-components": "0.17.6-next.0",
|
|
45
|
+
"@backstage/dev-utils": "1.1.14-next.1",
|
|
46
|
+
"@backstage/test-utils": "1.7.11",
|
|
47
47
|
"@testing-library/dom": "^10.0.0",
|
|
48
48
|
"@testing-library/jest-dom": "^6.0.0",
|
|
49
49
|
"@types/react": "^18.0.0",
|