@aws-amplify/auth 6.10.3-unstable.22ceeb3.0 → 6.10.3-unstable.289f3e8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,7 @@ const parseDevicesResponse = async (devices) => {
54
54
  }
55
55
  return attrs;
56
56
  }, {});
57
- return {
57
+ const result = {
58
58
  id,
59
59
  name: deviceName,
60
60
  attributes,
@@ -68,6 +68,7 @@ const parseDevicesResponse = async (devices) => {
68
68
  ? new Date(DeviceLastAuthenticatedDate * 1000)
69
69
  : undefined,
70
70
  };
71
+ return result;
71
72
  });
72
73
  };
73
74
  //# sourceMappingURL=fetchDevices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDevices.js","sources":["../../../../../src/providers/cognito/apis/fetchDevices.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fetchDevices = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst types_1 = require(\"../utils/types\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../factories\");\n// Cognito Documentation for max device\n// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html#API_ListDevices_RequestSyntax\nconst MAX_DEVICES = 60;\n/**\n * Fetches devices that have been remembered using {@link rememberDevice}\n * for the currently authenticated user.\n *\n * @returns FetchDevicesOutput\n * @throws {@link ListDevicesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function fetchDevices() {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await (0, core_1.fetchAuthSession)();\n (0, types_1.assertAuthTokens)(tokens);\n const listDevices = (0, cognitoIdentityProvider_1.createListDevicesClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await listDevices({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.FetchDevices),\n }, {\n AccessToken: tokens.accessToken.toString(),\n Limit: MAX_DEVICES,\n });\n return parseDevicesResponse(response.Devices ?? []);\n}\nexports.fetchDevices = fetchDevices;\nconst parseDevicesResponse = async (devices) => {\n return devices.map(({ DeviceKey: id = '', DeviceAttributes = [], DeviceCreateDate, DeviceLastModifiedDate, DeviceLastAuthenticatedDate, }) => {\n let deviceName;\n const attributes = DeviceAttributes.reduce((attrs, { Name, Value }) => {\n if (Name && Value) {\n if (Name === 'device_name')\n deviceName = Value;\n attrs[Name] = Value;\n }\n return attrs;\n }, {});\n return {\n id,\n name: deviceName,\n attributes,\n createDate: DeviceCreateDate\n ? new Date(DeviceCreateDate * 1000)\n : undefined,\n lastModifiedDate: DeviceLastModifiedDate\n ? new Date(DeviceLastModifiedDate * 1000)\n : undefined,\n lastAuthenticatedDate: DeviceLastAuthenticatedDate\n ? new Date(DeviceLastAuthenticatedDate * 1000)\n : undefined,\n };\n });\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC;AAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CA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C;AACV,KAAK,CAAC,CAAC;AACP,CAAC;;"}
