Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _getEndpointId(cacheKey) {
// try to get from cache
let endpointId = await Cache.getItem(cacheKey);
logger.debug(
'endpointId from cache',
endpointId,
'type',
typeof endpointId
);
if (!endpointId) {
endpointId = uuid();
Cache.setItem(cacheKey, endpointId);
}
return endpointId;
}
private async _getEndpointId(cacheKey) {
// try to get from cache
let endpointId = await Cache.getItem(cacheKey);
logger.debug(
'endpointId from cache',
endpointId,
'type',
typeof endpointId
);
if (!endpointId) {
endpointId = uuid();
Cache.setItem(cacheKey, endpointId);
}
return endpointId;
}
return dispatch => {
loadingStart();
console.log("signing out");
Cache.removeItem("federatedInfo");
localStorage.clear();
Auth.signOut().then(e => {
loadingEnd();
dispatch(loggedOut());
})
}
}
if (!apiKey) {
throw new Error('No api-key configured');
}
headers = {
Authorization: null,
'X-Api-Key': apiKey,
};
break;
case 'AWS_IAM':
const credentialsOK = await this._ensureCredentials();
if (!credentialsOK) {
throw new Error('No credentials');
}
break;
case 'OPENID_CONNECT':
const federatedInfo = await Cache.getItem('federatedInfo');
if (!federatedInfo || !federatedInfo.token) {
throw new Error('No federated jwt');
}
headers = {
Authorization: federatedInfo.token,
};
break;
case 'AMAZON_COGNITO_USER_POOLS':
const session = await Auth.currentSession();
headers = {
Authorization: session.getAccessToken().getJwtToken(),
};
break;
default:
headers = {
if (!apiKey) {
throw new Error('No api-key configured');
}
headers = {
Authorization: null,
'X-Api-Key': apiKey,
};
break;
case 'AWS_IAM':
const credentialsOK = await this._ensureCredentials();
if (!credentialsOK) {
throw new Error('No credentials');
}
break;
case 'OPENID_CONNECT':
const federatedInfo = await Cache.getItem('federatedInfo');
if (!federatedInfo || !federatedInfo.token) {
throw new Error('No federated jwt');
}
headers = {
Authorization: federatedInfo.token,
};
break;
case 'AMAZON_COGNITO_USER_POOLS':
const session = await Auth.currentSession();
headers = {
Authorization: session.getAccessToken().getJwtToken(),
};
break;
default:
headers = {
} = this._options;
let headers = {};
switch (authenticationType) {
case 'API_KEY':
headers = {
Authorization: null,
'X-Api-Key': apiKey
};
break;
case 'AWS_IAM':
const credentialsOK = await this._ensureCredentials();
if (!credentialsOK) { throw new Error('No credentials'); }
break;
case 'OPENID_CONNECT':
const federatedInfo = await Cache.getItem('federatedInfo');
if (!federatedInfo || !federatedInfo.token) { throw new Error('No federated jwt'); }
headers = {
Authorization: federatedInfo.token
};
break;
case 'AMAZON_COGNITO_USER_POOLS':
if (Amplify.Auth && typeof Amplify.Auth.currentSession === 'function') {
const session = await Amplify.Auth.currentSession();
headers = {
Authorization: session.getAccessToken().getJwtToken()
};
} else {
throw new Error('No Auth module registered in Amplify');
}
break;