-
Notifications
You must be signed in to change notification settings - Fork 12
[PB-5305]: validateTokenAndCheckExpiration simplified and added tests #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
larryrider
reviewed
Jan 5, 2026
Contributor
|
check sonarcloud issues |
…n-version-detected
…ception is catched
larryrider
approved these changes
Jan 12, 2026
Contributor
larryrider
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check sonarcloud issue
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



What is Changed / Added
AuthService.getAuthDetailsnow properly handles the case where the backend detects an old token version during the call torefreshUserToken. When this specific error occurs, the system automatically clears the stored user credentials and throws a dedicatedOldTokenDetectedError. This change aims to prevents users from getting stuck in a broken authentication state where their local token is no longer valid on the server.In the following trace you can see the error I am trying to fix with this pull request
{ "level": "error", "message": "[REPORTED_ERROR]: Old token version detected\nProperties => {\n \"command\": \"webdav\"\n}\nStack => Error: Old token version detected\n at new AppError (/usr/lib/node_modules/@internxt/cli/node_modules/@internxt/sdk/dist/shared/types/errors.js:21:28)\n at HttpClient.normalizeError (/usr/lib/node_modules/@internxt/cli/node_modules/@internxt/sdk/dist/shared/http/client.js:190:15)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async Axios.request (/usr/lib/node_modules/@internxt/cli/node_modules/axios/dist/node/axios.cjs:4478:14)\n at async AuthService.refreshUserToken (/usr/lib/node_modules/@internxt/cli/dist/services/auth.service.js:79:26)\n at async AuthService.getAuthDetails (/usr/lib/node_modules/@internxt/cli/dist/services/auth.service.js:54:26)\n at async Webdav.run" }The method in charge of validating and checking the expiration of the token
validateTokenAndCheckExpirationwas refactored to separate concerns more clearly. This way it is easier to test and reason about token states throughout the authentication flow.Two new error detection utilities
isFileNotFoundErrorandisOldTokenErrorwere added to identify file system errors and old token errors more reliably.ConfigService.clearUserwas also updated to gracefully handle cases where the credentials file doesn't exist during cleanup operations.