You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Chrome, the following exception is unhandled when getTokens is called after logout:
Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'ServiceWorker': Port at index 0 is already neutered.
at Object.<anonymous> (https://localhost:3000/static/js/vendors~main.chunk.js:67061:28)
(anonymous) @ appAuthHelper.js:272
Promise.then (async)
(anonymous) @ appAuthHelper.js:266
Promise.then (async)
(anonymous) @ appAuthHelper.js:264
(anonymous) @ appAuthHelper.js:281
registerIdentityProxy @ appAuthHelper.js:259
(anonymous) @ appAuthHelper.js:114
postMessage (async)
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
Promise.then (async)
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
2../TokenManager @ appAuthHelperFetchTokensBundle.js:46
t @ appAuthHelperFetchTokensBundle.js:46
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
3../appAuthHelperFetchTokens @ appAuthHelperFetchTokensBundle.js:46
t @ appAuthHelperFetchTokensBundle.js:46
s @ appAuthHelperFetchTokensBundle.js:46
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
However, with Firefox one gets React error boundary catching the error, resulting in the more cryptic, maybe it tried to serialize
Unhandled Rejection (DataCloneError): The object could not be cloned.
I used the following component in React in order to test the workflow.
importReact,{useEffect,useState}from'react';// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-ignoreimportAppAuthHelperfrom'appauthhelper';import{Toolbar}from'@mui/material';// Make the authorization requestexportconstAuthTest=()=>{const[data,setData]=useState<any>(null);useEffect(()=>{AppAuthHelper.init({clientId: 'warden.mobile',scopes: 'openid profile','authorizationEndpoint': 'https://localhost:44320/provider/auth','tokenEndpoint': 'https://localhost:44320/provider/token','revocationEndpoint': 'https://localhost:44320/provider/token/revocation',tokensAvailableHandler: function(claims: any,id_token: any,interactively_logged_in: any){constdata={ claims, id_token, interactively_logged_in };// eslint-disable-next-line no-consoleconsole.log('>>>>>>>>>>>>>>>>>>>>>>>>>',data);setData(data);},renewCooldownPeriod: 1,oidc: true,identityProxyPreference: 'serviceWorker',// Can be either "XHR" or "serviceWorker"renewStrategy: 'authCode',// Can be either "authCode" or "refreshToken"redirectUri: 'appAuthHelperRedirect.html',// Can be a relative or absolute urlserviceWorkerUri: 'appAuthServiceWorker.js'// Can be a relative or absolute url}).then(()=>{AppAuthHelper.getTokens();});},[]);return(<div><buttononClick={()=>{AppAuthHelper.getTokens();}}>Login</button>{JSON.stringify(data,null,2)}<buttononClick={()=>{setData(null);AppAuthHelper.logout();}}>Logout</button></div>);};
In order to reproduce this error, these steps are taken:
Click "Logout" after token string appears
Click "Login" after logout request completes
The text was updated successfully, but these errors were encountered:
Based on my reading of the code, this would only be possible if calling AppAuthHelper.logout(); doesn't actually end your session at the OP. Because of this, the call to AppAuthHelper.getTokens(); would be successful without a full-page redirection (i.e. it would be able to get fresh tokens using a silent auth code grant). Once that grant returns, the current code attempts to establish the IdentityProxy, which in this case isn't necessary because it was already established earlier. So, the fix for this case will be to just check to see if the IdentityProxy has already been established and skip it it is has.
It is somewhat of a strange behavior that your OP preserves the session after you call logout, though, isn't it?
jakefeasel
added a commit
to jakefeasel/appAuthHelper
that referenced
this issue
Dec 8, 2021
In Chrome, the following exception is unhandled when getTokens is called after logout:
However, with Firefox one gets React error boundary catching the error, resulting in the more cryptic, maybe it tried to serialize
I used the following component in React in order to test the workflow.
In order to reproduce this error, these steps are taken:
The text was updated successfully, but these errors were encountered: