Skip to content

Commit 75040ec

Browse files
authored
chore: ID-3113 Improve refresh token error logging (#2475)
1 parent 25ec0fd commit 75040ec

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

packages/passport/sdk/src/authManager.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,19 @@ describe('AuthManager', () => {
453453
expect(result).toEqual(mockUser);
454454
});
455455

456+
it('should reject with an error when signinSilent throws a string', async () => {
457+
mockGetUser.mockReturnValue(mockOidcExpiredUser);
458+
(isTokenExpired as jest.Mock).mockReturnValue(true);
459+
mockSigninSilent.mockRejectedValue('oops');
460+
461+
await expect(() => authManager.getUser()).rejects.toThrow(
462+
new PassportError(
463+
'Failed to refresh token: oops',
464+
PassportErrorType.AUTHENTICATION_ERROR,
465+
),
466+
);
467+
});
468+
456469
it('should return null when the user token is expired without refresh token', async () => {
457470
mockGetUser.mockReturnValue(mockOidcExpiredNoRefreshTokenUser);
458471
(isTokenExpired as jest.Mock).mockReturnValue(true);

packages/passport/sdk/src/authManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ export default class AuthManager {
489489
errorMessage = `${err.message}: ${err.error_description}`;
490490
} else if (err instanceof Error) {
491491
errorMessage = err.message;
492+
} else if (typeof err === 'string') {
493+
errorMessage = `${errorMessage}: ${err}`;
492494
}
493495

494496
reject(new PassportError(errorMessage, passportErrorType));

0 commit comments

Comments
 (0)