angular-auth-oidc-client: Cannot read property 'replace' of undefined
I’ve implemented the AutoLogin feature and after successful login in the following code I receive an error in browser console which says “Cannot read property replace of undefined”
Is it a bug or I’m missing something in code?
OidcSecurityValidation.prototype.urlBase64Decode = function (str) {
var /** @type {?} */ output = str.replace('-', '+').replace('_', '/');
switch (output.length % 4) {
case 0:
break;
case 2:
output += '==';
break;
case 3:
output += '=';
break;
default:
throw 'Illegal base64url string!';
}
return window.atob(output);
};
return OidcSecurityValidation;
}());
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 26 (16 by maintainers)
I’m using version 1.17 (planning on upgrading to the latest soon) and I get the same issue. I’ve turned on the logging and I seem to get that error whenever the nonce fails validation. I’ve checked the server logs and I can confirm it returns the correct nonce. What I think is happening from reading the logs is that the client sends an authorize request to the server with a nonce which it stores on the local storage but then I think it sends another authorize request (before the other one gets its response) this time with a different nonce which overwrites the one on the local storage. The response for the first authorize request then returns but now that nonce is invalid because it is expecting the nonce of the second authorize request.
I’m not sure if this is exactly whats happening but it is what I can piece together from the logs.
Hope this helps.
Please note, that it also happen when user is signed out of STS, and the Angular app does silent_renew.
I have this problem occasionally when the token refresh happens and another request is done while the token refresh has not yet completed:
Stacktrace:
This is what happens on the local storage: (I’ve replaced the token with the string
TOKENfor clarity)Then I make a GET request to the identity server:
Which returns with a
302: Foundstatus code. At this time another XHR request from the applications starts to make a database request, which fails because the Bearer token is not set at this point.Also, from this point on, the token refresh does not work anymore besides the
CheckSessionist constantly polling in the background, because the ID Token is not set in the local storage anymore.(Version used: Commit
e537d7403d6bf544c70913dea0af0fce79b72af4)@damienbod I’m pretty sure this is not a server issue. I’ve just seen the error occur again on the client, and the server logs all look fine. I haven’t been able to trace beyond this.