@backstage/core-app-api 1.4.0 → 1.5.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,31 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - db10b6ef65: Added a Bitbucket Server Auth Provider and added its API to the app defaults
8
+
9
+ ### Patch Changes
10
+
11
+ - dff4d8ddb1: Fixed an issue where an explicit port the frontend base URL could break the app.
12
+ - Updated dependencies
13
+ - @backstage/core-plugin-api@1.4.0
14
+ - @backstage/config@1.0.6
15
+ - @backstage/types@1.0.2
16
+ - @backstage/version-bridge@1.0.3
17
+
18
+ ## 1.4.1-next.0
19
+
20
+ ### Patch Changes
21
+
22
+ - dff4d8ddb1: Fixed an issue where an explicit port the frontend base URL could break the app.
23
+ - Updated dependencies
24
+ - @backstage/config@1.0.6
25
+ - @backstage/core-plugin-api@1.3.0
26
+ - @backstage/types@1.0.2
27
+ - @backstage/version-bridge@1.0.3
28
+
3
29
  ## 1.4.0
4
30
 
5
31
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, PropsWithChildren, ComponentType } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, OAuthApi, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, SessionApi, SessionState, AuthRequestOptions, BackstageIdentityResponse, ProfileInfo, oktaAuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
3
+ import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, OAuthApi, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, SessionApi, SessionState, AuthRequestOptions, BackstageIdentityResponse, ProfileInfo, oktaAuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, atlassianAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
4
4
  import * as _backstage_types from '@backstage/types';
5
5
  import { Observable, JsonValue } from '@backstage/types';
6
6
  import { Config, AppConfig } from '@backstage/config';
@@ -256,6 +256,29 @@ declare class BitbucketAuth {
256
256
  static create(options: OAuthApiCreateOptions): typeof bitbucketAuthApiRef.T;
257
257
  }
258
258
 
259
+ /**
260
+ * Session information for Bitbucket Server auth.
261
+ *
262
+ * @public
263
+ */
264
+ declare type BitbucketServerSession = {
265
+ providerInfo: {
266
+ accessToken: string;
267
+ scopes: Set<string>;
268
+ expiresAt?: Date;
269
+ };
270
+ profile: ProfileInfo;
271
+ backstageIdentity: BackstageIdentityResponse;
272
+ };
273
+
274
+ /**
275
+ * Implements the OAuth flow to Bitbucket Server.
276
+ * @public
277
+ */
278
+ declare class BitbucketServerAuth {
279
+ static create(options: OAuthApiCreateOptions): typeof bitbucketServerAuthApiRef.T;
280
+ }
281
+
259
282
  /**
260
283
  * Implements the OAuth flow to Atlassian products.
261
284
  *
@@ -959,4 +982,4 @@ declare type FeatureFlaggedProps = {
959
982
  */
960
983
  declare const FeatureFlagged: (props: FeatureFlaggedProps) => JSX.Element;
961
984
 
962
- export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppRouter, AppRouterProps, AppThemeSelector, AtlassianAuth, AuthApiCreateOptions, BackstageApp, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FetchMiddleware, FetchMiddlewares, FlatRoutes, FlatRoutesProps, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, MultipleAnalyticsApi, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, SignInPageProps, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
985
+ export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppRouter, AppRouterProps, AppThemeSelector, AtlassianAuth, AuthApiCreateOptions, BackstageApp, BitbucketAuth, BitbucketServerAuth, BitbucketServerSession, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FetchMiddleware, FetchMiddlewares, FlatRoutes, FlatRoutesProps, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, MultipleAnalyticsApi, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, SignInPageProps, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
package/dist/index.esm.js CHANGED
@@ -767,7 +767,7 @@ class AuthSessionStore {
767
767
  }
768
768
  }
769
769
 