1
+ {"version":3,"file":"fetchDevices.js","sources":["../../../../../src/providers/cognito/apis/fetchDevices.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fetchDevices = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst types_1 = require(\"../utils/types\");\nconst parsers_1 = require(\"../../../foundation/parsers\");\nconst utils_2 = require(\"../../../utils\");\nconst cognitoIdentityProvider_1 = require(\"../../../foundation/factories/serviceClients/cognitoIdentityProvider\");\nconst factories_1 = require(\"../factories\");\n// Cognito Documentation for max device\n// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html#API_ListDevices_RequestSyntax\nconst MAX_DEVICES = 60;\n/**\n * Fetches devices that have been remembered using {@link rememberDevice}\n * for the currently authenticated user.\n *\n * @returns FetchDevicesOutput\n * @throws {@link ListDevicesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nasync function fetchDevices() {\n const authConfig = core_1.Amplify.getConfig().Auth?.Cognito;\n (0, utils_1.assertTokenProviderConfig)(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await (0, core_1.fetchAuthSession)();\n (0, types_1.assertAuthTokens)(tokens);\n const listDevices = (0, cognitoIdentityProvider_1.createListDevicesClient)({\n endpointResolver: (0, factories_1.createCognitoUserPoolEndpointResolver)({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await listDevices({\n region: (0, parsers_1.getRegionFromUserPoolId)(userPoolId),\n userAgentValue: (0, utils_2.getAuthUserAgentValue)(utils_1.AuthAction.FetchDevices),\n }, {\n AccessToken: tokens.accessToken.toString(),\n Limit: MAX_DEVICES,\n });\n return parseDevicesResponse(response.Devices ?? []);\n}\nexports.fetchDevices = fetchDevices;\nconst parseDevicesResponse = async (devices) => {\n return devices.map(({ DeviceKey: id = '', DeviceAttributes = [], DeviceCreateDate, DeviceLastModifiedDate, DeviceLastAuthenticatedDate, }) => {\n let deviceName;\n const attributes = DeviceAttributes.reduce((attrs, { Name, Value }) => {\n if (Name && Value) {\n if (Name === 'device_name')\n deviceName = Value;\n attrs[Name] = Value;\n }\n return attrs;\n }, {});\n const result = {\n id,\n name: deviceName,\n attributes,\n createDate: DeviceCreateDate\n ? new Date(DeviceCreateDate * 1000)\n : undefined,\n lastModifiedDate: DeviceLastModifiedDate\n ? new Date(DeviceLastModifiedDate * 1000)\n : undefined,\n lastAuthenticatedDate: DeviceLastAuthenticatedDate\n ? new Date(DeviceLastAuthenticatedDate * 1000)\n : undefined,\n };\n return result;\n });\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC;AAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACzD,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1C,MAAM,yBAAyB,GAAG,OAAO,CAAC,sEAAsE,CAAC,CAAC;AAClH,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C;AACA;AACA,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,YAAY,GAAG;AAC9B,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CA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,IAAI,UAAU,CAAC;AACvB,QAAQ,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK;AAC/E,YAAY,IAAI,IAAI,IAAI,KAAK,EAAE;AAC/B,gBAAgB,IAAI,IAAI,KAAK,aAAa;AAC1C,oBAAoB,UAAU,GAAG,KAAK,CAAC;AACvC,gBAAgB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AACpC,aAAa;AACb,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS,EAAE,EAAE,CAAC,CAAC;AACf,QAAQ,MAAM,MAAM,GAAG;AACvB,YAAY,EAAE;AACd,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,UAAU;AACtB,YAAY,UAAU,EAAE,gBAAgB;AACxC,kBAAkB,IAAI,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;AACnD,kBAAkB,SAAS;AAC3B,YAAY,gBAAgB,EAAE,sBAAsB;AACpD,kBAAkB,IAAI,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;AACzD,kBAAkB,SAAS;AAC3B,YAAY,qBAAqB,EAAE,2BAA2B;AAC9D,kBAAkB,IAAI,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;AAC9D,kBAAkB,SAAS;AAC3B,SAAS,CAAC;AACV,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK,CAAC,CAAC;AACP,CAAC;;"}
@@ -57,7 +57,7 @@ const parseDevicesResponse = async (devices) => {
57
57
  }
58
58
  return attrs;
59
59
  }, {});
60
- return {
60
+ const result = {
61
61
  id,
62
62
  name: deviceName,
63
63
  attributes,
@@ -71,6 +71,7 @@ const parseDevicesResponse = async (devices) => {
71
71
  ? new Date(DeviceLastAuthenticatedDate * 1000)
72
72
  : undefined,
73
73
  };
74
+ return result;
74
75
  });
75
76
  };
