Skip to content

Commit 289f3e8

Browse files
ashwinkumar6Ashwin Kumar
andauthored
fix(auth): update FetchDevicesOutput output type to include name attribute (#14186)
Co-authored-by: Ashwin Kumar <ashwsrir@amazon.com>
1 parent 22ceeb3 commit 289f3e8

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

packages/auth/__tests__/providers/cognito/fetchDevices.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,23 @@ describe('fetchDevices', () => {
8181
});
8282

8383
it('should fetch devices and parse client response correctly', async () => {
84-
expect(await fetchDevices()).toEqual([apiOutputDevice]);
84+
const {
85+
id,
86+
name,
87+
attributes,
88+
createDate,
89+
lastAuthenticatedDate,
90+
lastModifiedDate,
91+
} = (await fetchDevices())[0];
92+
expect(id).toEqual(apiOutputDevice.id);
93+
expect(name).toEqual(apiOutputDevice.name);
94+
expect(attributes).toEqual(apiOutputDevice.attributes);
95+
expect(createDate).toEqual(apiOutputDevice.createDate);
96+
expect(lastAuthenticatedDate).toEqual(
97+
apiOutputDevice.lastAuthenticatedDate,
98+
);
99+
expect(lastModifiedDate).toEqual(apiOutputDevice.lastModifiedDate);
100+
85101
expect(mockListDevices).toHaveBeenCalledWith(
86102
expect.objectContaining({ region: 'us-west-2' }),
87103
expect.objectContaining({

packages/auth/src/providers/cognito/apis/fetchDevices.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
assertTokenProviderConfig,
88
} from '@aws-amplify/core/internals/utils';
99

10-
import { FetchDevicesOutput } from '../types';
10+
import { AWSAuthDevice, FetchDevicesOutput } from '../types';
1111
import { DeviceType } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
1212
import { assertAuthTokens } from '../utils/types';
1313
import { getRegionFromUserPoolId } from '../../../foundation/parsers';
@@ -77,7 +77,7 @@ const parseDevicesResponse = async (
7777
{},
7878
);
7979

80-
return {
80+
const result: AWSAuthDevice = {
8181
id,
8282
name: deviceName,
8383
attributes,
@@ -91,6 +91,8 @@ const parseDevicesResponse = async (
9191
? new Date(DeviceLastAuthenticatedDate * 1000)
9292
: undefined,
9393
};
94+
95+
return result;
9496
},
9597
);
9698
};

packages/auth/src/types/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,5 @@ export interface AWSAuthUser {
332332
*/
333333
export interface AuthDevice {
334334
id: string;
335+
name?: string;
335336
}

0 commit comments

Comments
 (0)