Skip to content

Conversation

@egalvis27
Copy link

What is Changed / Added


There were some inconsistencies in the validations responsible for refreshing the token, which caused unexpected shutdowns in the application session.

Why

@egalvis27 egalvis27 requested a review from AlexisMora December 29, 2025 23:32
tag: 'AUTH',
});

ConfigStore.set<EncryptedTokenKey>(`${tokenName}Encrypted`, false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting the token now when before where throwing an expection? What changed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the strategy was to throw an exception when encryption was unavailable. Now, the token is marked as unencrypted and returned, allowing the request to execute without interruption. The application currently stores tokens in plain text when safeStorage is unavailable, so throwing an exception is unnecessary since the token remains usable. If the token becomes corrupted for any reason, the request utilizing it would trigger an onUserUnauthorized exception, forcing the user to log in again and replacing the corrupted token.

}

export async function createTokenSchedule(refreshedTokens?: Array<string | undefined>): Promise<void> {
export async function createTokenSchedule(refreshedTokens?: Array<string | undefined>) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method now has a retry mechanism, you could add it onto the name of the funtion to better reflect the behaviour

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better yet: split into two and have one call the other, this way you have better separation of concerns

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think renaming it would be a better approach. The current function is only about 10 lines long, so further breaking it down wouldn't provide significant value.

@egalvis27 egalvis27 requested a review from AlexisMora December 31, 2025 15:49
import { TokenScheduler } from '../../token-scheduler/TokenScheduler';
import { Job } from 'node-schedule';

describe('createTokenScheduleWithRetry', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, you are naming this test file with a file that it does not exists, but rather is a method from another file. You have 2 options here, either move that method to a separate file, or in the refreshToken test have this whole section inside, so you would have it like this

describe('refreshToken', () => {
[...]
	
    describe('createTokenScheduleWithRetry', () => {
        [...]
    });
});    
``

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions have been placed in separate files to make it more organized.

@@ -0,0 +1,42 @@
import { Either, left, right } from '../../../../context/shared/domain/Either';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same principle applies here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions have been placed in separate files to make it more organized.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
70.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants