@backstage/plugin-app 0.4.3-next.0 → 0.4.3-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 +40 -0
- package/dist/defaultApis.esm.js +2 -2
- package/dist/extensions/AnalyticsApi.esm.js +1 -1
- package/dist/extensions/App.esm.js +1 -1
- package/dist/extensions/AppNav.esm.js +1 -1
- package/dist/extensions/AppRoot.esm.js +1 -1
- package/dist/extensions/AppRoutes.esm.js +17 -2
- package/dist/extensions/AppRoutes.esm.js.map +1 -1
- package/dist/extensions/AppThemeApi.esm.js +1 -1
- package/dist/extensions/IconsApi.esm.js +1 -1
- package/dist/extensions/LegacyComponentsApi.esm.js +1 -1
- package/dist/extensions/PluginHeaderActionsApi.esm.js +1 -1
- package/dist/extensions/PluginWrapperApi.esm.js +1 -1
- package/dist/extensions/SwappableComponentsApi.esm.js +1 -1
- package/dist/extensions/TranslationsApi.esm.js +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/packages/app-defaults/src/defaults/apis.esm.js +3 -2
- package/dist/packages/app-defaults/src/defaults/apis.esm.js.map +1 -1
- package/dist/packages/core-app-api/src/apis/implementations/FetchApi/ClarifyFailuresFetchMiddleware.esm.js +32 -0
- package/dist/packages/core-app-api/src/apis/implementations/FetchApi/ClarifyFailuresFetchMiddleware.esm.js.map +1 -0
- package/dist/packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.esm.js +8 -0
- package/dist/packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.esm.js.map +1 -1
- package/dist/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.esm.js +16 -0
- package/dist/packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.esm.js.map +1 -1
- package/dist/packages/frontend-plugin-api/src/translation/TranslationRef.esm.js.map +1 -1
- package/dist/plugins/app/package.json.esm.js +1 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @backstage/plugin-app
|
|
2
2
|
|
|
3
|
+
## 0.4.3-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9244b70: The default auth implementation now checks for a `logoutUrl` in the logout response body. If the auth provider returns one (e.g. Auth0 federated logout), the browser is redirected to that URL to clear the provider's session cookies. This is backward compatible — providers that return an empty response are unaffected.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/ui@0.14.0-next.2
|
|
10
|
+
- @backstage/theme@0.7.3-next.0
|
|
11
|
+
- @backstage/core-components@0.18.9-next.1
|
|
12
|
+
- @backstage/core-plugin-api@1.12.5-next.2
|
|
13
|
+
- @backstage/filter-predicates@0.1.2-next.0
|
|
14
|
+
- @backstage/frontend-plugin-api@0.16.0-next.2
|
|
15
|
+
- @backstage/integration-react@1.2.17-next.1
|
|
16
|
+
- @backstage/plugin-permission-react@0.4.42-next.1
|
|
17
|
+
|
|
18
|
+
## 0.4.3-next.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- e5baa20: Added support for configuring URL redirects on the `app/routes` extension. Redirects can be configured through `app-config` as an array of `{from, to}` path pairs, which will cause navigation to the `from` path to be redirected to the `to` path.
|
|
23
|
+
|
|
24
|
+
For example:
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
app:
|
|
28
|
+
extensions:
|
|
29
|
+
- app/routes:
|
|
30
|
+
config:
|
|
31
|
+
redirects:
|
|
32
|
+
- from: /old-path
|
|
33
|
+
to: /new-path
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
- @backstage/ui@0.14.0-next.1
|
|
38
|
+
- @backstage/frontend-plugin-api@0.16.0-next.1
|
|
39
|
+
- @backstage/core-components@0.18.9-next.0
|
|
40
|
+
- @backstage/core-plugin-api@1.12.5-next.1
|
|
41
|
+
- @backstage/plugin-app-react@0.2.2-next.1
|
|
42
|
+
|
|
3
43
|
## 0.4.3-next.0
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
package/dist/defaultApis.esm.js
CHANGED
|
@@ -25,8 +25,8 @@ import { WebStorage } from './packages/core-app-api/src/apis/implementations/Sto
|
|
|
25
25
|
import { ToastApiForwarder } from './apis/ToastApiForwarder.esm.js';
|
|
26
26
|
import { toastApiForwarderRef } from './apis/toastApiForwarderRef.esm.js';
|
|
27
27
|
import { ApiBlueprint, dialogApiRef, toastApiRef } from '@backstage/frontend-plugin-api';
|
|
28
|
-
import { ScmAuth,
|
|
29
|
-
import {
|
|
28
|
+
import { ScmAuth, scmIntegrationsApiRef, ScmIntegrationsApi } from '@backstage/integration-react';
|
|
29
|
+
import { permissionApiRef, IdentityPermissionApi } from '@backstage/plugin-permission-react';
|
|
30
30
|
import { DefaultDialogApi } from './apis/DefaultDialogApi.esm.js';
|
|
31
31
|
import { analyticsApi } from './extensions/AnalyticsApi.esm.js';
|
|
32
32
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, AnalyticsImplementationBlueprint, analyticsApiRef, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
2
2
|
|
|
3
3
|
const analyticsApi = ApiBlueprint.makeWithOverrides({
|
|
4
4
|
name: "analytics",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createExtension, coreExtensionData,
|
|
2
|
+
import { createExtension, coreExtensionData, ExtensionBoundary, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { ApiProvider } from '../packages/core-app-api/src/apis/system/ApiProvider.esm.js';
|
|
4
4
|
import 'zen-observable';
|
|
5
5
|
import '@backstage/core-plugin-api';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createExtension, coreExtensionData,
|
|
2
|
+
import { createExtension, coreExtensionData, NavItemBlueprint, createExtensionInput, useApi, appTreeApiRef, routeResolutionApiRef } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { NavContentBlueprint } from '@backstage/plugin-app-react';
|
|
4
4
|
import { Sidebar, SidebarItem } from '@backstage/core-components';
|
|
5
5
|
import { useMemo } from 'react';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import { createExtension, coreExtensionData,
|
|
3
|
+
import { createExtension, coreExtensionData, discoveryApiRef, errorApiRef, fetchApiRef, pluginWrapperApiRef, ExtensionBoundary, createExtensionInput, routeResolutionApiRef, useAnalytics } from '@backstage/frontend-plugin-api';
|
|
4
4
|
import { AppRootWrapperBlueprint, RouterBlueprint, SignInPageBlueprint } from '@backstage/plugin-app-react';
|
|
5
5
|
import { BUIProvider } from '@backstage/ui';
|
|
6
6
|
import { identityApiRef, useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createExtension, coreExtensionData, createExtensionInput, NotFoundErrorPage } from '@backstage/frontend-plugin-api';
|
|
3
|
-
import { useRoutes } from 'react-router-dom';
|
|
3
|
+
import { useRoutes, Navigate } from 'react-router-dom';
|
|
4
4
|
|
|
5
5
|
const AppRoutes = createExtension({
|
|
6
6
|
name: "routes",
|
|
@@ -12,10 +12,25 @@ const AppRoutes = createExtension({
|
|
|
12
12
|
coreExtensionData.reactElement
|
|
13
13
|
])
|
|
14
14
|
},
|
|
15
|
+
config: {
|
|
16
|
+
schema: {
|
|
17
|
+
redirects: (z) => z.array(
|
|
18
|
+
z.object({
|
|
19
|
+
from: z.string(),
|
|
20
|
+
to: z.string()
|
|
21
|
+
})
|
|
22
|
+
).optional()
|
|
23
|
+
}
|
|
24
|
+
},
|
|
15
25
|
output: [coreExtensionData.reactElement],
|
|
16
|
-
factory({ inputs }) {
|
|
26
|
+
factory({ inputs, config }) {
|
|
27
|
+
const redirects = config.redirects ?? [];
|
|
17
28
|
const Routes = () => {
|
|
18
29
|
const element = useRoutes([
|
|
30
|
+
...redirects.map((redirect) => ({
|
|
31
|
+
path: redirect.from === "/" ? redirect.from : `${redirect.from.replace(/\/$/, "")}/*`,
|
|
32
|
+
element: /* @__PURE__ */ jsx(Navigate, { to: redirect.to, replace: true })
|
|
33
|
+
})),
|
|
19
34
|
...inputs.routes.map((route) => {
|
|
20
35
|
const routePath = route.get(coreExtensionData.routePath);
|
|
21
36
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRoutes.esm.js","sources":["../../src/extensions/AppRoutes.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createExtension,\n coreExtensionData,\n createExtensionInput,\n NotFoundErrorPage,\n} from '@backstage/frontend-plugin-api';\nimport { useRoutes } from 'react-router-dom';\n\nexport const AppRoutes = createExtension({\n name: 'routes',\n attachTo: { id: 'app/layout', input: 'content' },\n inputs: {\n routes: createExtensionInput([\n coreExtensionData.routePath,\n coreExtensionData.routeRef.optional(),\n coreExtensionData.reactElement,\n ]),\n },\n output: [coreExtensionData.reactElement],\n factory({ inputs }) {\n const Routes = () => {\n const element = useRoutes([\n ...inputs.routes.map(route => {\n const routePath = route.get(coreExtensionData.routePath);\n\n return {\n path:\n routePath === '/'\n ? routePath\n : `${routePath.replace(/\\/$/, '')}/*`,\n\n element: route.get(coreExtensionData.reactElement),\n };\n }),\n {\n path: '*',\n element: <NotFoundErrorPage />,\n },\n ]);\n\n return element;\n };\n\n return [coreExtensionData.reactElement(<Routes />)];\n },\n});\n"],"names":[],"mappings":";;;;AAwBO,MAAM,YAAY,eAAA,CAAgB;AAAA,EACvC,IAAA,EAAM,QAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,YAAA,EAAc,OAAO,SAAA,EAAU;AAAA,EAC/C,MAAA,EAAQ;AAAA,IACN,QAAQ,oBAAA,CAAqB;AAAA,MAC3B,iBAAA,CAAkB,SAAA;AAAA,MAClB,iBAAA,CAAkB,SAAS,QAAA,EAAS;AAAA,MACpC,iBAAA,CAAkB;AAAA,KACnB;AAAA,GACH;AAAA,EACA,MAAA,EAAQ,CAAC,iBAAA,CAAkB,YAAY,CAAA;AAAA,EACvC,OAAA,CAAQ,EAAE,MAAA,EAAO,EAAG;
|
|
1
|
+
{"version":3,"file":"AppRoutes.esm.js","sources":["../../src/extensions/AppRoutes.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createExtension,\n coreExtensionData,\n createExtensionInput,\n NotFoundErrorPage,\n} from '@backstage/frontend-plugin-api';\nimport { Navigate, useRoutes } from 'react-router-dom';\n\nexport const AppRoutes = createExtension({\n name: 'routes',\n attachTo: { id: 'app/layout', input: 'content' },\n inputs: {\n routes: createExtensionInput([\n coreExtensionData.routePath,\n coreExtensionData.routeRef.optional(),\n coreExtensionData.reactElement,\n ]),\n },\n config: {\n schema: {\n redirects: z =>\n z\n .array(\n z.object({\n from: z.string(),\n to: z.string(),\n }),\n )\n .optional(),\n },\n },\n output: [coreExtensionData.reactElement],\n factory({ inputs, config }) {\n const redirects = config.redirects ?? [];\n\n const Routes = () => {\n const element = useRoutes([\n ...redirects.map(redirect => ({\n path:\n redirect.from === '/'\n ? redirect.from\n : `${redirect.from.replace(/\\/$/, '')}/*`,\n element: <Navigate to={redirect.to} replace />,\n })),\n ...inputs.routes.map(route => {\n const routePath = route.get(coreExtensionData.routePath);\n\n return {\n path:\n routePath === '/'\n ? routePath\n : `${routePath.replace(/\\/$/, '')}/*`,\n\n element: route.get(coreExtensionData.reactElement),\n };\n }),\n {\n path: '*',\n element: <NotFoundErrorPage />,\n },\n ]);\n\n return element;\n };\n\n return [coreExtensionData.reactElement(<Routes />)];\n },\n});\n"],"names":[],"mappings":";;;;AAwBO,MAAM,YAAY,eAAA,CAAgB;AAAA,EACvC,IAAA,EAAM,QAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,YAAA,EAAc,OAAO,SAAA,EAAU;AAAA,EAC/C,MAAA,EAAQ;AAAA,IACN,QAAQ,oBAAA,CAAqB;AAAA,MAC3B,iBAAA,CAAkB,SAAA;AAAA,MAClB,iBAAA,CAAkB,SAAS,QAAA,EAAS;AAAA,MACpC,iBAAA,CAAkB;AAAA,KACnB;AAAA,GACH;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,MAAA,EAAQ;AAAA,MACN,SAAA,EAAW,OACT,CAAA,CACG,KAAA;AAAA,QACC,EAAE,MAAA,CAAO;AAAA,UACP,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA,UACf,EAAA,EAAI,EAAE,MAAA;AAAO,SACd;AAAA,QAEF,QAAA;AAAS;AAChB,GACF;AAAA,EACA,MAAA,EAAQ,CAAC,iBAAA,CAAkB,YAAY,CAAA;AAAA,EACvC,OAAA,CAAQ,EAAE,MAAA,EAAQ,MAAA,EAAO,EAAG;AAC1B,IAAA,MAAM,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,EAAC;AAEvC,IAAA,MAAM,SAAS,MAAM;AACnB,MAAA,MAAM,UAAU,SAAA,CAAU;AAAA,QACxB,GAAG,SAAA,CAAU,GAAA,CAAI,CAAA,QAAA,MAAa;AAAA,UAC5B,IAAA,EACE,QAAA,CAAS,IAAA,KAAS,GAAA,GACd,QAAA,CAAS,IAAA,GACT,CAAA,EAAG,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,EAAA,CAAA;AAAA,UACzC,yBAAS,GAAA,CAAC,QAAA,EAAA,EAAS,IAAI,QAAA,CAAS,EAAA,EAAI,SAAO,IAAA,EAAC;AAAA,SAC9C,CAAE,CAAA;AAAA,QACF,GAAG,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,CAAA,KAAA,KAAS;AAC5B,UAAA,MAAM,SAAA,GAAY,KAAA,CAAM,GAAA,CAAI,iBAAA,CAAkB,SAAS,CAAA;AAEvD,UAAA,OAAO;AAAA,YACL,IAAA,EACE,cAAc,GAAA,GACV,SAAA,GACA,GAAG,SAAA,CAAU,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAC,CAAA,EAAA,CAAA;AAAA,YAErC,OAAA,EAAS,KAAA,CAAM,GAAA,CAAI,iBAAA,CAAkB,YAAY;AAAA,WACnD;AAAA,QACF,CAAC,CAAA;AAAA,QACD;AAAA,UACE,IAAA,EAAM,GAAA;AAAA,UACN,OAAA,sBAAU,iBAAA,EAAA,EAAkB;AAAA;AAC9B,OACD,CAAA;AAED,MAAA,OAAO,OAAA;AAAA,IACT,CAAA;AAEA,IAAA,OAAO,CAAC,iBAAA,CAAkB,YAAA,iBAAa,GAAA,CAAC,MAAA,EAAA,EAAO,CAAE,CAAC,CAAA;AAAA,EACpD;AACF,CAAC;;;;"}
|
|
@@ -2,7 +2,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { UnifiedThemeProvider, themes } from '@backstage/theme';
|
|
3
3
|
import DarkIcon from '@material-ui/icons/Brightness2';
|
|
4
4
|
import LightIcon from '@material-ui/icons/WbSunny';
|
|
5
|
-
import { ApiBlueprint,
|
|
5
|
+
import { ApiBlueprint, appThemeApiRef, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
6
6
|
import { ThemeBlueprint } from '@backstage/plugin-app-react';
|
|
7
7
|
import 'zen-observable';
|
|
8
8
|
import '@backstage/core-plugin-api';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, iconsApiRef, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { IconBundleBlueprint } from '@backstage/plugin-app-react';
|
|
3
3
|
import { DefaultIconsApi } from '../packages/frontend-app-api/src/apis/implementations/IconsApi/DefaultIconsApi.esm.js';
|
|
4
4
|
import '../packages/app-defaults/src/defaults/apis.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, Progress, NotFoundErrorPage, ErrorDisplay, createApiRef } from '@backstage/frontend-plugin-api';
|
|
2
2
|
|
|
3
3
|
const LegacyComponentsApi = ApiBlueprint.make({
|
|
4
4
|
name: "components",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, pluginHeaderActionsApiRef, coreExtensionData, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { DefaultPluginHeaderActionsApi } from '../apis/PluginHeaderActionsApi/DefaultPluginHeaderActionsApi.esm.js';
|
|
3
3
|
|
|
4
4
|
const PluginHeaderActionsApi = ApiBlueprint.makeWithOverrides({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, pluginWrapperApiRef, PluginWrapperBlueprint, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { DefaultPluginWrapperApi } from '../apis/PluginWrapperApi/DefaultPluginWrapperApi.esm.js';
|
|
3
3
|
|
|
4
4
|
const PluginWrapperApi = ApiBlueprint.makeWithOverrides({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, swappableComponentsApiRef, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { SwappableComponentBlueprint } from '@backstage/plugin-app-react';
|
|
3
3
|
import { DefaultSwappableComponentsApi } from '../apis/SwappableComponentsApi/DefaultSwappableComponentsApi.esm.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiBlueprint,
|
|
1
|
+
import { ApiBlueprint, appLanguageApiRef, translationApiRef, createExtensionInput } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { TranslationBlueprint } from '@backstage/plugin-app-react';
|
|
3
3
|
import { I18nextTranslationApi } from '../packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.esm.js';
|
|
4
4
|
|
package/dist/index.d.ts
CHANGED
|
@@ -103,8 +103,18 @@ declare const appPlugin: _backstage_frontend_plugin_api.OverridableFrontendPlugi
|
|
|
103
103
|
name: "root";
|
|
104
104
|
}>;
|
|
105
105
|
"app/routes": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
|
|
106
|
-
config: {
|
|
107
|
-
|
|
106
|
+
config: {
|
|
107
|
+
redirects: {
|
|
108
|
+
from: string;
|
|
109
|
+
to: string;
|
|
110
|
+
}[] | undefined;
|
|
111
|
+
};
|
|
112
|
+
configInput: {
|
|
113
|
+
redirects?: {
|
|
114
|
+
from: string;
|
|
115
|
+
to: string;
|
|
116
|
+
}[] | undefined;
|
|
117
|
+
};
|
|
108
118
|
output: _backstage_frontend_plugin_api.ExtensionDataRef<react.JSX.Element, "core.reactElement", {}>;
|
|
109
119
|
inputs: {
|
|
110
120
|
routes: _backstage_frontend_plugin_api.ExtensionInput<_backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FrontendHostDiscovery, AlertApiForwarder, NoOpAnalyticsApi, ErrorAlerter, ErrorApiForwarder, UnhandledErrorForwarder, WebStorage, createFetchApi, FetchMiddlewares, OAuthRequestManager, GoogleAuth, MicrosoftAuth, GithubAuth, OktaAuth, GitlabAuth, OneLoginAuth, BitbucketAuth, BitbucketServerAuth, AtlassianAuth, VMwareCloudAuth, OpenShiftAuth } from '@backstage/core-app-api';
|
|
2
2
|
import { createApiFactory, configApiRef, discoveryApiRef, alertApiRef, analyticsApiRef, errorApiRef, storageApiRef, identityApiRef, fetchApiRef, oauthRequestApiRef, googleAuthApiRef, microsoftAuthApiRef, githubAuthApiRef, oktaAuthApiRef, gitlabAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, atlassianAuthApiRef, vmwareCloudAuthApiRef, openshiftAuthApiRef } from '@backstage/core-plugin-api';
|
|
3
|
-
import {
|
|
3
|
+
import { permissionApiRef, IdentityPermissionApi } from '@backstage/plugin-permission-react';
|
|
4
4
|
|
|
5
5
|
[
|
|
6
6
|
createApiFactory({
|
|
@@ -48,7 +48,8 @@ import { IdentityPermissionApi, permissionApiRef } from '@backstage/plugin-permi
|
|
|
48
48
|
FetchMiddlewares.injectIdentityAuth({
|
|
49
49
|
identityApi,
|
|
50
50
|
config: configApi
|
|
51
|
-
})
|
|
51
|
+
}),
|
|
52
|
+
FetchMiddlewares.clarifyFailures()
|
|
52
53
|
]
|
|
53
54
|
});
|
|
54
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.esm.js","sources":["../../../../../../../packages/app-defaults/src/defaults/apis.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 AlertApiForwarder,\n NoOpAnalyticsApi,\n ErrorApiForwarder,\n ErrorAlerter,\n GoogleAuth,\n GithubAuth,\n OktaAuth,\n GitlabAuth,\n MicrosoftAuth,\n BitbucketAuth,\n BitbucketServerAuth,\n OAuthRequestManager,\n WebStorage,\n OneLoginAuth,\n UnhandledErrorForwarder,\n AtlassianAuth,\n createFetchApi,\n FetchMiddlewares,\n VMwareCloudAuth,\n FrontendHostDiscovery,\n OpenShiftAuth,\n} from '@backstage/core-app-api';\n\nimport {\n createApiFactory,\n alertApiRef,\n analyticsApiRef,\n errorApiRef,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n oauthRequestApiRef,\n googleAuthApiRef,\n githubAuthApiRef,\n oktaAuthApiRef,\n gitlabAuthApiRef,\n microsoftAuthApiRef,\n storageApiRef,\n configApiRef,\n oneloginAuthApiRef,\n bitbucketAuthApiRef,\n bitbucketServerAuthApiRef,\n atlassianAuthApiRef,\n vmwareCloudAuthApiRef,\n openshiftAuthApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n permissionApiRef,\n IdentityPermissionApi,\n} from '@backstage/plugin-permission-react';\n\nexport const apis = [\n createApiFactory({\n api: discoveryApiRef,\n deps: { configApi: configApiRef },\n factory: ({ configApi }) => FrontendHostDiscovery.fromConfig(configApi),\n }),\n createApiFactory({\n api: alertApiRef,\n deps: {},\n factory: () => new AlertApiForwarder(),\n }),\n createApiFactory({\n api: analyticsApiRef,\n deps: {},\n factory: () => new NoOpAnalyticsApi(),\n }),\n createApiFactory({\n api: errorApiRef,\n deps: { alertApi: alertApiRef },\n factory: ({ alertApi }) => {\n const errorApi = new ErrorAlerter(alertApi, new ErrorApiForwarder());\n UnhandledErrorForwarder.forward(errorApi, { hidden: false });\n return errorApi;\n },\n }),\n createApiFactory({\n api: storageApiRef,\n deps: { errorApi: errorApiRef },\n factory: ({ errorApi }) => WebStorage.create({ errorApi }),\n }),\n createApiFactory({\n api: fetchApiRef,\n deps: {\n configApi: configApiRef,\n identityApi: identityApiRef,\n discoveryApi: discoveryApiRef,\n },\n factory: ({ configApi, identityApi, discoveryApi }) => {\n return createFetchApi({\n middleware: [\n FetchMiddlewares.resolvePluginProtocol({\n discoveryApi,\n }),\n FetchMiddlewares.injectIdentityAuth({\n identityApi,\n config: configApi,\n }),\n ],\n });\n },\n }),\n createApiFactory({\n api: oauthRequestApiRef,\n deps: {},\n factory: () => new OAuthRequestManager(),\n }),\n createApiFactory({\n api: googleAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n GoogleAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: microsoftAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n MicrosoftAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: githubAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n GithubAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n defaultScopes: ['read:user'],\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: oktaAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n OktaAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: gitlabAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n GitlabAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: oneloginAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n OneLoginAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: bitbucketAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n BitbucketAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n defaultScopes: ['account'],\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: bitbucketServerAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n BitbucketServerAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n defaultScopes: ['REPO_READ'],\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: atlassianAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) => {\n return AtlassianAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n });\n },\n }),\n createApiFactory({\n api: vmwareCloudAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) => {\n return VMwareCloudAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n });\n },\n }),\n createApiFactory({\n api: openshiftAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) => {\n return OpenShiftAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n });\n },\n }),\n createApiFactory({\n api: permissionApiRef,\n deps: {\n discovery: discoveryApiRef,\n identity: identityApiRef,\n config: configApiRef,\n },\n factory: ({ config, discovery, identity }) =>\n IdentityPermissionApi.create({ config, discovery, identity }),\n }),\n];\n"],"names":[],"mappings":";;;;AAoEoB;AAAA,EAClB,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,eAAA;AAAA,IACL,IAAA,EAAM,EAAE,SAAA,EAAW,YAAA,EAAa;AAAA,IAChC,SAAS,CAAC,EAAE,WAAU,KAAM,qBAAA,CAAsB,WAAW,SAAS;AAAA,GACvE,CAAA;AAAA,EACD,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,WAAA;AAAA,IACL,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,iBAAA;AAAkB,GACtC,CAAA;AAAA,EACD,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,eAAA;AAAA,IACL,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IA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A,EAAW,QAAA,EAAS,KACtC,qBAAA,CAAsB,MAAA,CAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,UAAU;AAAA,GAC/D;AACH"}
|
|
1
|
+
{"version":3,"file":"apis.esm.js","sources":["../../../../../../../packages/app-defaults/src/defaults/apis.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 AlertApiForwarder,\n NoOpAnalyticsApi,\n ErrorApiForwarder,\n ErrorAlerter,\n GoogleAuth,\n GithubAuth,\n OktaAuth,\n GitlabAuth,\n MicrosoftAuth,\n BitbucketAuth,\n BitbucketServerAuth,\n OAuthRequestManager,\n WebStorage,\n OneLoginAuth,\n UnhandledErrorForwarder,\n AtlassianAuth,\n createFetchApi,\n FetchMiddlewares,\n VMwareCloudAuth,\n FrontendHostDiscovery,\n OpenShiftAuth,\n} from '@backstage/core-app-api';\n\nimport {\n createApiFactory,\n alertApiRef,\n analyticsApiRef,\n errorApiRef,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n oauthRequestApiRef,\n googleAuthApiRef,\n githubAuthApiRef,\n oktaAuthApiRef,\n gitlabAuthApiRef,\n microsoftAuthApiRef,\n storageApiRef,\n configApiRef,\n oneloginAuthApiRef,\n bitbucketAuthApiRef,\n bitbucketServerAuthApiRef,\n atlassianAuthApiRef,\n vmwareCloudAuthApiRef,\n openshiftAuthApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n permissionApiRef,\n IdentityPermissionApi,\n} from '@backstage/plugin-permission-react';\n\nexport const apis = [\n createApiFactory({\n api: discoveryApiRef,\n deps: { configApi: configApiRef },\n factory: ({ configApi }) => FrontendHostDiscovery.fromConfig(configApi),\n }),\n createApiFactory({\n api: alertApiRef,\n deps: {},\n factory: () => new AlertApiForwarder(),\n }),\n createApiFactory({\n api: analyticsApiRef,\n deps: {},\n factory: () => new NoOpAnalyticsApi(),\n }),\n createApiFactory({\n api: errorApiRef,\n deps: { alertApi: alertApiRef },\n factory: ({ alertApi }) => {\n const errorApi = new ErrorAlerter(alertApi, new ErrorApiForwarder());\n UnhandledErrorForwarder.forward(errorApi, { hidden: false });\n return errorApi;\n },\n }),\n createApiFactory({\n api: storageApiRef,\n deps: { errorApi: errorApiRef },\n factory: ({ errorApi }) => WebStorage.create({ errorApi }),\n }),\n createApiFactory({\n api: fetchApiRef,\n deps: {\n configApi: configApiRef,\n identityApi: identityApiRef,\n discoveryApi: discoveryApiRef,\n },\n factory: ({ configApi, identityApi, discoveryApi }) => {\n return createFetchApi({\n middleware: [\n FetchMiddlewares.resolvePluginProtocol({\n discoveryApi,\n }),\n FetchMiddlewares.injectIdentityAuth({\n identityApi,\n config: configApi,\n }),\n FetchMiddlewares.clarifyFailures(),\n ],\n });\n },\n }),\n createApiFactory({\n api: oauthRequestApiRef,\n deps: {},\n factory: () => new OAuthRequestManager(),\n }),\n createApiFactory({\n api: googleAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n GoogleAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: microsoftAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n MicrosoftAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: githubAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n GithubAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n defaultScopes: ['read:user'],\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: oktaAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n OktaAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: gitlabAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n GitlabAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: oneloginAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n OneLoginAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: bitbucketAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n BitbucketAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n defaultScopes: ['account'],\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: bitbucketServerAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) =>\n BitbucketServerAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n defaultScopes: ['REPO_READ'],\n environment: configApi.getOptionalString('auth.environment'),\n }),\n }),\n createApiFactory({\n api: atlassianAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) => {\n return AtlassianAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n });\n },\n }),\n createApiFactory({\n api: vmwareCloudAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) => {\n return VMwareCloudAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n });\n },\n }),\n createApiFactory({\n api: openshiftAuthApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n oauthRequestApi: oauthRequestApiRef,\n configApi: configApiRef,\n },\n factory: ({ discoveryApi, oauthRequestApi, configApi }) => {\n return OpenShiftAuth.create({\n configApi,\n discoveryApi,\n oauthRequestApi,\n environment: configApi.getOptionalString('auth.environment'),\n });\n },\n }),\n createApiFactory({\n api: permissionApiRef,\n deps: {\n discovery: discoveryApiRef,\n identity: identityApiRef,\n config: configApiRef,\n },\n factory: ({ config, discovery, identity }) =>\n IdentityPermissionApi.create({ config, discovery, identity }),\n }),\n];\n"],"names":[],"mappings":";;;;AAoEoB;AAAA,EAClB,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,eAAA;AAAA,IACL,IAAA,EAAM,EAAE,SAAA,EAAW,YAAA,EAAa;AAAA,IAChC,SAAS,CAAC,EAAE,WAAU,KAAM,qBAAA,CAAsB,WAAW,SAAS;AAAA,GACvE,CAAA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B,kBAAkB;AAAA,OAC5D,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AAAA,EACD,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,gBAAA;AAAA,IACL,IAAA,EAAM;AAAA,MACJ,SAAA,EAAW,eAAA;AAAA,MACX,QAAA,EAAU,cAAA;AAAA,MACV,MAAA,EAAQ;AAAA,KACV;AAAA,IACA,OAAA,EAAS,CAAC,EAAE,MAAA,EAAQ,SAAA,EAAW,QAAA,EAAS,KACtC,qBAAA,CAAsB,MAAA,CAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,UAAU;AAAA,GAC/D;AACH"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class ClarifyFailuresFetchMiddleware {
|
|
2
|
+
apply(next) {
|
|
3
|
+
return async (input, init) => {
|
|
4
|
+
try {
|
|
5
|
+
return await next(input, init);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
if (e instanceof TypeError && e.message === "Failed to fetch") {
|
|
8
|
+
try {
|
|
9
|
+
let method;
|
|
10
|
+
let url;
|
|
11
|
+
if (isRequestLike(input)) {
|
|
12
|
+
method = input.method;
|
|
13
|
+
url = input.url;
|
|
14
|
+
} else {
|
|
15
|
+
method = init?.method || "GET";
|
|
16
|
+
url = String(input);
|
|
17
|
+
}
|
|
18
|
+
e.message = `Failed to fetch: ${method} ${url}`;
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function isRequestLike(input) {
|
|
28
|
+
return input !== null && typeof input === "object" && "method" in input && "url" in input && typeof input.method === "string" && typeof input.url === "string";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { ClarifyFailuresFetchMiddleware };
|
|
32
|
+
//# sourceMappingURL=ClarifyFailuresFetchMiddleware.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClarifyFailuresFetchMiddleware.esm.js","sources":["../../../../../../../../../packages/core-app-api/src/apis/implementations/FetchApi/ClarifyFailuresFetchMiddleware.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { FetchMiddleware } from './types';\n\n/**\n * Replaces the generic \"TypeError: Failed to fetch\" error with a more\n * informative message that includes the HTTP method and target URL.\n */\nexport class ClarifyFailuresFetchMiddleware implements FetchMiddleware {\n apply(next: typeof fetch): typeof fetch {\n return async (input, init) => {\n try {\n // NOTE: The \"as any\" cast is because of subtle undici type differences\n // that happened in a node types bump. Immaterial at runtime.\n return await next(input as any, init);\n } catch (e) {\n if (e instanceof TypeError && e.message === 'Failed to fetch') {\n try {\n let method: string;\n let url: string;\n\n if (isRequestLike(input)) {\n method = input.method;\n url = input.url;\n } else {\n method = init?.method || 'GET';\n url = String(input);\n }\n\n e.message = `Failed to fetch: ${method} ${url}`;\n } catch {\n // intentionally ignored - clarification is best-effort\n }\n }\n throw e;\n }\n };\n }\n}\n\nfunction isRequestLike(input: unknown): input is Request {\n return (\n input !== null &&\n typeof input === 'object' &&\n 'method' in input &&\n 'url' in input &&\n typeof input.method === 'string' &&\n typeof input.url === 'string'\n );\n}\n"],"names":[],"mappings":"AAsBO,MAAM,8BAAA,CAA0D;AAAA,EACrE,MAAM,IAAA,EAAkC;AACtC,IAAA,OAAO,OAAO,OAAO,IAAA,KAAS;AAC5B,MAAA,IAAI;AAGF,QAAA,OAAO,MAAM,IAAA,CAAK,KAAA,EAAc,IAAI,CAAA;AAAA,MACtC,SAAS,CAAA,EAAG;AACV,QAAA,IAAI,CAAA,YAAa,SAAA,IAAa,CAAA,CAAE,OAAA,KAAY,iBAAA,EAAmB;AAC7D,UAAA,IAAI;AACF,YAAA,IAAI,MAAA;AACJ,YAAA,IAAI,GAAA;AAEJ,YAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,cAAA,MAAA,GAAS,KAAA,CAAM,MAAA;AACf,cAAA,GAAA,GAAM,KAAA,CAAM,GAAA;AAAA,YACd,CAAA,MAAO;AACL,cAAA,MAAA,GAAS,MAAM,MAAA,IAAU,KAAA;AACzB,cAAA,GAAA,GAAM,OAAO,KAAK,CAAA;AAAA,YACpB;AAEA,YAAA,CAAA,CAAE,OAAA,GAAU,CAAA,iBAAA,EAAoB,MAAM,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA;AAAA,UAC/C,CAAA,CAAA,MAAQ;AAAA,UAER;AAAA,QACF;AACA,QAAA,MAAM,CAAA;AAAA,MACR;AAAA,IACF,CAAA;AAAA,EACF;AACF;AAEA,SAAS,cAAc,KAAA,EAAkC;AACvD,EAAA,OACE,KAAA,KAAU,IAAA,IACV,OAAO,KAAA,KAAU,YACjB,QAAA,IAAY,KAAA,IACZ,KAAA,IAAS,KAAA,IACT,OAAO,KAAA,CAAM,MAAA,KAAW,QAAA,IACxB,OAAO,MAAM,GAAA,KAAQ,QAAA;AAEzB;;;;"}
|
package/dist/packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.esm.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClarifyFailuresFetchMiddleware } from './ClarifyFailuresFetchMiddleware.esm.js';
|
|
1
2
|
import { IdentityAuthInjectorFetchMiddleware } from './IdentityAuthInjectorFetchMiddleware.esm.js';
|
|
2
3
|
import { PluginProtocolResolverFetchMiddleware } from './PluginProtocolResolverFetchMiddleware.esm.js';
|
|
3
4
|
|
|
@@ -37,6 +38,13 @@ class FetchMiddlewares {
|
|
|
37
38
|
static injectIdentityAuth(options) {
|
|
38
39
|
return IdentityAuthInjectorFetchMiddleware.create(options);
|
|
39
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Replaces the generic "TypeError: Failed to fetch" with a more informative
|
|
43
|
+
* message that includes some request details to ease debugging.
|
|
44
|
+
*/
|
|
45
|
+
static clarifyFailures() {
|
|
46
|
+
return new ClarifyFailuresFetchMiddleware();
|
|
47
|
+
}
|
|
40
48
|
constructor() {
|
|
41
49
|
}
|
|
42
50
|
}
|
package/dist/packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchMiddlewares.esm.js","sources":["../../../../../../../../../packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.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 { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { IdentityAuthInjectorFetchMiddleware } from './IdentityAuthInjectorFetchMiddleware';\nimport { PluginProtocolResolverFetchMiddleware } from './PluginProtocolResolverFetchMiddleware';\nimport { FetchMiddleware } from './types';\n\n/**\n * A collection of common middlewares for the FetchApi.\n *\n * @public\n */\nexport class FetchMiddlewares {\n /**\n * Handles translation from `plugin://` URLs to concrete http(s) URLs based on\n * the discovery API.\n *\n * @remarks\n *\n * If the request is for `plugin://catalog/entities?filter=x=y`, the discovery\n * API will be queried for `'catalog'`. If it returned\n * `https://backstage.example.net/api/catalog`, the resulting query would be\n * `https://backstage.example.net/api/catalog/entities?filter=x=y`.\n *\n * If the incoming URL protocol was not `plugin`, the request is just passed\n * through verbatim to the underlying implementation.\n */\n static resolvePluginProtocol(options: {\n discoveryApi: DiscoveryApi;\n }): FetchMiddleware {\n return new PluginProtocolResolverFetchMiddleware(options.discoveryApi);\n }\n\n /**\n * Injects a Backstage token header when the user is signed in.\n *\n * @remarks\n *\n * Per default, an `Authorization: Bearer <token>` is generated. This can be\n * customized using the `header` option.\n *\n * The header injection only happens on allowlisted URLs. Per default, if the\n * `config` option is passed in, the `backend.baseUrl` is allowlisted, unless\n * the `urlPrefixAllowlist` or `allowUrl` options are passed in, in which case\n * they take precedence. If you pass in neither config nor an\n * allowlist/callback, the middleware will have no effect since effectively no\n * request will match the (nonexistent) rules.\n */\n static injectIdentityAuth(options: {\n identityApi: IdentityApi;\n config?: Config;\n urlPrefixAllowlist?: string[];\n allowUrl?: (url: string) => boolean;\n header?: {\n name: string;\n value: (backstageToken: string) => string;\n };\n }): FetchMiddleware {\n return IdentityAuthInjectorFetchMiddleware.create(options);\n }\n\n private constructor() {}\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FetchMiddlewares.esm.js","sources":["../../../../../../../../../packages/core-app-api/src/apis/implementations/FetchApi/FetchMiddlewares.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 { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { ClarifyFailuresFetchMiddleware } from './ClarifyFailuresFetchMiddleware';\nimport { IdentityAuthInjectorFetchMiddleware } from './IdentityAuthInjectorFetchMiddleware';\nimport { PluginProtocolResolverFetchMiddleware } from './PluginProtocolResolverFetchMiddleware';\nimport { FetchMiddleware } from './types';\n\n/**\n * A collection of common middlewares for the FetchApi.\n *\n * @public\n */\nexport class FetchMiddlewares {\n /**\n * Handles translation from `plugin://` URLs to concrete http(s) URLs based on\n * the discovery API.\n *\n * @remarks\n *\n * If the request is for `plugin://catalog/entities?filter=x=y`, the discovery\n * API will be queried for `'catalog'`. If it returned\n * `https://backstage.example.net/api/catalog`, the resulting query would be\n * `https://backstage.example.net/api/catalog/entities?filter=x=y`.\n *\n * If the incoming URL protocol was not `plugin`, the request is just passed\n * through verbatim to the underlying implementation.\n */\n static resolvePluginProtocol(options: {\n discoveryApi: DiscoveryApi;\n }): FetchMiddleware {\n return new PluginProtocolResolverFetchMiddleware(options.discoveryApi);\n }\n\n /**\n * Injects a Backstage token header when the user is signed in.\n *\n * @remarks\n *\n * Per default, an `Authorization: Bearer <token>` is generated. This can be\n * customized using the `header` option.\n *\n * The header injection only happens on allowlisted URLs. Per default, if the\n * `config` option is passed in, the `backend.baseUrl` is allowlisted, unless\n * the `urlPrefixAllowlist` or `allowUrl` options are passed in, in which case\n * they take precedence. If you pass in neither config nor an\n * allowlist/callback, the middleware will have no effect since effectively no\n * request will match the (nonexistent) rules.\n */\n static injectIdentityAuth(options: {\n identityApi: IdentityApi;\n config?: Config;\n urlPrefixAllowlist?: string[];\n allowUrl?: (url: string) => boolean;\n header?: {\n name: string;\n value: (backstageToken: string) => string;\n };\n }): FetchMiddleware {\n return IdentityAuthInjectorFetchMiddleware.create(options);\n }\n\n /**\n * Replaces the generic \"TypeError: Failed to fetch\" with a more informative\n * message that includes some request details to ease debugging.\n */\n static clarifyFailures(): FetchMiddleware {\n return new ClarifyFailuresFetchMiddleware();\n }\n\n private constructor() {}\n}\n"],"names":[],"mappings":";;;;AA4BO,MAAM,gBAAA,CAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAe5B,OAAO,sBAAsB,OAAA,EAET;AAClB,IAAA,OAAO,IAAI,qCAAA,CAAsC,OAAA,CAAQ,YAAY,CAAA;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,OAAO,mBAAmB,OAAA,EASN;AAClB,IAAA,OAAO,mCAAA,CAAoC,OAAO,OAAO,CAAA;AAAA,EAC3D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,eAAA,GAAmC;AACxC,IAAA,OAAO,IAAI,8BAAA,EAA+B;AAAA,EAC5C;AAAA,EAEQ,WAAA,GAAc;AAAA,EAAC;AACzB;;;;"}
|
|
@@ -103,6 +103,22 @@ class DefaultAuthConnector {
|
|
|
103
103
|
error.status = res.status;
|
|
104
104
|
throw error;
|
|
105
105
|
}
|
|
106
|
+
try {
|
|
107
|
+
const contentType = res.headers.get("content-type");
|
|
108
|
+
if (contentType?.includes("application/json")) {
|
|
109
|
+
const body = await res.json();
|
|
110
|
+
if (body.logoutUrl) {
|
|
111
|
+
const url = new URL(body.logoutUrl);
|
|
112
|
+
if (url.protocol === "https:" || url.hostname === "localhost") {
|
|
113
|
+
window.location.href = body.logoutUrl;
|
|
114
|
+
return new Promise(() => {
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
return void 0;
|
|
106
122
|
}
|
|
107
123
|
async showPopup(scopes) {
|
|
108
124
|
const scope = this.joinScopesFunc(scopes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAuthConnector.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.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 */\nimport {\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n OAuthRequestApi,\n OAuthRequester,\n} from '@backstage/core-plugin-api';\nimport { openLoginPopup } from '../loginPopup';\nimport {\n AuthConnector,\n AuthConnectorCreateSessionOptions,\n PopupOptions,\n AuthConnectorRefreshSessionOptions,\n} from './types';\n\nlet warned = false;\n\ntype Options<AuthSession> = {\n /**\n * DiscoveryApi instance used to locate the auth backend endpoint.\n */\n discoveryApi: DiscoveryApi;\n /**\n * Environment hint passed on to auth backend, for example 'production' or 'development'\n */\n environment: string;\n /**\n * Information about the auth provider to be shown to the user.\n * The ID Must match the backend auth plugin configuration, for example 'google'.\n */\n provider: AuthProviderInfo;\n /**\n * API used to instantiate an auth requester.\n */\n oauthRequestApi: OAuthRequestApi;\n /**\n * Function used to join together a set of scopes, defaults to joining with a space character.\n */\n joinScopes?: (scopes: Set<string>) => string;\n /**\n * Function used to transform an auth response into the session type.\n */\n sessionTransform?(response: any): AuthSession | Promise<AuthSession>;\n /**\n * ConfigApi instance used to configure authentication flow of pop-up or redirect.\n */\n configApi?: ConfigApi;\n /**\n * Options used to configure auth popup\n */\n popupOptions?: PopupOptions;\n};\n\nfunction defaultJoinScopes(scopes: Set<string>) {\n return [...scopes].join(' ');\n}\n\n/**\n * DefaultAuthConnector is the default auth connector in Backstage. It talks to the\n * backend auth plugin through the standardized API, and requests user permission\n * via the OAuthRequestApi.\n */\nexport class DefaultAuthConnector<AuthSession>\n implements AuthConnector<AuthSession>\n{\n private readonly discoveryApi: DiscoveryApi;\n private readonly environment: string;\n private readonly provider: AuthProviderInfo;\n private readonly joinScopesFunc: (scopes: Set<string>) => string;\n private readonly authRequester: OAuthRequester<AuthSession>;\n private readonly sessionTransform: (response: any) => Promise<AuthSession>;\n private readonly enableExperimentalRedirectFlow: boolean;\n private readonly popupOptions: PopupOptions | undefined;\n constructor(options: Options<AuthSession>) {\n const {\n configApi,\n discoveryApi,\n environment,\n provider,\n joinScopes = defaultJoinScopes,\n oauthRequestApi,\n sessionTransform = id => id,\n popupOptions,\n } = options;\n\n if (!warned && !configApi) {\n // eslint-disable-next-line no-console\n console.warn(\n 'DEPRECATION WARNING: Authentication providers require a configApi instance to configure the authentication flow. Please provide one to the authentication provider constructor.',\n );\n warned = true;\n }\n\n this.enableExperimentalRedirectFlow = configApi\n ? configApi.getOptionalBoolean('enableExperimentalRedirectFlow') ?? false\n : false;\n\n this.authRequester = oauthRequestApi.createAuthRequester({\n provider,\n onAuthRequest: async scopes => {\n if (!this.enableExperimentalRedirectFlow) {\n return this.showPopup(scopes);\n }\n return this.executeRedirect(scopes);\n },\n });\n\n this.discoveryApi = discoveryApi;\n this.environment = environment;\n this.provider = provider;\n this.joinScopesFunc = joinScopes;\n this.sessionTransform = sessionTransform;\n this.popupOptions = popupOptions;\n }\n\n async createSession(\n options: AuthConnectorCreateSessionOptions,\n ): Promise<AuthSession> {\n if (options.instantPopup) {\n if (this.enableExperimentalRedirectFlow) {\n return this.executeRedirect(options.scopes);\n }\n return this.showPopup(options.scopes);\n }\n return this.authRequester(options.scopes);\n }\n\n async refreshSession(\n options?: AuthConnectorRefreshSessionOptions,\n ): Promise<any> {\n const res = await fetch(\n await this.buildUrl('/refresh', {\n optional: true,\n ...(options && { scope: this.joinScopesFunc(options.scopes) }),\n }),\n {\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n },\n ).catch(error => {\n throw new Error(`Auth refresh request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(\n `Auth refresh request failed, ${res.statusText}`,\n );\n error.status = res.status;\n throw error;\n }\n\n const authInfo = await res.json();\n\n if (authInfo.error) {\n const error = new Error(authInfo.error.message);\n if (authInfo.error.name) {\n error.name = authInfo.error.name;\n }\n throw error;\n }\n return await this.sessionTransform(authInfo);\n }\n\n async removeSession(): Promise<void> {\n const res = await fetch(await this.buildUrl('/logout'), {\n method: 'POST',\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n }).catch(error => {\n throw new Error(`Logout request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(`Logout request failed, ${res.statusText}`);\n error.status = res.status;\n throw error;\n }\n }\n\n private async showPopup(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n const popupUrl = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n flow: 'popup',\n });\n\n const width = this.popupOptions?.size?.fullscreen\n ? window.screen.width\n : this.popupOptions?.size?.width || 450;\n\n const height = this.popupOptions?.size?.fullscreen\n ? window.screen.height\n : this.popupOptions?.size?.height || 730;\n\n const payload = await openLoginPopup({\n url: popupUrl,\n name: `${this.provider.title} Login`,\n width,\n height,\n });\n\n return await this.sessionTransform(payload);\n }\n\n private async executeRedirect(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n // redirect to auth api\n window.location.href = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n redirectUrl: window.location.href,\n flow: 'redirect',\n });\n // return a promise that never resolves\n return new Promise(() => {});\n }\n\n private async buildUrl(\n path: string,\n query?: { [key: string]: string | boolean | undefined },\n ): Promise<string> {\n const baseUrl = await this.discoveryApi.getBaseUrl('auth');\n const queryString = this.buildQueryString({\n ...query,\n env: this.environment,\n });\n\n return `${baseUrl}/${this.provider.id}${path}${queryString}`;\n }\n\n private buildQueryString(query?: {\n [key: string]: string | boolean | undefined;\n }): string {\n if (!query) {\n return '';\n }\n\n const queryString = Object.entries<string | boolean | undefined>(query)\n .map(([key, value]) => {\n if (typeof value === 'string') {\n return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n } else if (value) {\n return encodeURIComponent(key);\n }\n return undefined;\n })\n .filter(Boolean)\n .join('&');\n\n if (!queryString) {\n return '';\n }\n return `?${queryString}`;\n }\n}\n"],"names":[],"mappings":";;AA8BA,IAAI,MAAA,GAAS,KAAA;AAsCb,SAAS,kBAAkB,MAAA,EAAqB;AAC9C,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,GAAG,CAAA;AAC7B;AAOO,MAAM,oBAAA,CAEb;AAAA,EACmB,YAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,8BAAA;AAAA,EACA,YAAA;AAAA,EACjB,YAAY,OAAA,EAA+B;AACzC,IAAA,MAAM;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA,GAAa,iBAAA;AAAA,MACb,eAAA;AAAA,MACA,mBAAmB,CAAA,EAAA,KAAM,EAAA;AAAA,MACzB;AAAA,KACF,GAAI,OAAA;AAEJ,IAAA,IAAI,CAAC,MAAA,IAAU,CAAC,SAAA,EAAW;AAEzB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AACA,MAAA,MAAA,GAAS,IAAA;AAAA,IACX;AAEA,IAAA,IAAA,CAAK,iCAAiC,SAAA,GAClC,SAAA,CAAU,kBAAA,CAAmB,gCAAgC,KAAK,KAAA,GAClE,KAAA;AAEJ,IAAA,IAAA,CAAK,aAAA,GAAgB,gBAAgB,mBAAA,CAAoB;AAAA,MACvD,QAAA;AAAA,MACA,aAAA,EAAe,OAAM,MAAA,KAAU;AAC7B,QAAA,IAAI,CAAC,KAAK,8BAAA,EAAgC;AACxC,UAAA,OAAO,IAAA,CAAK,UAAU,MAAM,CAAA;AAAA,QAC9B;AACA,QAAA,OAAO,IAAA,CAAK,gBAAgB,MAAM,CAAA;AAAA,MACpC;AAAA,KACD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AAAA,EAC7B;AAAA,EAEA,MAAc,QAAA,CACZ,IAAA,EACA,KAAA,EACiB;AACjB,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,YAAA,CAAa,WAAW,MAAM,CAAA;AACzD,IAAA,MAAM,WAAA,GAAc,KAAK,gBAAA,CAAiB;AAAA,MACxC,GAAG,KAAA;AAAA,MACH,KAAK,IAAA,CAAK;AAAA,KACX,CAAA;AAED,IAAA,OAAO,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAA,CAAK,SAAS,EAAE,CAAA,EAAG,IAAI,CAAA,EAAG,WAAW,CAAA,CAAA;AAAA,EAC5D;AAAA,EAEQ,iBAAiB,KAAA,EAEd;AACT,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,OAAO,EAAA;AAAA,IACT;AAEA,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,OAAA,CAAsC,KAAK,CAAA,CACnE,IAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AACrB,MAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,QAAA,OAAO,GAAG,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAAA,MAChE,WAAW,KAAA,EAAO;AAChB,QAAA,OAAO,mBAAmB,GAAG,CAAA;AAAA,MAC/B;AACA,MAAA,OAAO,MAAA;AAAA,IACT,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,GAAG,CAAA;AAEX,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,EAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,WAAW,CAAA,CAAA;AAAA,EACxB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"DefaultAuthConnector.esm.js","sources":["../../../../../../../../packages/core-app-api/src/lib/AuthConnector/DefaultAuthConnector.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 */\nimport {\n AuthProviderInfo,\n ConfigApi,\n DiscoveryApi,\n OAuthRequestApi,\n OAuthRequester,\n} from '@backstage/core-plugin-api';\nimport { openLoginPopup } from '../loginPopup';\nimport {\n AuthConnector,\n AuthConnectorCreateSessionOptions,\n PopupOptions,\n AuthConnectorRefreshSessionOptions,\n} from './types';\n\nlet warned = false;\n\ntype Options<AuthSession> = {\n /**\n * DiscoveryApi instance used to locate the auth backend endpoint.\n */\n discoveryApi: DiscoveryApi;\n /**\n * Environment hint passed on to auth backend, for example 'production' or 'development'\n */\n environment: string;\n /**\n * Information about the auth provider to be shown to the user.\n * The ID Must match the backend auth plugin configuration, for example 'google'.\n */\n provider: AuthProviderInfo;\n /**\n * API used to instantiate an auth requester.\n */\n oauthRequestApi: OAuthRequestApi;\n /**\n * Function used to join together a set of scopes, defaults to joining with a space character.\n */\n joinScopes?: (scopes: Set<string>) => string;\n /**\n * Function used to transform an auth response into the session type.\n */\n sessionTransform?(response: any): AuthSession | Promise<AuthSession>;\n /**\n * ConfigApi instance used to configure authentication flow of pop-up or redirect.\n */\n configApi?: ConfigApi;\n /**\n * Options used to configure auth popup\n */\n popupOptions?: PopupOptions;\n};\n\nfunction defaultJoinScopes(scopes: Set<string>) {\n return [...scopes].join(' ');\n}\n\n/**\n * DefaultAuthConnector is the default auth connector in Backstage. It talks to the\n * backend auth plugin through the standardized API, and requests user permission\n * via the OAuthRequestApi.\n */\nexport class DefaultAuthConnector<AuthSession>\n implements AuthConnector<AuthSession>\n{\n private readonly discoveryApi: DiscoveryApi;\n private readonly environment: string;\n private readonly provider: AuthProviderInfo;\n private readonly joinScopesFunc: (scopes: Set<string>) => string;\n private readonly authRequester: OAuthRequester<AuthSession>;\n private readonly sessionTransform: (response: any) => Promise<AuthSession>;\n private readonly enableExperimentalRedirectFlow: boolean;\n private readonly popupOptions: PopupOptions | undefined;\n constructor(options: Options<AuthSession>) {\n const {\n configApi,\n discoveryApi,\n environment,\n provider,\n joinScopes = defaultJoinScopes,\n oauthRequestApi,\n sessionTransform = id => id,\n popupOptions,\n } = options;\n\n if (!warned && !configApi) {\n // eslint-disable-next-line no-console\n console.warn(\n 'DEPRECATION WARNING: Authentication providers require a configApi instance to configure the authentication flow. Please provide one to the authentication provider constructor.',\n );\n warned = true;\n }\n\n this.enableExperimentalRedirectFlow = configApi\n ? configApi.getOptionalBoolean('enableExperimentalRedirectFlow') ?? false\n : false;\n\n this.authRequester = oauthRequestApi.createAuthRequester({\n provider,\n onAuthRequest: async scopes => {\n if (!this.enableExperimentalRedirectFlow) {\n return this.showPopup(scopes);\n }\n return this.executeRedirect(scopes);\n },\n });\n\n this.discoveryApi = discoveryApi;\n this.environment = environment;\n this.provider = provider;\n this.joinScopesFunc = joinScopes;\n this.sessionTransform = sessionTransform;\n this.popupOptions = popupOptions;\n }\n\n async createSession(\n options: AuthConnectorCreateSessionOptions,\n ): Promise<AuthSession> {\n if (options.instantPopup) {\n if (this.enableExperimentalRedirectFlow) {\n return this.executeRedirect(options.scopes);\n }\n return this.showPopup(options.scopes);\n }\n return this.authRequester(options.scopes);\n }\n\n async refreshSession(\n options?: AuthConnectorRefreshSessionOptions,\n ): Promise<any> {\n const res = await fetch(\n await this.buildUrl('/refresh', {\n optional: true,\n ...(options && { scope: this.joinScopesFunc(options.scopes) }),\n }),\n {\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n },\n ).catch(error => {\n throw new Error(`Auth refresh request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(\n `Auth refresh request failed, ${res.statusText}`,\n );\n error.status = res.status;\n throw error;\n }\n\n const authInfo = await res.json();\n\n if (authInfo.error) {\n const error = new Error(authInfo.error.message);\n if (authInfo.error.name) {\n error.name = authInfo.error.name;\n }\n throw error;\n }\n return await this.sessionTransform(authInfo);\n }\n\n async removeSession(): Promise<void> {\n const res = await fetch(await this.buildUrl('/logout'), {\n method: 'POST',\n headers: {\n 'x-requested-with': 'XMLHttpRequest',\n },\n credentials: 'include',\n }).catch(error => {\n throw new Error(`Logout request failed, ${error}`);\n });\n\n if (!res.ok) {\n const error: any = new Error(`Logout request failed, ${res.statusText}`);\n error.status = res.status;\n throw error;\n }\n\n // If the auth provider returned a logout URL (e.g. for Auth0 federated\n // logout), redirect the browser to clear the provider's session cookies.\n try {\n const contentType = res.headers.get('content-type');\n if (contentType?.includes('application/json')) {\n const body = await res.json();\n if (body.logoutUrl) {\n const url = new URL(body.logoutUrl);\n if (url.protocol === 'https:' || url.hostname === 'localhost') {\n window.location.href = body.logoutUrl;\n return new Promise(() => {});\n }\n }\n }\n } catch {\n // Provider logout redirect is best-effort - the backend session\n // (refresh token cookie and persisted scopes) is already cleared,\n // so we degrade gracefully.\n }\n\n return undefined;\n }\n\n private async showPopup(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n const popupUrl = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n flow: 'popup',\n });\n\n const width = this.popupOptions?.size?.fullscreen\n ? window.screen.width\n : this.popupOptions?.size?.width || 450;\n\n const height = this.popupOptions?.size?.fullscreen\n ? window.screen.height\n : this.popupOptions?.size?.height || 730;\n\n const payload = await openLoginPopup({\n url: popupUrl,\n name: `${this.provider.title} Login`,\n width,\n height,\n });\n\n return await this.sessionTransform(payload);\n }\n\n private async executeRedirect(scopes: Set<string>): Promise<AuthSession> {\n const scope = this.joinScopesFunc(scopes);\n // redirect to auth api\n window.location.href = await this.buildUrl('/start', {\n scope,\n origin: window.location.origin,\n redirectUrl: window.location.href,\n flow: 'redirect',\n });\n // return a promise that never resolves\n return new Promise(() => {});\n }\n\n private async buildUrl(\n path: string,\n query?: { [key: string]: string | boolean | undefined },\n ): Promise<string> {\n const baseUrl = await this.discoveryApi.getBaseUrl('auth');\n const queryString = this.buildQueryString({\n ...query,\n env: this.environment,\n });\n\n return `${baseUrl}/${this.provider.id}${path}${queryString}`;\n }\n\n private buildQueryString(query?: {\n [key: string]: string | boolean | undefined;\n }): string {\n if (!query) {\n return '';\n }\n\n const queryString = Object.entries<string | boolean | undefined>(query)\n .map(([key, value]) => {\n if (typeof value === 'string') {\n return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;\n } else if (value) {\n return encodeURIComponent(key);\n }\n return undefined;\n })\n .filter(Boolean)\n .join('&');\n\n if (!queryString) {\n return '';\n }\n return `?${queryString}`;\n }\n}\n"],"names":[],"mappings":";;AA8BA,IAAI,MAAA,GAAS,KAAA;AAsCb,SAAS,kBAAkB,MAAA,EAAqB;AAC9C,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,GAAG,CAAA;AAC7B;AAOO,MAAM,oBAAA,CAEb;AAAA,EACmB,YAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,8BAAA;AAAA,EACA,YAAA;AAAA,EACjB,YAAY,OAAA,EAA+B;AACzC,IAAA,MAAM;AAAA,MACJ,SAAA;AAAA,MACA,YAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA,GAAa,iBAAA;AAAA,MACb,eAAA;AAAA,MACA,mBAAmB,CAAA,EAAA,KAAM,EAAA;AAAA,MACzB;AAAA,KACF,GAAI,OAAA;AAEJ,IAAA,IAAI,CAAC,MAAA,IAAU,CAAC,SAAA,EAAW;AAEzB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN;AAAA,OACF;AACA,MAAA,MAAA,GAAS,IAAA;AAAA,IACX;AAEA,IAAA,IAAA,CAAK,iCA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AAAA,MACH,KAAK,IAAA,CAAK;AAAA,KACX,CAAA;AAED,IAAA,OAAO,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAA,CAAK,SAAS,EAAE,CAAA,EAAG,IAAI,CAAA,EAAG,WAAW,CAAA,CAAA;AAAA,EAC5D;AAAA,EAEQ,iBAAiB,KAAA,EAEd;AACT,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,OAAO,EAAA;AAAA,IACT;AAEA,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,OAAA,CAAsC,KAAK,CAAA,CACnE,IAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AACrB,MAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,QAAA,OAAO,GAAG,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAAA,MAChE,WAAW,KAAA,EAAO;AAChB,QAAA,OAAO,mBAAmB,GAAG,CAAA;AAAA,MAC/B;AACA,MAAA,OAAO,MAAA;AAAA,IACT,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA,CACd,KAAK,GAAG,CAAA;AAEX,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,OAAO,EAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,WAAW,CAAA,CAAA;AAAA,EACxB;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationRef.esm.js","sources":["../../../../../../../packages/frontend-plugin-api/src/translation/TranslationRef.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTranslationResource,\n TranslationResource,\n} from './TranslationResource';\n\n/** @public */\nexport interface TranslationRef<\n TId extends string = string,\n TMessages extends { [key in string]: string } = { [key in string]: string },\n> {\n $$type: '@backstage/TranslationRef';\n\n id: TId;\n\n T: TMessages;\n}\n\n/** @internal */\ntype AnyMessages = { [key in string]: string };\n\n/** @ignore */\ntype AnyNestedMessages = { [key in string]: AnyNestedMessages | string };\n\n/**\n * Flattens a nested message declaration into a flat object with dot-separated keys.\n *\n * @ignore\n */\ntype FlattenedMessages<TMessages extends AnyNestedMessages> =\n // Flatten out object keys into a union structure of objects, e.g. { a: 'a', b: 'b' } -> { a: 'a' } | { b: 'b' }\n // Any nested object will be flattened into the individual unions, e.g. { a: 'a', b: { x: 'x', y: 'y' } } -> { a: 'a' } | { 'b.x': 'x', 'b.y': 'y' }\n // We create this structure by first nesting the desired union types into the original object, and\n // then extract them by indexing with `keyof TMessages` to form the union.\n // Throughout this the objects are wrapped up in a function parameter, which allows us to have the\n // final step of flipping this unions around to an intersection by inferring the function parameter.\n {\n [TKey in keyof TMessages]: (\n _: TMessages[TKey] extends
|
|
1
|
+
{"version":3,"file":"TranslationRef.esm.js","sources":["../../../../../../../packages/frontend-plugin-api/src/translation/TranslationRef.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTranslationResource,\n TranslationResource,\n} from './TranslationResource';\n\n/** @public */\nexport interface TranslationRef<\n TId extends string = string,\n TMessages extends { [key in string]: string } = { [key in string]: string },\n> {\n $$type: '@backstage/TranslationRef';\n\n id: TId;\n\n T: TMessages;\n}\n\n/** @internal */\ntype AnyMessages = { [key in string]: string };\n\n/** @ignore */\ntype AnyNestedMessages = { [key in string]: AnyNestedMessages | string };\n\n/**\n * Flattens a nested message declaration into a flat object with dot-separated keys.\n *\n * @ignore\n */\ntype FlattenedMessages<TMessages extends AnyNestedMessages> =\n // Flatten out object keys into a union structure of objects, e.g. { a: 'a', b: 'b' } -> { a: 'a' } | { b: 'b' }\n // Any nested object will be flattened into the individual unions, e.g. { a: 'a', b: { x: 'x', y: 'y' } } -> { a: 'a' } | { 'b.x': 'x', 'b.y': 'y' }\n // We create this structure by first nesting the desired union types into the original object, and\n // then extract them by indexing with `keyof TMessages` to form the union.\n // Throughout this the objects are wrapped up in a function parameter, which allows us to have the\n // final step of flipping this unions around to an intersection by inferring the function parameter.\n {\n [TKey in keyof TMessages]: (\n _: TMessages[TKey] extends string\n ? { [_ in TKey]: TMessages[TKey] } // String values are leaf nodes, passed through with the same key\n : TMessages[TKey] extends AnyNestedMessages\n ? FlattenedMessages<TMessages[TKey]> extends infer TNested // Recurse into nested messages, \"local variable\" for the result\n ? {\n [TNestedKey in keyof TNested as `${TKey & string}.${TNestedKey &\n string}`]: TNested[TNestedKey];\n }\n : never\n : never, // Unreachable: TMessages[TKey] is always string or AnyNestedMessages\n ) => void;\n // The `[keyof TMessages]` extracts the object values union from our flattened structure, still wrapped up in function parameters.\n // The `extends (_: infer TIntersection) => void` flips the union to an intersection, at which point we have the correct type.\n }[keyof TMessages] extends (_: infer TIntersection) => void\n ? // This object mapping just expands similar to the Expand<> utility type, providing nicer type hints\n {\n readonly [TExpandKey in keyof TIntersection]: TIntersection[TExpandKey];\n }\n : never;\n\n/** @internal */\nexport interface InternalTranslationRef<\n TId extends string = string,\n TMessages extends { [key in string]: string } = { [key in string]: string },\n> extends TranslationRef<TId, TMessages> {\n version: 'v1';\n\n getDefaultMessages(): AnyMessages;\n\n getDefaultResource(): TranslationResource | undefined;\n}\n\n/** @public */\nexport interface TranslationRefOptions<\n TId extends string,\n TNestedMessages extends AnyNestedMessages,\n TTranslations extends {\n [language in string]: () => Promise<{\n default: {\n [key in keyof FlattenedMessages<TNestedMessages>]: string | null;\n };\n }>;\n },\n> {\n id: TId;\n messages: TNestedMessages;\n translations?: TTranslations;\n}\n\nfunction flattenMessages(nested: AnyNestedMessages): AnyMessages {\n const entries = new Array<[string, string]>();\n\n function visit(obj: AnyNestedMessages, prefix: string): void {\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'string') {\n entries.push([prefix + key, value]);\n } else {\n visit(value, `${prefix}${key}.`);\n }\n }\n }\n\n visit(nested, '');\n\n return Object.fromEntries(entries);\n}\n\n/** @internal */\nclass TranslationRefImpl<\n TId extends string,\n TNestedMessages extends AnyNestedMessages,\n> implements InternalTranslationRef<TId, FlattenedMessages<TNestedMessages>>\n{\n #id: TId;\n #messages: FlattenedMessages<TNestedMessages>;\n #resources: TranslationResource | undefined;\n\n constructor(options: TranslationRefOptions<TId, TNestedMessages, any>) {\n this.#id = options.id;\n this.#messages = flattenMessages(\n options.messages,\n ) as FlattenedMessages<TNestedMessages>;\n }\n\n $$type = '@backstage/TranslationRef' as const;\n\n version = 'v1' as const;\n\n get id(): TId {\n return this.#id;\n }\n\n get T(): never {\n throw new Error('Not implemented');\n }\n\n getDefaultMessages(): AnyMessages {\n return this.#messages;\n }\n\n setDefaultResource(resources: TranslationResource): void {\n this.#resources = resources;\n }\n\n getDefaultResource(): TranslationResource | undefined {\n return this.#resources;\n }\n\n toString() {\n return `TranslationRef{id=${this.id}}`;\n }\n}\n\n/** @public */\nexport function createTranslationRef<\n TId extends string,\n const TNestedMessages extends AnyNestedMessages,\n TTranslations extends {\n [language in string]: () => Promise<{\n default: {\n [key in keyof FlattenedMessages<TNestedMessages>]: string | null;\n };\n }>;\n },\n>(\n config: TranslationRefOptions<TId, TNestedMessages, TTranslations>,\n): TranslationRef<TId, FlattenedMessages<TNestedMessages>> {\n const ref = new TranslationRefImpl(config);\n if (config.translations) {\n ref.setDefaultResource(\n createTranslationResource({\n ref,\n translations: config.translations as any,\n }),\n );\n }\n return ref;\n}\n\n/** @internal */\nexport function toInternalTranslationRef<\n TId extends string,\n TMessages extends AnyMessages,\n>(ref: TranslationRef<TId, TMessages>): InternalTranslationRef<TId, TMessages> {\n const r = ref as InternalTranslationRef<TId, TMessages>;\n if (r.$$type !== '@backstage/TranslationRef') {\n throw new Error(`Invalid translation ref, bad type '${r.$$type}'`);\n }\n if (r.version !== 'v1') {\n throw new Error(`Invalid translation ref, bad version '${r.version}'`);\n }\n return r;\n}\n"],"names":[],"mappings":"AAiMO,SAAS,yBAGd,GAAA,EAA6E;AAC7E,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,IAAI,CAAA,CAAE,WAAW,2BAAA,EAA6B;AAC5C,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mCAAA,EAAsC,CAAA,CAAE,MAAM,CAAA,CAAA,CAAG,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,CAAA,CAAE,YAAY,IAAA,EAAM;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,sCAAA,EAAyC,CAAA,CAAE,OAAO,CAAA,CAAA,CAAG,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,CAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-app",
|
|
3
|
-
"version": "0.4.3-next.
|
|
3
|
+
"version": "0.4.3-next.2",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "frontend-plugin",
|
|
6
6
|
"pluginId": "app",
|
|
@@ -63,16 +63,16 @@
|
|
|
63
63
|
"test": "backstage-cli package test"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@backstage/core-components": "0.18.9-next.
|
|
67
|
-
"@backstage/core-plugin-api": "1.12.5-next.
|
|
68
|
-
"@backstage/filter-predicates": "0.1.
|
|
69
|
-
"@backstage/frontend-plugin-api": "0.
|
|
70
|
-
"@backstage/integration-react": "1.2.17-next.
|
|
71
|
-
"@backstage/plugin-app-react": "0.2.2-next.
|
|
72
|
-
"@backstage/plugin-permission-react": "0.4.42-next.
|
|
73
|
-
"@backstage/theme": "0.7.
|
|
66
|
+
"@backstage/core-components": "0.18.9-next.1",
|
|
67
|
+
"@backstage/core-plugin-api": "1.12.5-next.2",
|
|
68
|
+
"@backstage/filter-predicates": "0.1.2-next.0",
|
|
69
|
+
"@backstage/frontend-plugin-api": "0.16.0-next.2",
|
|
70
|
+
"@backstage/integration-react": "1.2.17-next.1",
|
|
71
|
+
"@backstage/plugin-app-react": "0.2.2-next.1",
|
|
72
|
+
"@backstage/plugin-permission-react": "0.4.42-next.1",
|
|
73
|
+
"@backstage/theme": "0.7.3-next.0",
|
|
74
74
|
"@backstage/types": "1.2.2",
|
|
75
|
-
"@backstage/ui": "0.14.0-next.
|
|
75
|
+
"@backstage/ui": "0.14.0-next.2",
|
|
76
76
|
"@backstage/version-bridge": "1.0.12",
|
|
77
77
|
"@material-ui/core": "^4.9.13",
|
|
78
78
|
"@material-ui/icons": "^4.9.1",
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
"zod": "^3.25.76 || ^4.0.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@backstage/cli": "0.36.1-next.
|
|
92
|
-
"@backstage/dev-utils": "1.1.22-next.
|
|
93
|
-
"@backstage/frontend-defaults": "0.5.1-next.
|
|
94
|
-
"@backstage/frontend-test-utils": "0.5.2-next.
|
|
95
|
-
"@backstage/test-utils": "1.7.17-next.
|
|
91
|
+
"@backstage/cli": "0.36.1-next.2",
|
|
92
|
+
"@backstage/dev-utils": "1.1.22-next.2",
|
|
93
|
+
"@backstage/frontend-defaults": "0.5.1-next.2",
|
|
94
|
+
"@backstage/frontend-test-utils": "0.5.2-next.2",
|
|
95
|
+
"@backstage/test-utils": "1.7.17-next.2",
|
|
96
96
|
"@testing-library/jest-dom": "^6.0.0",
|
|
97
97
|
"@testing-library/react": "^16.0.0",
|
|
98
98
|
"@testing-library/user-event": "^14.0.0",
|