Skip to content

Commit

Permalink
Merge pull request #427 from ForgeRock/fix_ping-error-handling
Browse files Browse the repository at this point in the history
fix(javascript-sdk): add PingOne login error to allowed errors
  • Loading branch information
cerebrl authored Feb 27, 2024
2 parents b717d02 + 64d0ff6 commit 3796ac3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/javascript-sdk/src/oauth2-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ import middlewareWrapper from '../util/middleware';
const allowedErrors = {
// AM error for consent requirement
AuthenticationConsentRequired: 'Authentication or consent required',

// Manual iframe error
AuthorizationTimeout: 'Authorization timed out',

// Chromium browser error
FailedToFetch: 'Failed to fetch',

// Mozilla browser error
NetworkError: 'NetworkError when attempting to fetch resource.',

// Webkit browser error
CORSError: 'Cross-origin redirection',

// prompt=none errors
InteractionNotAllowed: 'The request requires some interaction that is not allowed.',

// PingOne login error
LoginRequired: 'User authentication is required',
};

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/javascript-sdk/src/token-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ abstract class TokenManager {
allowedErrors.FailedToFetch !== err.message &&
allowedErrors.NetworkError !== err.message &&
allowedErrors.InteractionNotAllowed !== err.message &&
// Check for Ping Identity Login Required error
// Long message, so just check substring
!err.message.includes(allowedErrors.LoginRequired) &&
// Safari has a very long error message, so we check for a substring
!err.message.includes(allowedErrors.CORSError)
) {
Expand Down

0 comments on commit 3796ac3

Please sign in to comment.