76
77
 
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDevices.mjs","sources":["../../../../../src/providers/cognito/apis/fetchDevices.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../utils/types';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createListDevicesClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n// Cognito Documentation for max device\n// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html#API_ListDevices_RequestSyntax\nconst MAX_DEVICES = 60;\n/**\n * Fetches devices that have been remembered using {@link rememberDevice}\n * for the currently authenticated user.\n *\n * @returns FetchDevicesOutput\n * @throws {@link ListDevicesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function fetchDevices() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession();\n assertAuthTokens(tokens);\n const listDevices = createListDevicesClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await listDevices({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.FetchDevices),\n }, {\n AccessToken: tokens.accessToken.toString(),\n Limit: MAX_DEVICES,\n });\n return parseDevicesResponse(response.Devices ?? []);\n}\nconst parseDevicesResponse = async (devices) => {\n return devices.map(({ DeviceKey: id = '', DeviceAttributes = [], DeviceCreateDate, DeviceLastModifiedDate, DeviceLastAuthenticatedDate, }) => {\n let deviceName;\n const attributes = DeviceAttributes.reduce((attrs, { Name, Value }) => {\n if (Name && Value) {\n if (Name === 'device_name')\n deviceName = Value;\n attrs[Name] = Value;\n }\n return attrs;\n }, {});\n return {\n id,\n name: deviceName,\n attributes,\n createDate: DeviceCreateDate\n ? new Date(DeviceCreateDate * 1000)\n : undefined,\n lastModifiedDate: DeviceLastModifiedDate\n ? new Date(DeviceLastModifiedDate * 1000)\n : undefined,\n lastAuthenticatedDate: DeviceLastAuthenticatedDate\n ? new Date(DeviceLastAuthenticatedDate * 1000)\n : undefined,\n };\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,YAAY,GAAG;AACrC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;AACxD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;AAChD,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAChD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC;AACvC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,YAAY,CAAC;AACtE,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,KAAK,EAAE,WAAW;AAC1B,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,oBAAoB,CAAC,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["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { assertAuthTokens } from '../utils/types';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { createListDevicesClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../factories';\n// Cognito Documentation for max device\n// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListDevices.html#API_ListDevices_RequestSyntax\nconst MAX_DEVICES = 60;\n/**\n * Fetches devices that have been remembered using {@link rememberDevice}\n * for the currently authenticated user.\n *\n * @returns FetchDevicesOutput\n * @throws {@link ListDevicesException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function fetchDevices() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { userPoolEndpoint, userPoolId } = authConfig;\n const { tokens } = await fetchAuthSession();\n assertAuthTokens(tokens);\n const listDevices = createListDevicesClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: userPoolEndpoint,\n }),\n });\n const response = await listDevices({\n region: getRegionFromUserPoolId(userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.FetchDevices),\n }, {\n AccessToken: tokens.accessToken.toString(),\n Limit: MAX_DEVICES,\n });\n return parseDevicesResponse(response.Devices ?? []);\n}\nconst parseDevicesResponse = async (devices) => {\n return devices.map(({ DeviceKey: id = '', DeviceAttributes = [], DeviceCreateDate, DeviceLastModifiedDate, DeviceLastAuthenticatedDate, }) => {\n let deviceName;\n const attributes = DeviceAttributes.reduce((attrs, { Name, Value }) => {\n if (Name && Value) {\n if (Name === 'device_name')\n deviceName = Value;\n attrs[Name] = Value;\n }\n return attrs;\n }, {});\n const result = {\n id,\n name: deviceName,\n attributes,\n createDate: DeviceCreateDate\n ? new Date(DeviceCreateDate * 1000)\n : undefined,\n lastModifiedDate: DeviceLastModifiedDate\n ? new Date(DeviceLastModifiedDate * 1000)\n : undefined,\n lastAuthenticatedDate: DeviceLastAuthenticatedDate\n ? new Date(DeviceLastAuthenticatedDate * 1000)\n : undefined,\n };\n return result;\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAQA;AACA;AACA,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,YAAY,GAAG;AACrC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;AACxD,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;AAChD,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAChD,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,gBAAgB;AAC9C,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC;AACvC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,UAAU,CAAC;AACnD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,YAAY,CAAC;AACtE,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,KAAK,EAAE,WAAW;AAC1B,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,oBAAoB,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC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: string;
262
+ name?: string;
262
263
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/auth",
3
- "version": "6.10.3-unstable.22ceeb3.0+22ceeb3",
3
+ "version": "6.10.3-unstable.289f3e8.0+289f3e8",
4
4
  "description": "Auth category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -96,13 +96,13 @@
96
96
  "tslib": "^2.5.0"
97
97
  },
98
98
  "peerDependencies": {
99
- "@aws-amplify/core": "6.9.4-unstable.22ceeb3.0+22ceeb3"
99
+ "@aws-amplify/core": "6.9.4-unstable.289f3e8.0+289f3e8"
100
100
  },
101
101
  "devDependencies": {
102
- "@aws-amplify/core": "6.9.4-unstable.22ceeb3.0+22ceeb3",
103
- "@aws-amplify/react-native": "1.1.8-unstable.22ceeb3.0+22ceeb3",
102
+ "@aws-amplify/core": "6.9.4-unstable.289f3e8.0+289f3e8",
103
+ "@aws-amplify/react-native": "1.1.8-unstable.289f3e8.0+289f3e8",
104
104
  "@jest/test-sequencer": "^29.7.0",
105
105
  "typescript": "5.0.2"
106
106
  },
107
- "gitHead": "22ceeb387bb17ac1f849b3dd2a75439ebd69ac44"
107
+ "gitHead": "289f3e8d1bbf8c95abffb553b612699f43cdccb5"
108
108
  }
@@ -7,7 +7,7 @@ import {
7
7
  assertTokenProviderConfig,
8
8
  } from '@aws-amplify/core/internals/utils';
9
9
 
10
- import { FetchDevicesOutput } from '../types';
10
+ import { AWSAuthDevice, FetchDevicesOutput } from '../types';
11
11
  import { DeviceType } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider/types';
12
12
  import { assertAuthTokens } from '../utils/types';
13
13
  import { getRegionFromUserPoolId } from '../../../foundation/parsers';
@@ -77,7 +77,7 @@ const parseDevicesResponse = async (
77
77
  {},
78
78
  );
79
79
 
80
- return {
80
+ const result: AWSAuthDevice = {
81
81
  id,
82
82
  name: deviceName,
83
83
  attributes,
@@ -91,6 +91,8 @@ const parseDevicesResponse = async (
91
91
  ? new Date(DeviceLastAuthenticatedDate * 1000)
92
92
  : undefined,
93
93
  };
94
+
95
+ return result;
94
96
  },
95
97
  );
96
98
  };
@@ -332,4 +332,5 @@ export interface AWSAuthUser {
332
332
  */
333
333
  export interface AuthDevice {
334
334
  id: string;
335
+ name?: string;
335
336
  }