okta / okta-auth-js

The official js wrapper around Okta's auth API
Other
447 stars 261 forks source link

Handle fetch exceptions #1487

Closed denysoblohin-okta closed 8 months ago

denysoblohin-okta commented 8 months ago

fetch can throw exceptions: https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions

formatError currently will return AuthApiError with xhr property set to TypeError object. generateIdxAction will try to parse xhr as JSON and will trigger error SyntaxError: "undefined" is not valid JSON

You can reproduce with SIW playground with mock authenticator-enroll-select-authenticator-with-skip having incorrect url http://localhost:3000:1802/idp/idx/cancel. Clicking on Back to sign in will trigger error SyntaxError: "undefined" is not valid JSON instead of OAuthError: Failed to execute 'fetch' on 'Window': Failed to parse URL from http://localhost:3000:1802/idp/idx/cancel

Issue for SIW: OKTA-668419