How to use the amazon-cognito-identity-js.CognitoUserSession function in amazon-cognito-identity-js

To help you get started, we’ve selected a few amazon-cognito-identity-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-js / packages / auth / __tests__ / cred-unit-test-rn.ts View on Github external
userPoolId: null,
	userPoolWebClientId: 'awsUserPoolsWebClientId',
	region: 'region',
	identityPoolId: 'awsCognitoIdentityPoolId',
	mandatorySignIn: false,
};

const userPool = new CognitoUserPool({
	UserPoolId: authOptions.userPoolId,
	ClientId: authOptions.userPoolWebClientId,
});

const idToken = new CognitoIdToken({ IdToken: 'idToken' });
const accessToken = new CognitoAccessToken({ AccessToken: 'accessToken' });

const session = new CognitoUserSession({
	IdToken: idToken,
	AccessToken: accessToken,
});

const cognitoCredentialSpyon = jest
	.spyOn(CognitoIdentityCredentials.prototype, 'get')
	.mockImplementation(callback => {
		callback(null);
	});

describe('for react native', () => {
	describe('currentUserCredentials test', () => {
		test('with federated info', async () => {
			//     const auth = new Auth(authOptions);

			//     const spyon = jest.spyOn(Credentials, 'currentUserCredentials');
github paulcwatts / ember-cognito / addon-test-support / utils / -mock-auth.js View on Github external
export function newSession({ idToken, refreshToken, accessToken } = {}) {
  const token = makeToken();
  return new CognitoUserSession({
    IdToken: new CognitoIdToken({ IdToken: idToken || token }),
    RefreshToken: new CognitoRefreshToken({ RefreshToken: refreshToken || token }),
    AccessToken: new CognitoAccessToken({ AccessToken: accessToken || token })
  });
}
github jpdillingham / SWoT / web / src / components / security / SecurityActions.js View on Github external
return new Promise((resolve, reject) => {
        if (sessionData) {
            let accessToken = new CognitoAccessToken({ AccessToken: sessionData.accessToken.jwtToken });
            let idToken = new CognitoIdToken({ IdToken: sessionData.idToken.jwtToken });
            let refreshToken = new CognitoRefreshToken({ RefreshToken: sessionData.refreshToken.token });
    
            let session = new CognitoUserSession({
                IdToken: idToken,
                AccessToken: accessToken,
                RefreshToken: refreshToken,
                ClockDrift: sessionData.clockDrift,
            });
    
            if (!session.isValid()) {
                dispatch(refreshSession()).then((result) => {
                    resolve(result);
                }, error => {
                    dispatch(logoutAction());
                    reject(error.response.message);
                });
            }
            else {
                resolve(true);