@backstage/core-app-api 1.0.2 → 1.0.4-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 1.0.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 8fe2357101: The `signOut` method of the `IdentityApi` will now navigate the user back to the base URL of the app as indicated by the `app.baseUrl` config.
8
+
9
+ ## 1.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 8f7b1835df: Updated dependency `msw` to `^0.41.0`.
14
+ - 19781483a2: Handle URLs as the first argument to `fetchApi`, when using the `plugin:` protocol
15
+ - Updated dependencies
16
+ - @backstage/core-plugin-api@1.0.3
17
+
18
+ ## 1.0.3-next.0
19
+
20
+ ### Patch Changes
21
+
22
+ - 8f7b1835df: Updated dependency `msw` to `^0.41.0`.
23
+ - Updated dependencies
24
+ - @backstage/core-plugin-api@1.0.3-next.0
25
+
3
26
  ## 1.0.2
4
27
 
5
28
  ### Patch Changes
package/dist/index.esm.js CHANGED
@@ -1401,10 +1401,13 @@ class PluginProtocolResolverFetchMiddleware {
1401
1401
  base = `${baseUrl.protocol}//${authority}${baseUrl.host}${baseUrl.pathname}`;
1402
1402
  }
1403
1403
  const target = `${join(base, pathname)}${search}${hash}`;
1404
- return next(target, typeof input === "string" ? init : input);
1404
+ return next(target, typeof input === "string" || isUrl(input) ? init : input);
1405
1405
  };
1406
1406
  }
1407
1407
  }
1408
+ function isUrl(a) {
1409
+ return typeof a === "object" && (a == null ? void 0 : a.constructor) === URL;
1410
+ }
1408
1411
 
1409
1412
  class FetchMiddlewares {
1410
1413
  static resolvePluginProtocol(options) {
@@ -2028,12 +2031,14 @@ class AppIdentityProxy {
2028
2031
  constructor() {
2029
2032
  this.resolveTarget = () => {
2030
2033
  };
2034
+ this.signOutTargetUrl = "/";
2031
2035
  this.waitForTarget = new Promise((resolve) => {
2032
2036
  this.resolveTarget = resolve;
2033
2037
  });
2034
2038
  }
2035
- setTarget(identityApi) {
2039
+ setTarget(identityApi, targetOptions) {
2036
2040
  this.target = identityApi;
2041
+ this.signOutTargetUrl = targetOptions.signOutTargetUrl;
2037
2042
  this.resolveTarget(identityApi);
2038
2043
  }
2039
2044
  getUserId() {
@@ -2080,7 +2085,7 @@ class AppIdentityProxy {
2080
2085
  }
2081
2086
  async signOut() {
2082
2087
  await this.waitForTarget.then((target) => target.signOut());
2083
- location.reload();
2088
+ location.href = this.signOutTargetUrl;
2084
2089
  }
2085
2090
  }
2086
2091
 
@@ -2374,17 +2379,22 @@ class AppManager {
2374
2379
  children
2375
2380
  }) => {
2376
2381
  const [identityApi, setIdentityApi] = useState();
2382
+ const configApi = useApi(configApiRef);
2383
+ const basePath = getBasePath(configApi);
2377
2384
  if (!identityApi) {
2378
2385
  return /* @__PURE__ */ React.createElement(Component, {
2379
2386
  onSignInSuccess: setIdentityApi
2380
2387
  });
2381
2388
  }
2382
- this.appIdentityProxy.setTarget(identityApi);
2389
+ this.appIdentityProxy.setTarget(identityApi, {
2390
+ signOutTargetUrl: basePath || "/"
2391
+ });
2383
2392
  return children;
2384
2393
  };
2385
2394
  const AppRouter = ({ children }) => {
2386
2395
  const configApi = useApi(configApiRef);
2387
- const mountPath = `${getBasePath(configApi)}/*`;
2396
+ const basePath = getBasePath(configApi);
2397
+ const mountPath = `${basePath}/*`;
2388
2398
  const { routeObjects } = useContext(InternalAppContext);
2389
2399
  if (!SignInPageComponent) {
2390
2400
  this.appIdentityProxy.setTarget({
@@ -2406,7 +2416,7 @@ class AppManager {
2406
2416
  getCredentials: async () => ({}),
2407
2417
  signOut: async () => {
2408
2418
  }
2409
- });
2419
+ }, { signOutTargetUrl: basePath || "/" });
2410
2420
  return /* @__PURE__ */ React.createElement(RouterComponent, null, /* @__PURE__ */ React.createElement(RouteTracker, {
2411
2421
  routeObjects
2412
2422
  }), /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {