Skip to content

Commit

Permalink
chore: ID-3113 Improve refresh token error logging (#2475)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenfowler authored Dec 18, 2024
1 parent 25ec0fd commit 75040ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit 75040ec

Please sign in to comment.