From 698f97abf784645418948f8208c3202e5f86be79 Mon Sep 17 00:00:00 2001 From: Warren Parad Date: Wed, 27 Dec 2023 20:08:57 +0100 Subject: [PATCH] Improve logging level for session continuation. --- CHANGELOG.md | 1 + src/httpClient.js | 24 +++++++++++++----------- src/index.js | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 947ffc2..dc83d27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This is the changelog for [Authress Login](readme.md). ## 2.3 ## * Add MFA device methods. * Improve http error handling when there is an issue authenticating. +* Reduce logging level for SESSION continuation. ## 2.2 ## * Automatically retry on network connection issues. diff --git a/src/httpClient.js b/src/httpClient.js index 5b6782b..1c6bfd9 100644 --- a/src/httpClient.js +++ b/src/httpClient.js @@ -49,37 +49,37 @@ class HttpClient { this.loginUrl = `${loginHostFullUrl.origin}/api`; } - get(url, withCredentials, headers) { + get(url, withCredentials, headers, ignoreExpectedWarnings) { return retryExecutor(() => { - return this.fetchWrapper('GET', url, null, headers, withCredentials); + return this.fetchWrapper('GET', url, null, headers, withCredentials, ignoreExpectedWarnings); }); } - delete(url, withCredentials, headers) { + delete(url, withCredentials, headers, ignoreExpectedWarnings) { return retryExecutor(() => { - return this.fetchWrapper('DELETE', url, null, headers, withCredentials); + return this.fetchWrapper('DELETE', url, null, headers, withCredentials, ignoreExpectedWarnings); }); } - post(url, withCredentials, data, headers) { + post(url, withCredentials, data, headers, ignoreExpectedWarnings) { return retryExecutor(() => { - return this.fetchWrapper('POST', url, data, headers, withCredentials); + return this.fetchWrapper('POST', url, data, headers, withCredentials, ignoreExpectedWarnings); }); } - put(url, withCredentials, data, headers) { + put(url, withCredentials, data, headers, ignoreExpectedWarnings) { return retryExecutor(() => { - return this.fetchWrapper('PUT', url, data, headers, withCredentials); + return this.fetchWrapper('PUT', url, data, headers, withCredentials, ignoreExpectedWarnings); }); } - patch(url, withCredentials, data, headers) { + patch(url, withCredentials, data, headers, ignoreExpectedWarnings) { return retryExecutor(() => { - return this.fetchWrapper('PATCH', url, data, headers, withCredentials); + return this.fetchWrapper('PATCH', url, data, headers, withCredentials, ignoreExpectedWarnings); }); } - async fetchWrapper(rawMethod, urlObject, data, requestHeaders, withCredentials) { + async fetchWrapper(rawMethod, urlObject, data, requestHeaders, withCredentials, ignoreExpectedWarnings) { const url = `${this.loginUrl}${urlObject.toString()}`; const method = rawMethod.toUpperCase(); const headers = Object.assign({}, defaultHeaders, requestHeaders); @@ -124,6 +124,8 @@ class HttpClient { } else if (status === 404) { message = 'HttpClient Response: Not Found'; level = 'debug'; + } else if (status < 500 && ignoreExpectedWarnings) { + level = 'debug'; } if (this.logger && this.logger[level]) { diff --git a/src/index.js b/src/index.js index 2589d9f..55739a3 100644 --- a/src/index.js +++ b/src/index.js @@ -354,7 +354,7 @@ class LoginClient { if (!this.isLocalHost() && !backgroundTrigger) { try { - const sessionResult = await this.httpClient.patch('/session', this.enableCredentials, {}); + const sessionResult = await this.httpClient.patch('/session', this.enableCredentials, {}, null, true); // In the case that the session contains non cookie based data, store it back to the cookie for this domain if (sessionResult.data.access_token) { const idToken = jwtManager.decode(sessionResult.data.id_token);