From c2f65e1cbd06ec4b3b9220090a2ca383b20a145c Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Fri, 12 Jan 2024 15:41:44 -0500 Subject: [PATCH] fixed lint errors and minor cleanup --- src/credentials_provider/http_request.ts | 2 +- src/credentials_provider/index.ts | 3 ++- src/datasource/middleauth/credentials_provider.ts | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/credentials_provider/http_request.ts b/src/credentials_provider/http_request.ts index 475e706cf..bdad3b686 100644 --- a/src/credentials_provider/http_request.ts +++ b/src/credentials_provider/http_request.ts @@ -48,7 +48,7 @@ export async function fetchWithCredentials( cancellationToken: CancellationToken = uncancelableToken, ): Promise { let credentials: CredentialsWithGeneration | undefined; - credentialsLoop: for (let credentialsAttempt = 0; ; ) { + for (let credentialsAttempt = 0; ; ) { throwIfCanceled(cancellationToken); if (credentialsAttempt > 1) { // Don't delay on the first attempt, and also don't delay on the second attempt, since if the diff --git a/src/credentials_provider/index.ts b/src/credentials_provider/index.ts index 3e471de33..b5df0839c 100644 --- a/src/credentials_provider/index.ts +++ b/src/credentials_provider/index.ts @@ -57,7 +57,8 @@ export abstract class CredentialsProvider extends RefCounted { if (status === 401) { // 401: Authorization needed. OAuth2 token may have expired. return "refresh"; - } else if (status === 403 && !credentials.accessToken) { + } + if (status === 403 && !credentials.accessToken) { // Anonymous access denied. Request credentials. return "refresh"; } diff --git a/src/datasource/middleauth/credentials_provider.ts b/src/datasource/middleauth/credentials_provider.ts index f476f3b76..bda701dcd 100644 --- a/src/datasource/middleauth/credentials_provider.ts +++ b/src/datasource/middleauth/credentials_provider.ts @@ -102,7 +102,6 @@ async function waitForRemoteFlow( } async function waitForLogin(serverUrl: string): Promise { - console.log("wait for login"); const data = await waitForRemoteFlow( `${serverUrl}/api/v1/authorize`, `middleauth server ${serverUrl} login required.`, @@ -127,7 +126,7 @@ async function showTosForm(url: string, tosName: string) { url, `Before you can access ${tosName}, you need to accept its Terms of Service.`, "Open", - `Waiting for Terms of Service agreement...`, + "Waiting for Terms of Service agreement...", `Terms of Service closed for ${tosName}.`, ); return data === "success"; @@ -216,13 +215,12 @@ export class MiddleAuthAppCredentialsProvider extends CredentialsProvider => { - console.log("ma handle error", error); const { status } = error; if (status === 401) { // 401: Authorization needed. OAuth2 token may have expired. return "refresh"; - } else if (status === 403) { - // Anonymous access denied. Request credentials. + } + if (status === 403) { const { response } = error; if (response) { const { headers } = response; @@ -230,6 +228,7 @@ export class MiddleAuthAppCredentialsProvider extends CredentialsProvider