unexport OAuth2Response

Signed-off-by: Gasan.Guseinov <465806+gusega@users.noreply.github.com>
This commit is contained in:
Gasan.Guseinov
2025-03-25 17:11:23 +01:00
parent 75e0c40abb
commit 50e2d6fb6c
4 changed files with 39 additions and 38 deletions
-17
View File
@@ -21,7 +21,6 @@ import { AuthRequestOptions } from '@backstage/core-plugin-api';
import { BackstageIdentityApi } from '@backstage/core-plugin-api';
import { BackstageIdentityResponse } from '@backstage/core-plugin-api';
import { BackstagePlugin } from '@backstage/core-plugin-api';
import { BackstageUserIdentity } from '@backstage/core-plugin-api';
import { bitbucketAuthApiRef } from '@backstage/core-plugin-api';
import { bitbucketServerAuthApiRef } from '@backstage/core-plugin-api';
import { ComponentType } from 'react';
@@ -592,22 +591,6 @@ export type OAuth2CreateOptionsWithAuthConnector = {
authConnector: AuthConnector<OAuth2Session>;
};
// @public (undocumented)
export type OAuth2Response = {
providerInfo: {
accessToken: string;
idToken: string;
scope: string;
expiresInSeconds?: number;
};
profile: ProfileInfo;
backstageIdentity: {
token: string;
expiresInSeconds?: number;
identity: BackstageUserIdentity;
};
};
// @public
export type OAuth2Session = {
providerInfo: {
@@ -21,8 +21,10 @@ import {
AuthRequestOptions,
BackstageIdentityApi,
BackstageIdentityResponse,
BackstageUserIdentity,
OAuthApi,
OpenIdConnectApi,
ProfileInfo,
ProfileInfoApi,
SessionApi,
SessionState,
@@ -31,7 +33,6 @@ import { Observable } from '@backstage/types';
import {
OAuth2CreateOptions,
OAuth2CreateOptionsWithAuthConnector,
OAuth2Response,
OAuth2Session,
} from './types';
@@ -41,6 +42,21 @@ const DEFAULT_PROVIDER = {
icon: () => null,
};
export type OAuth2Response = {
providerInfo: {
accessToken: string;
idToken: string;
scope: string;
expiresInSeconds?: number;
};
profile: ProfileInfo;
backstageIdentity: {
token: string;
expiresInSeconds?: number;
identity: BackstageUserIdentity;
};
};
/**
* Implements a generic OAuth2 flow for auth.
*
@@ -21,9 +21,9 @@ import {
AuthConnectorRefreshSessionOptions,
openLoginPopup,
OAuth2CreateOptionsWithAuthConnector,
OAuth2Response,
} from '../../../../index';
import { waitFor } from '@testing-library/react';
import { BackstageUserIdentity, ProfileInfo } from '@backstage/core-plugin-api';
const scopeTransform = (x: string[]) => x;
@@ -34,6 +34,27 @@ type Options = {
sessionTransform?(response: any): OAuth2Session | Promise<OAuth2Session>;
};
/**
* A replica of private `OAuth2Response` from OAuth2.ts.
* `OAuth2Response` represents raw OAuth2 response from the `auth-backend` plugin.
* If custom auth connector calls `auth-backend` plugin, it will have to transform `OAuth2Response` into
* `OAuth2Session`.
*/
type OAuth2Response = {
providerInfo: {
accessToken: string;
idToken: string;
scope: string;
expiresInSeconds?: number;
};
profile: ProfileInfo;
backstageIdentity: {
token: string;
expiresInSeconds?: number;
identity: BackstageUserIdentity;
};
};
class CustomAuthConnector implements AuthConnector<OAuth2Session> {
private readonly sessionTransform: (response: any) => Promise<OAuth2Session>;
@@ -16,7 +16,6 @@
import {
BackstageIdentityResponse,
BackstageUserIdentity,
ProfileInfo,
} from '@backstage/core-plugin-api';
import { OAuthApiCreateOptions } from '../types.ts';
@@ -39,24 +38,6 @@ export type OAuth2Session = {
backstageIdentity?: BackstageIdentityResponse;
};
/**
* @public
*/
export type OAuth2Response = {
providerInfo: {
accessToken: string;
idToken: string;
scope: string;
expiresInSeconds?: number;
};
profile: ProfileInfo;
backstageIdentity: {
token: string;
expiresInSeconds?: number;
identity: BackstageUserIdentity;
};
};
/**
* OAuth2 create options.
* @public