Skip to content

Commit

Permalink
chore(api-graphql): Bump graphql to 14.5.0 (#8984)
Browse files Browse the repository at this point in the history
* Bump graphql to 14.5.0

* Specify graphql type where needed

* Use graphql 15.6.0

* Import directly from root

* Revert "Use graphql 15.6.0"

This reverts commit f8e79e4.

Co-authored-by: Chris Bonifacio <christopher.bonifacio@gmail.com>
  • Loading branch information
wlee221 and chrisbonifacio committed Oct 26, 2021
1 parent 5d01a1d commit 3f8c000
Show file tree
Hide file tree
Showing 31 changed files with 551 additions and 8,023 deletions.
264 changes: 35 additions & 229 deletions packages/amazon-cognito-identity-js/CHANGELOG.md

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions packages/amazon-cognito-identity-js/__tests__/CognitoUser.test.js
Expand Up @@ -383,12 +383,21 @@ describe('authenticateUserInternal()', () => {
});

test('DEVICE_SRP_AUTH calls getDeviceResponse and sends session', () => {
const clientSpy = jest.spyOn(Client.prototype, 'request')
.mockImplementation((...args) => { });
const authDataGetDeviceResponse = { ...authData, ChallengeName: 'DEVICE_SRP_AUTH', Session: 'abcd' };
const clientSpy = jest
.spyOn(Client.prototype, 'request')
.mockImplementation((...args) => {});
const authDataGetDeviceResponse = {
...authData,
ChallengeName: 'DEVICE_SRP_AUTH',
Session: 'abcd',
};
const spyon = jest.spyOn(user, 'getDeviceResponse');

user.authenticateUserInternal(authDataGetDeviceResponse, authHelper, callback);
user.authenticateUserInternal(
authDataGetDeviceResponse,
authHelper,
callback
);
expect(clientSpy.mock.calls[0][1]).toMatchObject({ Session: 'abcd' });
expect(spyon).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -1169,7 +1178,7 @@ describe('confirmPassword() and forgotPassword()', () => {
test('happy path should callback onSuccess', () => {
netRequestMockSuccess(true);
cognitoUser.confirmPassword(...confirmPasswordDefaults);
expect(callback.onSuccess).toHaveBeenCalledWith('SUCCESS')
expect(callback.onSuccess).toHaveBeenCalledWith('SUCCESS');
});

test('client request throws an error', () => {
Expand Down Expand Up @@ -1572,8 +1581,9 @@ describe('refreshSession()', () => {
const callback = jest.fn();
const refreshSessionDefaults = [new CognitoRefreshToken(), callback, {}];

const keyPrefix = `CognitoIdentityServiceProvider.${cognitoUser.pool.getClientId()}.${cognitoUser.username
}`;
const keyPrefix = `CognitoIdentityServiceProvider.${cognitoUser.pool.getClientId()}.${
cognitoUser.username
}`;

const idTokenKey = `${keyPrefix}.idToken`;
const accessTokenKey = `${keyPrefix}.accessToken`;
Expand Down
40 changes: 23 additions & 17 deletions packages/amazon-cognito-identity-js/src/CognitoUser.js
Expand Up @@ -673,7 +673,7 @@ export default class CognitoUser {
ClientId: this.pool.getClientId(),
ChallengeResponses: authParameters,
ClientMetadata: clientMetadata,
Session: this.Session
Session: this.Session,
};
if (this.getUserContextData()) {
jsonReq.UserContextData = this.getUserContextData();
Expand Down Expand Up @@ -1397,8 +1397,9 @@ export default class CognitoUser {
return callback(null, this.signInUserSession);
}

const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username
}`;
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${
this.username
}`;
const idTokenKey = `${keyPrefix}.idToken`;
const accessTokenKey = `${keyPrefix}.accessToken`;
const refreshTokenKey = `${keyPrefix}.refreshToken`;
Expand Down Expand Up @@ -1561,8 +1562,9 @@ export default class CognitoUser {
* @returns {void}
*/
cacheDeviceKeyAndPassword() {
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username
}`;
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${
this.username
}`;
const deviceKeyKey = `${keyPrefix}.deviceKey`;
const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;
const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;
Expand All @@ -1577,8 +1579,9 @@ export default class CognitoUser {
* @returns {void}
*/
getCachedDeviceKeyAndPassword() {
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username
}`;
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${
this.username
}`;
const deviceKeyKey = `${keyPrefix}.deviceKey`;
const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;
const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;
Expand All @@ -1595,8 +1598,9 @@ export default class CognitoUser {
* @returns {void}
*/
clearCachedDeviceKeyAndPassword() {
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${this.username
}`;
const keyPrefix = `CognitoIdentityServiceProvider.${this.pool.getClientId()}.${
this.username
}`;
const deviceKeyKey = `${keyPrefix}.deviceKey`;
const randomPasswordKey = `${keyPrefix}.randomPasswordKey`;
const deviceGroupKeyKey = `${keyPrefix}.deviceGroupKey`;
Expand Down Expand Up @@ -1970,7 +1974,7 @@ export default class CognitoUser {
*/
signOut(revokeTokenCallback) {
// If tokens won't be revoked, we just clean the client data.
if (!revokeTokenCallback || typeof revokeTokenCallback !== "function") {
if (!revokeTokenCallback || typeof revokeTokenCallback !== 'function') {
this.cleanClientData();

return;
Expand All @@ -1981,17 +1985,17 @@ export default class CognitoUser {
return revokeTokenCallback(error);
}

this.revokeTokens((err) => {
this.revokeTokens(err => {
this.cleanClientData();

revokeTokenCallback(err);
});
});
}

revokeTokens(revokeTokenCallback = () => { }) {
revokeTokens(revokeTokenCallback = () => {}) {
if (typeof revokeTokenCallback !== 'function') {
throw new Error('Invalid revokeTokenCallback. It should be a function.')
throw new Error('Invalid revokeTokenCallback. It should be a function.');
}

const tokensToBeRevoked = [];
Expand All @@ -2013,7 +2017,10 @@ export default class CognitoUser {

if (this.isSessionRevocable(accessToken)) {
if (refreshToken) {
return this.revokeToken({ token: refreshToken, callback: revokeTokenCallback });
return this.revokeToken({
token: refreshToken,
callback: revokeTokenCallback,
});
}
}
revokeTokenCallback();
Expand Down Expand Up @@ -2042,17 +2049,16 @@ export default class CognitoUser {
'RevokeToken',
{
Token: token,
ClientId: this.pool.getClientId()
ClientId: this.pool.getClientId(),
},
err => {

if (err) {
return callback(err);
}

callback();
}
)
);
}

/**
Expand Down

0 comments on commit 3f8c000

Please sign in to comment.