core-plugin-api: Require OAuth provider id
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/core-plugin-api': minor
|
||||
---
|
||||
|
||||
**BREAKING**: OAuth provider id is now required when passing a provider to `createAuthRequester`.
|
||||
@@ -23,13 +23,13 @@ describe('MockOAuthApi', () => {
|
||||
|
||||
const authHandler1 = jest.fn().mockImplementation(() => authResult);
|
||||
const requester1 = mock.createAuthRequester({
|
||||
provider: { icon: () => null, title: 'Test' },
|
||||
provider: { icon: () => null, title: 'Test', id: 'test-provider' },
|
||||
onAuthRequest: authHandler1,
|
||||
});
|
||||
|
||||
const authHandler2 = jest.fn().mockResolvedValue('other');
|
||||
const requester2 = mock.createAuthRequester({
|
||||
provider: { icon: () => null, title: 'Test' },
|
||||
provider: { icon: () => null, title: 'Test', id: 'test-provider' },
|
||||
onAuthRequest: authHandler2,
|
||||
});
|
||||
|
||||
@@ -66,13 +66,13 @@ describe('MockOAuthApi', () => {
|
||||
|
||||
const authHandler1 = jest.fn();
|
||||
const requester1 = mock.createAuthRequester({
|
||||
provider: { icon: () => null, title: 'Test' },
|
||||
provider: { icon: () => null, title: 'Test', id: 'test-provider' },
|
||||
onAuthRequest: authHandler1,
|
||||
});
|
||||
|
||||
const authHandler2 = jest.fn();
|
||||
const requester2 = mock.createAuthRequester({
|
||||
provider: { icon: () => null, title: 'Test' },
|
||||
provider: { icon: () => null, title: 'Test', id: 'test-provider' },
|
||||
onAuthRequest: authHandler2,
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ describe('OAuthRequestManager', () => {
|
||||
|
||||
const requester = manager.createAuthRequester({
|
||||
provider: {
|
||||
id: 'my-provider',
|
||||
title: 'My Provider',
|
||||
icon: () => null,
|
||||
},
|
||||
|
||||
@@ -39,12 +39,6 @@ export class OAuthRequestManager implements OAuthRequestApi {
|
||||
private handlerCount = 0;
|
||||
|
||||
createAuthRequester<T>(options: OAuthRequesterOptions<T>): OAuthRequester<T> {
|
||||
if (!options.provider.id) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
'DEPRECATION WARNING: Not passing a provider id to createAuthRequester is deprecated, it will be required in the future',
|
||||
);
|
||||
}
|
||||
const handler = new OAuthPendingRequests<T>();
|
||||
|
||||
const index = this.handlerCount;
|
||||
|
||||
@@ -27,10 +27,8 @@ import { AuthProviderInfo } from './auth';
|
||||
export type OAuthRequesterOptions<TOAuthResponse> = {
|
||||
/**
|
||||
* Information about the auth provider, which will be forwarded to auth requests.
|
||||
*
|
||||
* Not passing in an `id` is deprecated, and it will be required in the future.
|
||||
*/
|
||||
provider: Omit<AuthProviderInfo, 'id'> & { id?: string };
|
||||
provider: AuthProviderInfo;
|
||||
|
||||
/**
|
||||
* Implementation of the auth flow, which will be called synchronously when
|
||||
@@ -71,10 +69,8 @@ export type OAuthRequester<TAuthResponse> = (
|
||||
export type PendingOAuthRequest = {
|
||||
/**
|
||||
* Information about the auth provider, as given in the AuthRequesterOptions
|
||||
*
|
||||
* Not passing in an `id` is deprecated, and it will be required in the future.
|
||||
*/
|
||||
provider: Omit<AuthProviderInfo, 'id'> & { id?: string };
|
||||
provider: AuthProviderInfo;
|
||||
|
||||
/**
|
||||
* Rejects the request, causing all pending AuthRequester calls to fail with "RejectedError".
|
||||
|
||||
Reference in New Issue
Block a user