Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('...should be returning Amplify.Auth', inject([AmplifyService], (service: AmplifyService) => {
const myAuth = service.auth();
expect(myAuth).toEqual(Amplify.Auth);
}));
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;
default:
headers = {
Authorization: null,
};
break;
}
return headers;
}
};
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;
default:
headers = {
Authorization: null,
};
break;
}
return headers;
Auth.signOut = (): Promise => {
return _signOut
.call(Amplify.Auth)
.then(data => {
logger.debug('signOut success');
authState.next({ state: 'signedOut', user: null });
return data;
})
.catch(err => {
logger.debug('signOut error', err);
throw err;
});
};
}
import Amplify from '@aws-amplify/core';
const Auth = Amplify.Auth;
const API = Amplify.API;
const Analytics = Amplify.Analytics;
const Storage = Amplify.Storage;
const PubSub = Amplify.PubSub;
const Interactions = Amplify.Interactions;
export { Auth, API, Analytics, Storage, PubSub, Interactions };
import XR, { XRClass } from '@aws-amplify/xr';
import Predictions from '@aws-amplify/predictions';
import Amplify, {
ConsoleLogger as Logger,
Hub,
JS,
ClientDevice,
Signer,
I18n,
ServiceWorker,
} from '@aws-amplify/core';
export default Amplify;
Amplify.Auth = Auth;
Amplify.Analytics = Analytics;
Amplify.API = API;
Amplify.Storage = Storage;
Amplify.I18n = I18n;
Amplify.Cache = Cache;
Amplify.PubSub = PubSub;
Amplify.Logger = Logger;
Amplify.ServiceWorker = ServiceWorker;
Amplify.Interactions = Interactions;
Amplify.UI = UI;
Amplify.XR = XR;
Amplify.Predictions = Predictions;
export {
Auth,
Analytics,