Skip to content
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

chore: ID-3113 Improve refresh token error logging #2475

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/passport/sdk/src/authManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,19 @@ describe('AuthManager', () => {
expect(result).toEqual(mockUser);
});

it('should reject with an error when signinSilent throws a string', async () => {
mockGetUser.mockReturnValue(mockOidcExpiredUser);
(isTokenExpired as jest.Mock).mockReturnValue(true);
mockSigninSilent.mockRejectedValue('oops');

await expect(() => authManager.getUser()).rejects.toThrow(
new PassportError(
'Failed to refresh token: oops',
PassportErrorType.AUTHENTICATION_ERROR,
),
);
});

it('should return null when the user token is expired without refresh token', async () => {
mockGetUser.mockReturnValue(mockOidcExpiredNoRefreshTokenUser);
(isTokenExpired as jest.Mock).mockReturnValue(true);
Expand Down
2 changes: 2 additions & 0 deletions packages/passport/sdk/src/authManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ export default class AuthManager {
errorMessage = `${err.message}: ${err.error_description}`;
} else if (err instanceof Error) {
errorMessage = err.message;
} else if (typeof err === 'string') {
errorMessage = `${errorMessage}: ${err}`;
}

reject(new PassportError(errorMessage, passportErrorType));
Expand Down
Loading