in src/index.ts [171:186]
_getIdTokenFromCookie(cookies) {
this._logger.debug({ msg: 'Extracting authentication token from request cookie', cookies });
// eslint-disable-next-line no-useless-escape
const regex = new RegExp(`${this._userPoolAppId}\..+?\.idToken=(.*?);`);
if (cookies) {
for (let i = 0; i < cookies.length; i++) {
const matches = cookies[i].value.match(regex);
if (matches && matches.length > 1) {
this._logger.debug({ msg: ' Found token in cookie', token: matches[1] });
return matches[1];
}
}
}
this._logger.debug(" idToken wasn't present in request cookies");
throw new Error("Id token isn't present in the request cookies");
}