Importing this library using import { CognitoAuth } from 'amazon-cognito-auth-js/dist/amazon-cognito-auth'; to grab the prebuilt Webpack distribution, as recommended by issue #13 .
Cognito is set up to use a 3rd party federated ID provider internal to my company. We're using the code grant flow.
Some authentication step after returning with the grant code is calling a function named decode, I believe defined in DecodingHelper.js. That code calls global.atob(). which throws the following error at line 730 of the Webpacked file: ERROR TypeError: "global is undefined"
It appears to be preventing the library from writing the credentials to localStorage.
I was able to fix this issue by changing the definition of decode() in the Webpack file to
var decode = exports.decode = function decode(str) {
// return global.atob(str);
return global ? global.atob(str) : window.atob(str);
};
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
Technologies used: Angular 8.1.3, Firefox 68.1.0esr
Importing this library using
import { CognitoAuth } from 'amazon-cognito-auth-js/dist/amazon-cognito-auth';
to grab the prebuilt Webpack distribution, as recommended by issue #13 .Cognito is set up to use a 3rd party federated ID provider internal to my company. We're using the code grant flow.
Some authentication step after returning with the grant code is calling a function named decode, I believe defined in DecodingHelper.js. That code calls
global.atob()
. which throws the following error at line 730 of the Webpacked file:ERROR TypeError: "global is undefined"
It appears to be preventing the library from writing the credentials to localStorage.
I was able to fix this issue by changing the definition of
decode()
in the Webpack file tobut this is not an ideal way to fix this bug.