@backstage/core-app-api 0.4.0 → 0.5.0-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 +12 -0
- package/dist/index.d.ts +9 -30
- package/dist/index.esm.js +20 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/core-app-api
|
|
2
2
|
|
|
3
|
+
## 0.5.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ceebe25391: Removed deprecated `SignInResult` type, which was replaced with the new `onSignInSuccess` callback.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/core-plugin-api@0.6.0-next.0
|
|
13
|
+
- @backstage/config@0.1.13-next.0
|
|
14
|
+
|
|
3
15
|
## 0.4.0
|
|
4
16
|
|
|
5
17
|
### 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, ProfileInfo,
|
|
3
|
+
import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, ProfileInfo, BackstageIdentityResponse, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, OAuthApi, SessionApi, SessionState, AuthRequestOptions, gitlabAuthApiRef, googleAuthApiRef, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, oktaAuthApiRef, auth0AuthApiRef, 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';
|
|
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';
|
|
@@ -104,7 +104,7 @@ declare type GithubSession = {
|
|
|
104
104
|
expiresAt?: Date;
|
|
105
105
|
};
|
|
106
106
|
profile: ProfileInfo;
|
|
107
|
-
backstageIdentity:
|
|
107
|
+
backstageIdentity: BackstageIdentityResponse;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
/**
|
|
@@ -138,7 +138,7 @@ declare class GithubAuth implements OAuthApi, SessionApi {
|
|
|
138
138
|
signOut(): Promise<void>;
|
|
139
139
|
sessionState$(): Observable<SessionState>;
|
|
140
140
|
getAccessToken(scope?: string, options?: AuthRequestOptions): Promise<string>;
|
|
141
|
-
getBackstageIdentity(options?: AuthRequestOptions): Promise<
|
|
141
|
+
getBackstageIdentity(options?: AuthRequestOptions): Promise<BackstageIdentityResponse | undefined>;
|
|
142
142
|
getProfile(options?: AuthRequestOptions): Promise<ProfileInfo | undefined>;
|
|
143
143
|
static normalizeScope(scope?: string): Set<string>;
|
|
144
144
|
}
|
|
@@ -183,7 +183,7 @@ declare class OAuth2 implements OAuthApi, OpenIdConnectApi, ProfileInfoApi, Back
|
|
|
183
183
|
sessionState$(): Observable<SessionState>;
|
|
184
184
|
getAccessToken(scope?: string | string[], options?: AuthRequestOptions): Promise<string>;
|
|
185
185
|
getIdToken(options?: AuthRequestOptions): Promise<string>;
|
|
186
|
-
getBackstageIdentity(options?: AuthRequestOptions): Promise<
|
|
186
|
+
getBackstageIdentity(options?: AuthRequestOptions): Promise<BackstageIdentityResponse | undefined>;
|
|
187
187
|
getProfile(options?: AuthRequestOptions): Promise<ProfileInfo | undefined>;
|
|
188
188
|
private static normalizeScopes;
|
|
189
189
|
}
|
|
@@ -201,7 +201,7 @@ declare type OAuth2Session = {
|
|
|
201
201
|
expiresAt: Date;
|
|
202
202
|
};
|
|
203
203
|
profile: ProfileInfo;
|
|
204
|
-
backstageIdentity:
|
|
204
|
+
backstageIdentity: BackstageIdentityResponse;
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
/**
|
|
@@ -225,7 +225,7 @@ declare class SamlAuth implements ProfileInfoApi, BackstageIdentityApi, SessionA
|
|
|
225
225
|
private constructor();
|
|
226
226
|
signIn(): Promise<void>;
|
|
227
227
|
signOut(): Promise<void>;
|
|
228
|
-
getBackstageIdentity(options?: AuthRequestOptions): Promise<
|
|
228
|
+
getBackstageIdentity(options?: AuthRequestOptions): Promise<BackstageIdentityResponse | undefined>;
|
|
229
229
|
getProfile(options?: AuthRequestOptions): Promise<ProfileInfo | undefined>;
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -238,7 +238,7 @@ declare class SamlAuth implements ProfileInfoApi, BackstageIdentityApi, SessionA
|
|
|
238
238
|
declare type ExportedSamlSession = {
|
|
239
239
|
userId: string;
|
|
240
240
|
profile: ProfileInfo;
|
|
241
|
-
backstageIdentity:
|
|
241
|
+
backstageIdentity: BackstageIdentityResponse;
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
/**
|
|
@@ -307,7 +307,7 @@ declare type BitbucketSession = {
|
|
|
307
307
|
expiresAt?: Date;
|
|
308
308
|
};
|
|
309
309
|
profile: ProfileInfo;
|
|
310
|
-
backstageIdentity:
|
|
310
|
+
backstageIdentity: BackstageIdentityResponse;
|
|
311
311
|
};
|
|
312
312
|
|
|
313
313
|
/**
|
|
@@ -578,27 +578,6 @@ declare type BootErrorPageProps = {
|
|
|
578
578
|
step: 'load-config' | 'load-chunk';
|
|
579
579
|
error: Error;
|
|
580
580
|
};
|
|
581
|
-
/**
|
|
582
|
-
* The outcome of signing in on the sign-in page.
|
|
583
|
-
*
|
|
584
|
-
* @public
|
|
585
|
-
* @deprecated replaced by passing the {@link @backstage/core-plugin-api#IdentityApi} to the {@link SignInPageProps.onSignInSuccess} instead.
|
|
586
|
-
*/
|
|
587
|
-
declare type SignInResult = {
|
|
588
|
-
/**
|
|
589
|
-
* User ID that will be returned by the IdentityApi
|
|
590
|
-
*/
|
|
591
|
-
userId: string;
|
|
592
|
-
profile: ProfileInfo;
|
|
593
|
-
/**
|
|
594
|
-
* Function used to retrieve an ID token for the signed in user.
|
|
595
|
-
*/
|
|
596
|
-
getIdToken?: () => Promise<string>;
|
|
597
|
-
/**
|
|
598
|
-
* Sign out handler that will be called if the user requests to sign out.
|
|
599
|
-
*/
|
|
600
|
-
signOut?: () => Promise<void>;
|
|
601
|
-
};
|
|
602
581
|
/**
|
|
603
582
|
* Props for the `SignInPage` component of {@link AppComponents}.
|
|
604
583
|
*
|
|
@@ -937,4 +916,4 @@ declare type FeatureFlaggedProps = {
|
|
|
937
916
|
*/
|
|
938
917
|
declare const FeatureFlagged: (props: FeatureFlaggedProps) => JSX.Element;
|
|
939
918
|
|
|
940
|
-
export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppThemeSelector, AtlassianAuth, Auth0Auth, AuthApiCreateOptions, BackstageApp, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FetchMiddleware, FetchMiddlewares, FlatRoutes, FlatRoutesProps, GithubAuth, GithubSession, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, ExportedSamlSession as SamlSession, SignInPageProps,
|
|
919
|
+
export { AlertApiForwarder, ApiFactoryHolder, ApiFactoryRegistry, ApiFactoryScope, ApiProvider, ApiProviderProps, ApiResolver, AppComponents, AppConfigLoader, AppContext, AppIcons, AppOptions, AppRouteBinder, AppThemeSelector, AtlassianAuth, Auth0Auth, AuthApiCreateOptions, BackstageApp, BitbucketAuth, BitbucketSession, BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, ErrorBoundaryFallbackProps, FeatureFlagged, FeatureFlaggedProps, FetchMiddleware, FetchMiddlewares, FlatRoutes, FlatRoutesProps, GithubAuth, GithubSession, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, NoOpAnalyticsApi, OAuth2, OAuth2CreateOptions, OAuth2Session, OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, OneLoginAuthCreateOptions, SamlAuth, ExportedSamlSession as SamlSession, SignInPageProps, UnhandledErrorForwarder, UrlPatternDiscovery, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
|
package/dist/index.esm.js
CHANGED
|
@@ -2183,6 +2183,9 @@ const AppContextProvider = ({
|
|
|
2183
2183
|
function mkError(thing) {
|
|
2184
2184
|
return new Error(`Tried to access IdentityApi ${thing} before app was loaded`);
|
|
2185
2185
|
}
|
|
2186
|
+
function logDeprecation(thing) {
|
|
2187
|
+
console.warn(`WARNING: Call to ${thing} is deprecated and will break in the future`);
|
|
2188
|
+
}
|
|
2186
2189
|
class AppIdentityProxy {
|
|
2187
2190
|
setTarget(identityApi) {
|
|
2188
2191
|
this.target = identityApi;
|
|
@@ -2191,12 +2194,20 @@ class AppIdentityProxy {
|
|
|
2191
2194
|
if (!this.target) {
|
|
2192
2195
|
throw mkError("getUserId");
|
|
2193
2196
|
}
|
|
2197
|
+
if (!this.target.getUserId) {
|
|
2198
|
+
throw new Error("IdentityApi does not implement getUserId");
|
|
2199
|
+
}
|
|
2200
|
+
logDeprecation("getUserId");
|
|
2194
2201
|
return this.target.getUserId();
|
|
2195
2202
|
}
|
|
2196
2203
|
getProfile() {
|
|
2197
2204
|
if (!this.target) {
|
|
2198
2205
|
throw mkError("getProfile");
|
|
2199
2206
|
}
|
|
2207
|
+
if (!this.target.getProfile) {
|
|
2208
|
+
throw new Error("IdentityApi does not implement getProfile");
|
|
2209
|
+
}
|
|
2210
|
+
logDeprecation("getProfile");
|
|
2200
2211
|
return this.target.getProfile();
|
|
2201
2212
|
}
|
|
2202
2213
|
async getProfileInfo() {
|
|
@@ -2209,7 +2220,11 @@ class AppIdentityProxy {
|
|
|
2209
2220
|
if (!this.target) {
|
|
2210
2221
|
throw mkError("getBackstageIdentity");
|
|
2211
2222
|
}
|
|
2212
|
-
|
|
2223
|
+
const identity = await this.target.getBackstageIdentity();
|
|
2224
|
+
if (!identity.userEntityRef.match(/^.*:.*\/.*$/)) {
|
|
2225
|
+
console.warn(`WARNING: The App IdentityApi provided an invalid userEntityRef, '${identity.userEntityRef}'. It must be a full Entity Reference of the form '<kind>:<namespace>/<name>'.`);
|
|
2226
|
+
}
|
|
2227
|
+
return identity;
|
|
2213
2228
|
}
|
|
2214
2229
|
async getCredentials() {
|
|
2215
2230
|
if (!this.target) {
|
|
@@ -2221,6 +2236,10 @@ class AppIdentityProxy {
|
|
|
2221
2236
|
if (!this.target) {
|
|
2222
2237
|
throw mkError("getIdToken");
|
|
2223
2238
|
}
|
|
2239
|
+
if (!this.target.getIdToken) {
|
|
2240
|
+
throw new Error("IdentityApi does not implement getIdToken");
|
|
2241
|
+
}
|
|
2242
|
+
logDeprecation("getIdToken");
|
|
2224
2243
|
return this.target.getIdToken();
|
|
2225
2244
|
}
|
|
2226
2245
|
async signOut() {
|