packages/core: reorder some AuthConnector methods

This commit is contained in:
Patrik Oldsberg
2020-05-20 12:53:39 +02:00
parent 3ae262f4f8
commit 930c2dba2b
3 changed files with 9 additions and 9 deletions
@@ -94,6 +94,10 @@ export class DefaultAuthConnector<AuthSession>
this.sessionTransform = sessionTransform;
}
async createSession(scopes: Set<string>): Promise<AuthSession> {
return this.authRequester(scopes);
}
async refreshSession(): Promise<any> {
const res = await fetch(this.buildUrl('/token', { optional: true }), {
headers: {
@@ -138,10 +142,6 @@ export class DefaultAuthConnector<AuthSession>
}
}
async createSession(scopes: Set<string>): Promise<AuthSession> {
return this.authRequester(scopes);
}
private async showPopup(scope: string): Promise<AuthSession> {
const popupUrl = this.buildUrl('/start', { scope });
@@ -33,13 +33,13 @@ const defaultMockSession: MockSession = {
export class MockAuthConnector implements AuthConnector<MockSession> {
constructor(private readonly mockSession: MockSession = defaultMockSession) {}
async createSession() {
return this.mockSession;
}
async refreshSession() {
return this.mockSession;
}
async removeSession() {}
async createSession() {
return this.mockSession;
}
}
@@ -24,7 +24,7 @@ export type BaseAuthSession = {
* by for example communicating with a backend or interacting with the user.
*/
export type AuthConnector<AuthSession> = {
createSession(scopes: Set<string>): Promise<AuthSession>;
refreshSession(): Promise<AuthSession>;
removeSession(): Promise<void>;
createSession(scopes: Set<string>): Promise<AuthSession>;
};