770
- const DEFAULT_PROVIDER$9 = {
770
+ const DEFAULT_PROVIDER$a = {
771
771
  id: "oauth2",
772
772
  title: "Your Identity Provider",
773
773
  icon: () => null
@@ -777,7 +777,7 @@ class OAuth2 {
777
777
  const {
778
778
  discoveryApi,
779
779
  environment = "development",
780
- provider = DEFAULT_PROVIDER$9,
780
+ provider = DEFAULT_PROVIDER$a,
781
781
  oauthRequestApi,
782
782
  defaultScopes = [],
783
783
  scopeTransform = (x) => x
@@ -859,7 +859,7 @@ class OAuth2 {
859
859
  }
860
860
  }
861
861
 
862
- const DEFAULT_PROVIDER$8 = {
862
+ const DEFAULT_PROVIDER$9 = {
863
863
  id: "github",
864
864
  title: "GitHub",
865
865
  icon: () => null
@@ -869,7 +869,7 @@ class GithubAuth {
869
869
  const {
870
870
  discoveryApi,
871
871
  environment = "development",
872
- provider = DEFAULT_PROVIDER$8,
872
+ provider = DEFAULT_PROVIDER$9,
873
873
  oauthRequestApi,
874
874
  defaultScopes = ["read:user"]
875
875
  } = options;
@@ -883,7 +883,7 @@ class GithubAuth {
883
883
  }
884
884
  }
885
885
 
886
- const DEFAULT_PROVIDER$7 = {
886
+ const DEFAULT_PROVIDER$8 = {
887
887
  id: "gitlab",
888
888
  title: "GitLab",
889
889
  icon: () => null
@@ -893,7 +893,7 @@ class GitlabAuth {
893
893
  const {
894
894
  discoveryApi,
895
895
  environment = "development",
896
- provider = DEFAULT_PROVIDER$7,
896
+ provider = DEFAULT_PROVIDER$8,
897
897
  oauthRequestApi,
898
898
  defaultScopes = ["read_user"]
899
899
  } = options;
@@ -907,7 +907,7 @@ class GitlabAuth {
907
907
  }
908
908
  }
909
909
 
910
- const DEFAULT_PROVIDER$6 = {
910
+ const DEFAULT_PROVIDER$7 = {
911
911
  id: "google",
912
912
  title: "Google",
913
913
  icon: () => null
@@ -919,7 +919,7 @@ class GoogleAuth {
919
919
  discoveryApi,
920
920
  oauthRequestApi,
921
921
  environment = "development",
922
- provider = DEFAULT_PROVIDER$6,
922
+ provider = DEFAULT_PROVIDER$7,
923
923
  defaultScopes = [
924
924
  "openid",
925
925
  `${SCOPE_PREFIX$1}userinfo.email`,
@@ -950,7 +950,7 @@ class GoogleAuth {
950
950
  }
951
951
  }
952
952
 
953
- const DEFAULT_PROVIDER$5 = {
953
+ const DEFAULT_PROVIDER$6 = {
954
954
  id: "okta",
955
955
  title: "Okta",
956
956
  icon: () => null
@@ -970,7 +970,7 @@ class OktaAuth {
970
970
  const {
971
971
  discoveryApi,
972
972
  environment = "development",
973
- provider = DEFAULT_PROVIDER$5,
973
+ provider = DEFAULT_PROVIDER$6,
974
974
  oauthRequestApi,
975
975
  defaultScopes = ["openid", "email", "profile", "offline_access"]
976
976
  } = options;
@@ -1011,7 +1011,7 @@ const samlSessionSchema = z.object({
1011
1011
  })
1012
1012
  });
1013
1013
 
1014
- const DEFAULT_PROVIDER$4 = {
1014
+ const DEFAULT_PROVIDER$5 = {
1015
1015
  id: "saml",
1016
1016
  title: "SAML",
1017
1017
  icon: () => null
@@ -1024,7 +1024,7 @@ class SamlAuth {
1024
1024
  const {
1025
1025
  discoveryApi,
1026
1026
  environment = "development",
1027
- provider = DEFAULT_PROVIDER$4
1027
+ provider = DEFAULT_PROVIDER$5
1028
1028
  } = options;
1029
1029
  const connector = new DirectAuthConnector({
1030
1030
  discoveryApi,
@@ -1060,7 +1060,7 @@ class SamlAuth {
1060
1060
  }
1061
1061
  }
1062
1062
 
1063
- const DEFAULT_PROVIDER$3 = {
1063
+ const DEFAULT_PROVIDER$4 = {
1064
1064
  id: "microsoft",
1065
1065
  title: "Microsoft",
1066
1066
  icon: () => null
@@ -1069,7 +1069,7 @@ class MicrosoftAuth {
1069
1069
  static create(options) {
1070
1070
  const {
1071
1071
  environment = "development",
1072
- provider = DEFAULT_PROVIDER$3,
1072
+ provider = DEFAULT_PROVIDER$4,
1073
1073
  oauthRequestApi,
1074
1074
  discoveryApi,
1075
1075
  defaultScopes = [
@@ -1090,7 +1090,7 @@ class MicrosoftAuth {
1090
1090
  }
1091
1091
  }
1092
1092
 
1093
- const DEFAULT_PROVIDER$2 = {
1093
+ const DEFAULT_PROVIDER$3 = {
1094
1094
  id: "onelogin",
1095
1095
  title: "onelogin",
1096
1096
  icon: () => null
@@ -1110,7 +1110,7 @@ class OneLoginAuth {
1110
1110
  const {
1111
1111
  discoveryApi,
1112
1112
  environment = "development",
1113
- provider = DEFAULT_PROVIDER$2,
1113
+ provider = DEFAULT_PROVIDER$3,
1114
1114
  oauthRequestApi
1115
1115
  } = options;
1116
1116
  return OAuth2.create({
@@ -1134,7 +1134,7 @@ class OneLoginAuth {
1134
1134
  }
1135
1135
  }
1136
1136
 
1137
- const DEFAULT_PROVIDER$1 = {
1137
+ const DEFAULT_PROVIDER$2 = {
1138
1138
  id: "bitbucket",
1139
1139
  title: "Bitbucket",
1140
1140
  icon: () => null
@@ -1144,7 +1144,7 @@ class BitbucketAuth {
1144
1144
  const {
1145
1145
  discoveryApi,
1146
1146
  environment = "development",
1147
- provider = DEFAULT_PROVIDER$1,
1147
+ provider = DEFAULT_PROVIDER$2,
1148
1148
  oauthRequestApi,
1149
1149
  defaultScopes = ["team"]
1150
1150
  } = options;
@@ -1158,6 +1158,30 @@ class BitbucketAuth {
1158
1158
  }
1159
1159
  }
1160
1160
 
1161
+ const DEFAULT_PROVIDER$1 = {
1162
+ id: "bitbucketServer",
1163
+ title: "Bitbucket Server",
1164
+ icon: () => null
1165
+ };
1166
+ class BitbucketServerAuth {
1167
+ static create(options) {
1168
+ const {
1169
+ discoveryApi,
1170
+ environment = "development",
1171
+ provider = DEFAULT_PROVIDER$1,
1172
+ oauthRequestApi,
1173
+ defaultScopes = ["PROJECT_ADMIN"]
1174
+ } = options;
1175
+ return OAuth2.create({
1176
+ discoveryApi,
1177
+ oauthRequestApi,
1178
+ provider,
1179
+ environment,
1180
+ defaultScopes
1181
+ });
1182
+ }
1183
+ }
1184
+
1161
1185
  const DEFAULT_PROVIDER = {
1162
1186
  id: "atlassian",
1163
1187
  title: "Atlassian",
@@ -2727,6 +2751,13 @@ var __privateSet = (obj, member, value, setter) => {
2727
2751
  return value;
2728
2752
  };
2729
2753
  var _getProviderCalled;
2754
+ function createLocalBaseUrl(fullUrl) {
2755
+ const url = new URL(fullUrl);
2756
+ url.protocol = document.location.protocol;
2757
+ url.hostname = document.location.hostname;
2758
+ url.port = document.location.port;
2759
+ return url.toString().replace(/\/$/, "");
2760
+ }
2730
2761
  function useConfigLoader(configLoader, components, appThemeApi) {
2731
2762
  var _a;
2732
2763
  const hasConfig = Boolean(configLoader);
@@ -2748,13 +2779,6 @@ function useConfigLoader(configLoader, components, appThemeApi) {
2748
2779
  let configReader;
2749
2780
  if ((_a = config.value) == null ? void 0 : _a.length) {
2750
2781
  const urlConfigReader = ConfigReader.fromConfigs(config.value);
2751
- const getOrigin = (url) => new URL(url).origin;
2752
- const overrideOrigin = (fullUrl) => {
2753
- return new URL(
2754
- fullUrl.replace(getOrigin(fullUrl), ""),
2755
- document.location.origin
2756
- ).href.replace(/\/$/, "");
2757
- };
2758
2782
  const appBaseUrl = urlConfigReader.getOptionalString("app.baseUrl");
2759
2783
  const backendBaseUrl = urlConfigReader.getOptionalString("backend.baseUrl");
2760
2784
  let configs = config.value;
@@ -2763,17 +2787,17 @@ function useConfigLoader(configLoader, components, appThemeApi) {
2763
2787
  context: "relative-resolver"
2764
2788
  };
2765
2789
  if (appBaseUrl && backendBaseUrl) {
2766
- const appOrigin = getOrigin(appBaseUrl);
2767
- const backendOrigin = getOrigin(backendBaseUrl);
2790
+ const appOrigin = new URL(appBaseUrl).origin;
2791
+ const backendOrigin = new URL(backendBaseUrl).origin;
2768
2792
  if (appOrigin === backendOrigin) {
2769
- const newBackendBaseUrl = overrideOrigin(backendBaseUrl);
2793
+ const newBackendBaseUrl = createLocalBaseUrl(backendBaseUrl);
2770
2794
  if (backendBaseUrl !== newBackendBaseUrl) {
2771
2795
  relativeResolverConfig.data.backend = { baseUrl: newBackendBaseUrl };
2772
2796
  }
2773
2797
  }
2774
2798
  }
2775
2799
  if (appBaseUrl) {
2776
- const newAppBaseUrl = overrideOrigin(appBaseUrl);
2800
+ const newAppBaseUrl = createLocalBaseUrl(appBaseUrl);
2777
2801
  if (appBaseUrl !== newAppBaseUrl) {
2778
2802
  relativeResolverConfig.data.app = { baseUrl: newAppBaseUrl };
2779
2803
  }
@@ -3095,5 +3119,5 @@ const FlatRoutes = (props) => {
3095
3119
  return useRoutes(withNotFound);
3096
3120
  };
3097
3121
 
3098
- export { AlertApiForwarder, ApiFactoryRegistry, ApiProvider, ApiResolver, AppRouter, AppThemeSelector, AtlassianAuth, BitbucketAuth, ErrorAlerter, ErrorApiForwarder, FeatureFlagged, FetchMiddlewares, FlatRoutes, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, MultipleAnalyticsApi, NoOpAnalyticsApi, OAuth2, OAuthRequestManager, OktaAuth, OneLoginAuth, SamlAuth, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
3122
+ export { AlertApiForwarder, ApiFactoryRegistry, ApiProvider, ApiResolver, AppRouter, AppThemeSelector, AtlassianAuth, BitbucketAuth, BitbucketServerAuth, ErrorAlerter, ErrorApiForwarder, FeatureFlagged, FetchMiddlewares, FlatRoutes, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, MultipleAnalyticsApi, NoOpAnalyticsApi, OAuth2, OAuthRequestManager, OktaAuth, OneLoginAuth, SamlAuth, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
3099
3123
  //# sourceMappingURL=index.esm.js.map