@aws-amplify/core 6.0.1-console-preview.5f040a2.0 → 6.0.1-console-preview.23dc225.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.
Files changed (260) hide show
  1. package/lib/Cache/StorageCache.d.ts +14 -31
  2. package/lib/Cache/StorageCache.js +97 -102
  3. package/lib/Cache/StorageCache.native.d.ts +19 -0
  4. package/lib/Cache/StorageCache.native.js +164 -0
  5. package/lib/Cache/{AsyncStorageCache.d.ts → StorageCacheCommon.d.ts} +124 -99
  6. package/lib/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +497 -432
  7. package/lib/Cache/constants.d.ts +6 -0
  8. package/lib/Cache/constants.js +17 -0
  9. package/lib/Cache/index.d.ts +2 -0
  10. package/lib/Cache/index.js +7 -0
  11. package/lib/Cache/types/cache.d.ts +38 -0
  12. package/lib/Cache/types/index.d.ts +1 -1
  13. package/lib/Cache/types/index.js +1 -1
  14. package/lib/Cache/{Utils → utils}/CacheList.d.ts +1 -1
  15. package/lib/Cache/{Utils → utils}/CacheList.js +2 -1
  16. package/lib/Cache/utils/cacheHelpers.d.ts +14 -0
  17. package/lib/Cache/utils/cacheHelpers.js +51 -0
  18. package/lib/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
  19. package/lib/Cache/{Utils → utils}/errorHelpers.js +0 -4
  20. package/lib/Cache/utils/index.d.ts +2 -0
  21. package/lib/Cache/utils/index.js +12 -0
  22. package/lib/Hub/index.d.ts +7 -0
  23. package/lib/Hub/index.js +8 -1
  24. package/lib/Platform/customUserAgent.d.ts +16 -0
  25. package/lib/Platform/customUserAgent.js +70 -0
  26. package/lib/Platform/index.js +10 -1
  27. package/lib/Platform/types.d.ts +33 -1
  28. package/lib/Platform/types.js +1 -0
  29. package/lib/Platform/version.d.ts +1 -1
  30. package/lib/Platform/version.js +1 -1
  31. package/lib/Reachability/Reachability.d.ts +1 -0
  32. package/lib/Reachability/Reachability.js +36 -0
  33. package/lib/Signer/Signer.js +3 -2
  34. package/lib/awsClients/cognitoIdentity/base.js +2 -1
  35. package/lib/awsClients/pinpoint/base.js +2 -1
  36. package/lib/awsClients/pinpoint/getInAppMessages.js +2 -1
  37. package/lib/awsClients/pinpoint/putEvents.js +2 -1
  38. package/lib/awsClients/pinpoint/updateEndpoint.js +2 -1
  39. package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
  40. package/lib/clients/middleware/signing/signer/signatureV4/index.js +0 -1
  41. package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
  42. package/lib/index.d.ts +2 -5
  43. package/lib/index.js +3 -6
  44. package/lib/libraryUtils.d.ts +7 -5
  45. package/lib/libraryUtils.js +11 -6
  46. package/lib/parseAWSExports.js +75 -14
  47. package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -2
  48. package/lib/providers/pinpoint/apis/record.js +3 -3
  49. package/lib/providers/pinpoint/apis/updateEndpoint.js +6 -6
  50. package/lib/singleton/API/types.d.ts +4 -3
  51. package/lib/singleton/Amplify.d.ts +2 -2
  52. package/lib/singleton/Amplify.js +6 -5
  53. package/lib/singleton/Auth/types.d.ts +28 -1
  54. package/lib/singleton/Cache/types.d.ts +18 -0
  55. package/lib/singleton/Cache/types.js +4 -0
  56. package/lib/singleton/types.d.ts +3 -1
  57. package/lib/storage/DefaultStorage.js +1 -1
  58. package/lib/storage/utils.d.ts +1 -1
  59. package/lib/storage/utils.js +3 -3
  60. package/lib/tsconfig.tsbuildinfo +1 -1
  61. package/lib/utils/amplifyUrl/index.d.ts +13 -0
  62. package/lib/utils/amplifyUrl/index.js +10 -0
  63. package/lib/utils/amplifyUrl/polyfill.d.ts +0 -0
  64. package/lib/utils/amplifyUrl/polyfill.js +4 -0
  65. package/lib/utils/amplifyUrl/polyfill.native.d.ts +1 -0
  66. package/lib/utils/amplifyUuid/index.d.ts +3 -0
  67. package/lib/utils/amplifyUuid/index.js +9 -0
  68. package/lib/utils/amplifyUuid/polyfill.d.ts +0 -0
  69. package/lib/utils/amplifyUuid/polyfill.js +4 -0
  70. package/lib/utils/amplifyUuid/polyfill.native.d.ts +1 -0
  71. package/lib/utils/amplifyUuid/polyfill.native.js +6 -0
  72. package/lib/utils/deepFreeze.d.ts +1 -0
  73. package/lib/utils/deepFreeze.js +38 -0
  74. package/lib/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
  75. package/lib/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +4 -4
  76. package/lib/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
  77. package/lib/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
  78. package/lib/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +4 -4
  79. package/lib/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +6 -18
  80. package/lib/utils/getClientInfo/index.d.ts +1 -0
  81. package/lib/utils/getClientInfo/index.js +7 -0
  82. package/lib/utils/index.d.ts +2 -0
  83. package/lib/utils/index.js +5 -1
  84. package/lib-esm/Cache/StorageCache.d.ts +14 -31
  85. package/lib-esm/Cache/StorageCache.js +97 -102
  86. package/lib-esm/Cache/StorageCache.native.d.ts +19 -0
  87. package/lib-esm/Cache/StorageCache.native.js +161 -0
  88. package/lib-esm/Cache/{AsyncStorageCache.d.ts → StorageCacheCommon.d.ts} +124 -99
  89. package/lib-esm/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +496 -430
  90. package/lib-esm/Cache/constants.d.ts +6 -0
  91. package/lib-esm/Cache/constants.js +14 -0
  92. package/lib-esm/Cache/index.d.ts +2 -0
  93. package/lib-esm/Cache/index.js +4 -0
  94. package/lib-esm/Cache/types/cache.d.ts +38 -0
  95. package/lib-esm/Cache/types/index.d.ts +1 -1
  96. package/lib-esm/Cache/types/index.js +1 -1
  97. package/lib-esm/Cache/{Utils → utils}/CacheList.d.ts +1 -1
  98. package/lib-esm/Cache/{Utils → utils}/CacheList.js +1 -1
  99. package/lib-esm/Cache/utils/cacheHelpers.d.ts +14 -0
  100. package/lib-esm/Cache/utils/cacheHelpers.js +44 -0
  101. package/lib-esm/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
  102. package/lib-esm/Cache/{Utils → utils}/errorHelpers.js +0 -4
  103. package/lib-esm/Cache/utils/index.d.ts +2 -0
  104. package/lib-esm/Cache/utils/index.js +4 -0
  105. package/lib-esm/Hub/index.d.ts +7 -0
  106. package/lib-esm/Hub/index.js +7 -0
  107. package/lib-esm/Platform/customUserAgent.d.ts +16 -0
  108. package/lib-esm/Platform/customUserAgent.js +65 -0
  109. package/lib-esm/Platform/index.js +10 -1
  110. package/lib-esm/Platform/types.d.ts +33 -1
  111. package/lib-esm/Platform/types.js +1 -0
  112. package/lib-esm/Platform/version.d.ts +1 -1
  113. package/lib-esm/Platform/version.js +1 -1
  114. package/lib-esm/Reachability/Reachability.d.ts +1 -0
  115. package/lib-esm/Reachability/Reachability.js +36 -0
  116. package/lib-esm/Signer/Signer.js +3 -2
  117. package/lib-esm/awsClients/cognitoIdentity/base.js +2 -1
  118. package/lib-esm/awsClients/pinpoint/base.js +2 -1
  119. package/lib-esm/awsClients/pinpoint/getInAppMessages.js +2 -1
  120. package/lib-esm/awsClients/pinpoint/putEvents.js +2 -1
  121. package/lib-esm/awsClients/pinpoint/updateEndpoint.js +2 -1
  122. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
  123. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
  124. package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
  125. package/lib-esm/index.d.ts +2 -5
  126. package/lib-esm/index.js +1 -4
  127. package/lib-esm/libraryUtils.d.ts +7 -5
  128. package/lib-esm/libraryUtils.js +5 -3
  129. package/lib-esm/parseAWSExports.js +75 -14
  130. package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -2
  131. package/lib-esm/providers/pinpoint/apis/record.js +3 -3
  132. package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +6 -6
  133. package/lib-esm/singleton/API/types.d.ts +4 -3
  134. package/lib-esm/singleton/Amplify.d.ts +2 -2
  135. package/lib-esm/singleton/Amplify.js +6 -5
  136. package/lib-esm/singleton/Auth/types.d.ts +28 -1
  137. package/lib-esm/singleton/Cache/types.d.ts +18 -0
  138. package/lib-esm/singleton/Cache/types.js +3 -0
  139. package/lib-esm/singleton/types.d.ts +3 -1
  140. package/lib-esm/storage/DefaultStorage.js +2 -2
  141. package/lib-esm/storage/utils.d.ts +1 -1
  142. package/lib-esm/storage/utils.js +1 -1
  143. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  144. package/lib-esm/utils/amplifyUrl/index.d.ts +13 -0
  145. package/lib-esm/utils/amplifyUrl/index.js +6 -0
  146. package/lib-esm/utils/amplifyUuid/index.d.ts +3 -0
  147. package/lib-esm/utils/amplifyUuid/index.js +6 -0
  148. package/lib-esm/utils/amplifyUuid/polyfill.native.js +4 -0
  149. package/lib-esm/utils/deepFreeze.d.ts +1 -0
  150. package/lib-esm/utils/deepFreeze.js +34 -0
  151. package/lib-esm/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
  152. package/lib-esm/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +2 -2
  153. package/lib-esm/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
  154. package/lib-esm/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
  155. package/lib-esm/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +2 -2
  156. package/lib-esm/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +4 -14
  157. package/lib-esm/utils/getClientInfo/index.d.ts +1 -0
  158. package/lib-esm/utils/getClientInfo/index.js +3 -0
  159. package/lib-esm/utils/index.d.ts +2 -0
  160. package/lib-esm/utils/index.js +2 -0
  161. package/package.json +7 -17
  162. package/src/Cache/StorageCache.native.ts +65 -0
  163. package/src/Cache/StorageCache.ts +61 -158
  164. package/src/Cache/StorageCacheCommon.ts +581 -0
  165. package/src/Cache/constants.ts +18 -0
  166. package/src/Cache/index.ts +6 -0
  167. package/src/Cache/types/cache.ts +51 -0
  168. package/src/Cache/types/index.ts +1 -1
  169. package/src/Cache/{Utils → utils}/CacheList.ts +185 -185
  170. package/src/Cache/utils/cacheHelpers.ts +52 -0
  171. package/src/Cache/{Utils → utils}/errorHelpers.ts +0 -4
  172. package/src/Cache/{Utils → utils}/index.ts +4 -5
  173. package/src/Hub/index.ts +8 -0
  174. package/src/Platform/customUserAgent.ts +75 -0
  175. package/src/Platform/index.ts +14 -1
  176. package/src/Platform/types.ts +45 -1
  177. package/src/Platform/version.ts +1 -1
  178. package/src/Reachability/Reachability.ts +14 -0
  179. package/src/Signer/Signer.ts +3 -2
  180. package/src/awsClients/cognitoIdentity/base.ts +4 -1
  181. package/src/awsClients/pinpoint/base.ts +2 -1
  182. package/src/awsClients/pinpoint/getInAppMessages.ts +2 -1
  183. package/src/awsClients/pinpoint/putEvents.ts +2 -1
  184. package/src/awsClients/pinpoint/updateEndpoint.ts +2 -1
  185. package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -2
  186. package/src/clients/middleware/signing/signer/signatureV4/presignUrl.ts +2 -1
  187. package/src/index.ts +3 -4
  188. package/src/libraryUtils.ts +17 -10
  189. package/src/parseAWSExports.ts +76 -13
  190. package/src/providers/pinpoint/apis/flushEvents.ts +2 -2
  191. package/src/providers/pinpoint/apis/record.ts +3 -3
  192. package/src/providers/pinpoint/apis/updateEndpoint.ts +6 -6
  193. package/src/singleton/API/types.ts +4 -3
  194. package/src/singleton/Amplify.ts +10 -8
  195. package/src/singleton/Auth/types.ts +50 -1
  196. package/src/singleton/Cache/types.ts +27 -0
  197. package/src/singleton/types.ts +3 -1
  198. package/src/storage/DefaultStorage.ts +2 -2
  199. package/src/storage/utils.ts +1 -1
  200. package/src/utils/amplifyUrl/index.ts +9 -0
  201. package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.ts → utils/amplifyUrl/polyfill.native.ts} +1 -0
  202. package/src/utils/amplifyUuid/index.ts +9 -0
  203. package/src/utils/amplifyUuid/polyfill.native.ts +6 -0
  204. package/src/utils/amplifyUuid/polyfill.ts +4 -0
  205. package/src/utils/deepFreeze.ts +16 -0
  206. package/src/{ClientDevice/android.ts → utils/getClientInfo/getClientInfo.android.ts} +2 -2
  207. package/src/{ClientDevice/ios.ts → utils/getClientInfo/getClientInfo.ios.ts} +3 -3
  208. package/src/{ClientDevice/browser.ts → utils/getClientInfo/getClientInfo.ts} +4 -16
  209. package/src/utils/getClientInfo/index.ts +4 -0
  210. package/src/utils/index.ts +2 -0
  211. package/lib/Cache/BrowserStorageCache.d.ts +0 -166
  212. package/lib/Cache/BrowserStorageCache.js +0 -456
  213. package/lib/Cache/InMemoryCache.d.ts +0 -129
  214. package/lib/Cache/InMemoryCache.js +0 -342
  215. package/lib/Cache/Utils/CacheUtils.d.ts +0 -25
  216. package/lib/Cache/Utils/CacheUtils.js +0 -86
  217. package/lib/Cache/Utils/index.d.ts +0 -2
  218. package/lib/Cache/Utils/index.js +0 -16
  219. package/lib/Cache/reactnative.d.ts +0 -3
  220. package/lib/Cache/reactnative.js +0 -8
  221. package/lib/Cache/types/Cache.d.ts +0 -55
  222. package/lib/ClientDevice/index.d.ts +0 -23
  223. package/lib/ClientDevice/index.js +0 -18
  224. package/lib/ClientDevice/reactnative.d.ts +0 -7
  225. package/lib/ClientDevice/reactnative.js +0 -24
  226. package/lib-esm/Cache/BrowserStorageCache.d.ts +0 -166
  227. package/lib-esm/Cache/BrowserStorageCache.js +0 -453
  228. package/lib-esm/Cache/InMemoryCache.d.ts +0 -129
  229. package/lib-esm/Cache/InMemoryCache.js +0 -339
  230. package/lib-esm/Cache/Utils/CacheUtils.d.ts +0 -25
  231. package/lib-esm/Cache/Utils/CacheUtils.js +0 -79
  232. package/lib-esm/Cache/Utils/index.d.ts +0 -2
  233. package/lib-esm/Cache/Utils/index.js +0 -4
  234. package/lib-esm/Cache/reactnative.d.ts +0 -3
  235. package/lib-esm/Cache/reactnative.js +0 -6
  236. package/lib-esm/Cache/types/Cache.d.ts +0 -55
  237. package/lib-esm/ClientDevice/index.d.ts +0 -23
  238. package/lib-esm/ClientDevice/index.js +0 -15
  239. package/lib-esm/ClientDevice/reactnative.d.ts +0 -7
  240. package/lib-esm/ClientDevice/reactnative.js +0 -21
  241. package/src/Cache/AsyncStorageCache.ts +0 -495
  242. package/src/Cache/BrowserStorageCache.ts +0 -504
  243. package/src/Cache/CHANGELOG.md +0 -1239
  244. package/src/Cache/InMemoryCache.ts +0 -347
  245. package/src/Cache/Utils/CacheUtils.ts +0 -90
  246. package/src/Cache/reactnative.ts +0 -9
  247. package/src/Cache/types/Cache.ts +0 -75
  248. package/src/ClientDevice/index.ts +0 -14
  249. package/src/ClientDevice/reactnative.ts +0 -18
  250. package/lib/Cache/types/{Cache.js → cache.js} +0 -0
  251. package/lib/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +1 -1
  252. /package/lib-esm/Cache/types/{Cache.js → cache.js} +0 -0
  253. /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → utils/amplifyUrl/polyfill.d.ts} +0 -0
  254. /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.js → utils/amplifyUrl/polyfill.js} +0 -0
  255. /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → utils/amplifyUrl/polyfill.native.d.ts} +0 -0
  256. /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +0 -0
  257. /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → lib-esm/utils/amplifyUuid/polyfill.d.ts} +0 -0
  258. /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.js → lib-esm/utils/amplifyUuid/polyfill.js} +0 -0
  259. /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → lib-esm/utils/amplifyUuid/polyfill.native.d.ts} +0 -0
  260. /package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.ts → utils/amplifyUrl/polyfill.ts} +0 -0
@@ -7,6 +7,7 @@ import {
7
7
  signRequest,
8
8
  TOKEN_QUERY_PARAM,
9
9
  } from '../clients/middleware/signing/signer/signatureV4';
10
+ import { AmplifyUrl } from '../utils/amplifyUrl';
10
11
 
11
12
  const IOT_SERVICE_NAME = 'iotdevicegateway';
12
13
  // Best practice regex to parse the service and region from an AWS endpoint
@@ -75,7 +76,7 @@ export class Signer {
75
76
  const requestToSign = {
76
77
  ...request,
77
78
  body: request.data,
78
- url: new URL(request.url),
79
+ url: new AmplifyUrl(request.url),
79
80
  };
80
81
 
81
82
  const options = getOptions(requestToSign, accessInfo, serviceInfo);
@@ -121,7 +122,7 @@ export class Signer {
121
122
  const presignable = {
122
123
  body,
123
124
  method,
124
- url: new URL(urlToSign),
125
+ url: new AmplifyUrl(urlToSign),
125
126
  };
126
127
 
127
128
  const options = getOptions(
@@ -19,6 +19,7 @@ import {
19
19
  } from '../../clients/middleware/retry';
20
20
  import { getAmplifyUserAgent } from '../../Platform';
21
21
  import { observeFrameworkChanges } from '../../Platform/detectFramework';
22
+ import { AmplifyUrl } from '../../utils/amplifyUrl';
22
23
 
23
24
  /**
24
25
  * The service name used to sign requests if the API requires authentication.
@@ -29,7 +30,9 @@ const SERVICE_NAME = 'cognito-identity';
29
30
  * The endpoint resolver function that returns the endpoint URL for a given region.
30
31
  */
31
32
  const endpointResolver = ({ region }: EndpointResolverOptions) => ({
32
- url: new URL(`https://cognito-identity.${region}.${getDnsSuffix(region)}`),
33
+ url: new AmplifyUrl(
34
+ `https://cognito-identity.${region}.${getDnsSuffix(region)}`
35
+ ),
33
36
  });
34
37
 
35
38
  /**
@@ -9,6 +9,7 @@ import {
9
9
  import { parseJsonError } from '../../clients/serde/json';
10
10
  import type { EndpointResolverOptions, Headers } from '../../clients/types';
11
11
  import { getAmplifyUserAgent } from '../../Platform';
12
+ import { AmplifyUrl } from '../../utils/amplifyUrl';
12
13
 
13
14
  /**
14
15
  * The service name used to sign requests if the API requires authentication.
@@ -19,7 +20,7 @@ const SERVICE_NAME = 'mobiletargeting';
19
20
  * The endpoint resolver function that returns the endpoint URL for a given region.
20
21
  */
21
22
  const endpointResolver = ({ region }: EndpointResolverOptions) => ({
22
- url: new URL(`https://pinpoint.${region}.${getDnsSuffix(region)}`),
23
+ url: new AmplifyUrl(`https://pinpoint.${region}.${getDnsSuffix(region)}`),
23
24
  });
24
25
 
25
26
  /**
@@ -15,6 +15,7 @@ import type {
15
15
  GetInAppMessagesCommandInput as GetInAppMessagesInput,
16
16
  GetInAppMessagesCommandOutput as GetInAppMessagesOutput,
17
17
  } from './types';
18
+ import { AmplifyUrl } from '../../utils/amplifyUrl';
18
19
 
19
20
  export type { GetInAppMessagesInput, GetInAppMessagesOutput };
20
21
 
@@ -23,7 +24,7 @@ const getInAppMessagesSerializer = (
23
24
  endpoint: Endpoint
24
25
  ): HttpRequest => {
25
26
  const headers = getSharedHeaders();
26
- const url = new URL(endpoint.url);
27
+ const url = new AmplifyUrl(endpoint.url);
27
28
  url.pathname = `v1/apps/${extendedEncodeURIComponent(
28
29
  ApplicationId
29
30
  )}/endpoints/${extendedEncodeURIComponent(EndpointId)}/inappmessages`;
@@ -16,6 +16,7 @@ import type {
16
16
  PutEventsCommandInput as PutEventsInput,
17
17
  PutEventsCommandOutput as PutEventsOutput,
18
18
  } from './types';
19
+ import { AmplifyUrl } from '../../utils/amplifyUrl';
19
20
 
20
21
  export type { PutEventsInput, PutEventsOutput };
21
22
 
@@ -25,7 +26,7 @@ const putEventsSerializer = (
25
26
  ): HttpRequest => {
26
27
  assert(!!ApplicationId, PinpointValidationErrorCode.NoAppId);
27
28
  const headers = getSharedHeaders();
28
- const url = new URL(endpoint.url);
29
+ const url = new AmplifyUrl(endpoint.url);
29
30
  url.pathname = `v1/apps/${extendedEncodeURIComponent(ApplicationId)}/events`;
30
31
  const body = JSON.stringify(EventsRequest ?? {});
31
32
  return { method: 'POST', headers, url, body };
@@ -15,6 +15,7 @@ import type {
15
15
  UpdateEndpointCommandInput as UpdateEndpointInput,
16
16
  UpdateEndpointCommandOutput as UpdateEndpointOutput,
17
17
  } from './types';
18
+ import { AmplifyUrl } from '../../utils/amplifyUrl';
18
19
 
19
20
  export type { UpdateEndpointInput, UpdateEndpointOutput };
20
21
 
@@ -23,7 +24,7 @@ const updateEndpointSerializer = (
23
24
  endpoint: Endpoint
24
25
  ): HttpRequest => {
25
26
  const headers = getSharedHeaders();
26
- const url = new URL(endpoint.url);
27
+ const url = new AmplifyUrl(endpoint.url);
27
28
  url.pathname = `v1/apps/${extendedEncodeURIComponent(
28
29
  ApplicationId
29
30
  )}/endpoints/${extendedEncodeURIComponent(EndpointId)}`;
@@ -1,8 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import './polyfills';
5
-
6
4
  // TODO: V6 replace Signer
7
5
  export { signRequest } from './signRequest';
8
6
  export { presignUrl } from './presignUrl';
@@ -15,6 +15,7 @@ import {
15
15
  } from './constants';
16
16
  import { getSigningValues } from './utils/getSigningValues';
17
17
  import { getSignature } from './utils/getSignature';
18
+ import { AmplifyUrl } from '../../../../../utils/amplifyUrl';
18
19
 
19
20
  /**
20
21
  * Given a `Presignable` object, returns a Signature Version 4 presigned `URL` object.
@@ -33,7 +34,7 @@ export const presignUrl = (
33
34
 
34
35
  // create the request to sign
35
36
  // @ts-ignore URL constructor accepts a URL object
36
- const presignedUrl = new URL(url);
37
+ const presignedUrl = new AmplifyUrl(url);
37
38
  Object.entries({
38
39
  [ALGORITHM_QUERY_PARAM]: SHA256_ALGORITHM_IDENTIFIER,
39
40
  [CREDENTIAL_QUERY_PARAM]: `${accessKeyId}/${credentialScope}`,
package/src/index.ts CHANGED
@@ -23,6 +23,8 @@ export {
23
23
  AuthConfig,
24
24
  AuthUserPoolConfig,
25
25
  AuthUserPoolAndIdentityPoolConfig,
26
+ APIConfig,
27
+ CacheConfig,
26
28
  StorageAccessLevel,
27
29
  StorageConfig,
28
30
  GetCredentialsOptions,
@@ -59,10 +61,7 @@ export {
59
61
  export { KeyValueStorageInterface } from './types';
60
62
 
61
63
  // Cache exports
62
- import { BrowserStorageCache } from './Cache/BrowserStorageCache';
63
- export { InMemoryCache } from './Cache/InMemoryCache';
64
- export { BrowserStorageCache };
65
- export { BrowserStorageCache as Cache }; // Maintain interoperability with React Native
64
+ export { Cache } from './Cache';
66
65
 
67
66
  // Internationalization utilities
68
67
  export { I18n } from './I18n';
@@ -20,12 +20,9 @@ export {
20
20
  } from './utils';
21
21
  export { parseAWSExports } from './parseAWSExports';
22
22
  export { LegacyConfig } from './singleton/types';
23
- export {
24
- JWT,
25
- StrictUnion,
26
- CognitoIdentityPoolConfig,
27
- JwtPayload,
28
- } from './singleton/Auth/types';
23
+ export { amplifyUuid } from './utils/amplifyUuid';
24
+ export { AmplifyUrl, AmplifyUrlSearchParams } from './utils/amplifyUrl';
25
+
29
26
  // Auth utilities
30
27
  export {
31
28
  decodeJWT,
@@ -34,14 +31,22 @@ export {
34
31
  assertOAuthConfig,
35
32
  } from './singleton/Auth/utils';
36
33
  export { isTokenExpired } from './singleton/Auth';
37
- export { APIAuthMode, DocumentType } from './singleton/API/types';
34
+ export { GraphQLAuthMode, DocumentType } from './singleton/API/types';
38
35
  export { Signer } from './Signer';
36
+ export {
37
+ JWT,
38
+ StrictUnion,
39
+ CognitoIdentityPoolConfig,
40
+ JwtPayload,
41
+ AuthStandardAttributeKey,
42
+ AuthVerifiableAttributeKey,
43
+ AWSCredentials
44
+ } from './singleton/Auth/types';
39
45
 
40
46
  // Logging utilities
41
47
  export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
42
48
 
43
- // Platform & device utils
44
- export { ClientDevice } from './ClientDevice';
49
+ // Platform & user-agent utilities
45
50
  export {
46
51
  Platform,
47
52
  getAmplifyUserAgentObject,
@@ -62,7 +67,9 @@ export {
62
67
  PubSubAction,
63
68
  PushNotificationAction,
64
69
  StorageAction,
70
+ SetCustomUserAgentInput,
65
71
  } from './Platform/types';
72
+ export { setCustomUserAgent } from './Platform/customUserAgent';
66
73
 
67
74
  // Service worker
68
75
  export { ServiceWorker } from './ServiceWorker';
@@ -93,4 +100,4 @@ export { base64Decoder, base64Encoder } from './utils/convert';
93
100
  export { getCrypto } from './utils/globalHelpers';
94
101
 
95
102
  // Hub
96
- export { HubClass } from './Hub';
103
+ export { HubInternal } from './Hub';
@@ -1,7 +1,11 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ConsoleLogger as Logger } from './Logger';
4
- import { OAuthConfig } from './singleton/Auth/types';
4
+ import {
5
+ OAuthConfig,
6
+ AuthStandardAttributeKey,
7
+ AuthConfigUserAttributes,
8
+ } from './singleton/Auth/types';
5
9
  import { ResourcesConfig } from './singleton/types';
6
10
 
7
11
  const logger = new Logger('parseAWSExports');
@@ -34,6 +38,12 @@ export const parseAWSExports = (
34
38
  aws_appsync_region,
35
39
  aws_cognito_identity_pool_id,
36
40
  aws_cognito_sign_up_verification_method,
41
+ aws_cognito_mfa_configuration,
42
+ aws_cognito_mfa_types,
43
+ aws_cognito_password_protection_settings,
44
+ aws_cognito_verification_mechanisms,
45
+ aws_cognito_signup_attributes,
46
+ aws_cognito_username_attributes,
37
47
  aws_mandatory_sign_in,
38
48
  aws_mobile_analytics_app_id,
39
49
  aws_mobile_analytics_app_region,
@@ -93,18 +103,73 @@ export const parseAWSExports = (
93
103
  }
94
104
 
95
105
  // Auth
106
+ const mfaConfig = aws_cognito_mfa_configuration
107
+ ? {
108
+ status:
109
+ aws_cognito_mfa_configuration &&
110
+ aws_cognito_mfa_configuration.toLowerCase(),
111
+ totpEnabled: aws_cognito_mfa_types?.includes('TOTP') ?? false,
112
+ smsEnabled: aws_cognito_mfa_types?.includes('SMS') ?? false,
113
+ }
114
+ : undefined;
115
+ const passwordFormatConfig = aws_cognito_password_protection_settings
116
+ ? {
117
+ minLength:
118
+ aws_cognito_password_protection_settings.passwordPolicyMinLength,
119
+ requireLowercase:
120
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes(
121
+ 'REQUIRES_LOWERCASE'
122
+ ) ?? false,
123
+ requireUppercase:
124
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes(
125
+ 'REQUIRES_UPPERCASE'
126
+ ) ?? false,
127
+ requireNumbers:
128
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes(
129
+ 'REQUIRES_NUMBERS'
130
+ ) ?? false,
131
+ requireSpecialCharacters:
132
+ aws_cognito_password_protection_settings.passwordPolicyCharacters?.includes(
133
+ 'REQUIRES_SYMBOLS'
134
+ ) ?? false,
135
+ }
136
+ : undefined;
137
+ const mergedUserAttributes = Array.from(
138
+ new Set([
139
+ ...(aws_cognito_verification_mechanisms ?? []),
140
+ ...(aws_cognito_signup_attributes ?? []),
141
+ ])
142
+ );
143
+ const userAttributesConfig = mergedUserAttributes.map((s: string) => ({
144
+ [s.toLowerCase()]: {
145
+ required: true, // All user attributes generated by the CLI will be required
146
+ },
147
+ })) as unknown as AuthConfigUserAttributes;
148
+ const loginWithEmailEnabled =
149
+ aws_cognito_username_attributes?.includes('EMAIL') ?? false;
150
+ const loginWithPhoneEnabled =
151
+ aws_cognito_username_attributes?.includes('PHONE_NUMBER') ?? false;
96
152
  if (aws_cognito_identity_pool_id || aws_user_pools_id) {
97
153
  amplifyConfig.Auth = {
98
154
  Cognito: {
99
155
  identityPoolId: aws_cognito_identity_pool_id,
100
156
  allowGuestAccess: aws_mandatory_sign_in !== 'enable',
101
157
  signUpVerificationMethod: aws_cognito_sign_up_verification_method,
158
+ userAttributes: userAttributesConfig,
102
159
  userPoolClientId: aws_user_pools_web_client_id,
103
160
  userPoolId: aws_user_pools_id,
104
- ...(oauth &&
105
- Object.keys(oauth).length > 0 && {
106
- loginWith: getOAuthConfig(oauth),
107
- }),
161
+ mfa: mfaConfig,
162
+ passwordFormat: passwordFormatConfig,
163
+ loginWith: {
164
+ username:
165
+ loginWithEmailEnabled || loginWithPhoneEnabled ? false : true,
166
+ email: loginWithEmailEnabled,
167
+ phone: loginWithPhoneEnabled,
168
+ ...(oauth &&
169
+ Object.keys(oauth).length > 0 && {
170
+ oauth: getOAuthConfig(oauth),
171
+ }),
172
+ },
108
173
  },
109
174
  };
110
175
  }
@@ -168,12 +233,10 @@ const getOAuthConfig = ({
168
233
  redirectSignIn,
169
234
  redirectSignOut,
170
235
  responseType,
171
- }: Record<string, any>): { oauth: OAuthConfig } => ({
172
- oauth: {
173
- domain,
174
- scopes: scope,
175
- redirectSignIn: getRedirectUrl(redirectSignIn),
176
- redirectSignOut: getRedirectUrl(redirectSignOut),
177
- responseType,
178
- },
236
+ }: Record<string, any>): OAuthConfig => ({
237
+ domain,
238
+ scopes: scope,
239
+ redirectSignIn: getRedirectUrl(redirectSignIn),
240
+ redirectSignOut: getRedirectUrl(redirectSignOut),
241
+ responseType,
179
242
  });
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { Credentials } from '@aws-sdk/types';
4
+ import { AWSCredentials } from '../../../libraryUtils';
5
5
  import { getEventBuffer } from '../utils/getEventBuffer';
6
6
  import {
7
7
  BUFFER_SIZE,
@@ -13,7 +13,7 @@ import {
13
13
  export const flushEvents = (
14
14
  appId: string,
15
15
  region: string,
16
- credentials: Credentials,
16
+ credentials: AWSCredentials,
17
17
  identityId?: string,
18
18
  userAgentValue?: string
19
19
  ) => {
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { v4 as uuid } from 'uuid';
4
+ import { amplifyUuid } from '../../../utils/amplifyUuid';
5
5
  import { PinpointRecordInput, PinpointSession } from '../types';
6
6
  import { getEndpointId } from '../utils';
7
7
  import {
@@ -30,7 +30,7 @@ export const record = async ({
30
30
  userAgentValue,
31
31
  }: PinpointRecordInput): Promise<void> => {
32
32
  const timestampISOString = new Date().toISOString();
33
- const eventId = uuid();
33
+ const eventId = amplifyUuid();
34
34
  let endpointId = await getEndpointId(appId, category);
35
35
 
36
36
  // Prepare event buffer if required
@@ -70,7 +70,7 @@ export const record = async ({
70
70
 
71
71
  // Generate session if required
72
72
  if (!session) {
73
- const sessionId = uuid();
73
+ const sessionId = amplifyUuid();
74
74
 
75
75
  session = {
76
76
  Id: sessionId,
@@ -1,8 +1,8 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { v4 as uuidv4 } from 'uuid';
5
- import { ClientDevice } from '../../../ClientDevice';
4
+ import { amplifyUuid } from '../../../utils/amplifyUuid';
5
+ import { getClientInfo } from '../../../utils/getClientInfo';
6
6
  import {
7
7
  updateEndpoint as clientUpdateEndpoint,
8
8
  UpdateEndpointInput,
@@ -29,7 +29,7 @@ export const updateEndpoint = async ({
29
29
  }: PinpointUpdateEndpointInput): Promise<void> => {
30
30
  const endpointId = await getEndpointId(appId, category);
31
31
  // only generate a new endpoint id if one was not found in cache
32
- const createdEndpointId = !endpointId ? uuidv4() : undefined;
32
+ const createdEndpointId = !endpointId ? amplifyUuid() : undefined;
33
33
  const {
34
34
  customProperties,
35
35
  demographic,
@@ -39,7 +39,7 @@ export const updateEndpoint = async ({
39
39
  name,
40
40
  plan,
41
41
  } = userProfile ?? {};
42
- const clientInfo = ClientDevice.clientInfo();
42
+ const clientInfo = getClientInfo();
43
43
  const mergedDemographic = {
44
44
  appVersion: clientInfo.appVersion,
45
45
  make: clientInfo.make,
@@ -59,7 +59,7 @@ export const updateEndpoint = async ({
59
59
  ApplicationId: appId,
60
60
  EndpointId: endpointId ?? createdEndpointId,
61
61
  EndpointRequest: {
62
- RequestId: uuidv4(),
62
+ RequestId: amplifyUuid(),
63
63
  EffectiveDate: new Date().toISOString(),
64
64
  ChannelType: channelType,
65
65
  Address: address,
@@ -93,6 +93,6 @@ export const updateEndpoint = async ({
93
93
  await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);
94
94
  // if we had to create an endpoint id, we need to now cache it
95
95
  if (!!createdEndpointId) {
96
- cacheEndpointId(appId, category, createdEndpointId);
96
+ return cacheEndpointId(appId, category, createdEndpointId);
97
97
  }
98
98
  };
@@ -7,8 +7,9 @@ export type LibraryAPIOptions = {
7
7
  // custom headers for given GraphQL service. Will be applied to all operations.
8
8
  headers?: (options: {
9
9
  query: string;
10
- variables: Record<string, DocumentType>;
10
+ variables?: Record<string, DocumentType>;
11
11
  }) => Promise<Headers>;
12
+ withCredentials?: boolean;
12
13
  };
13
14
  REST?: {
14
15
  // custom headers for given REST service. Will be applied to all operations.
@@ -41,7 +42,7 @@ type APIGraphQLConfig = {
41
42
  /**
42
43
  * Default auth mode for all the API calls to given service.
43
44
  */
44
- defaultAuthMode: APIAuthMode;
45
+ defaultAuthMode: GraphQLAuthMode;
45
46
  };
46
47
 
47
48
  type APIRestConfig = {
@@ -69,7 +70,7 @@ export type APIConfig = {
69
70
  GraphQL?: APIGraphQLConfig;
70
71
  };
71
72
 
72
- export type APIAuthMode =
73
+ export type GraphQLAuthMode =
73
74
  | 'apiKey'
74
75
  | 'oidc'
75
76
  | 'userPool'
@@ -4,24 +4,23 @@ import { AuthClass } from './Auth';
4
4
  import { Hub, AMPLIFY_SYMBOL } from '../Hub';
5
5
  import { LegacyConfig, LibraryOptions, ResourcesConfig } from './types';
6
6
  import { parseAWSExports } from '../parseAWSExports';
7
-
8
- // TODO(v6): add default AuthTokenStore for each platform
7
+ import { deepFreeze } from '../utils';
9
8
 
10
9
  export class AmplifyClass {
11
10
  resourcesConfig: ResourcesConfig;
12
11
  libraryOptions: LibraryOptions;
12
+
13
13
  /**
14
14
  * Cross-category Auth utilities.
15
15
  *
16
16
  * @internal
17
17
  */
18
18
  public readonly Auth: AuthClass;
19
+
19
20
  constructor() {
20
21
  this.resourcesConfig = {};
21
- this.Auth = new AuthClass();
22
-
23
- // TODO(v6): add default providers for getting started
24
22
  this.libraryOptions = {};
23
+ this.Auth = new AuthClass();
25
24
  }
26
25
 
27
26
  /**
@@ -55,6 +54,9 @@ export class AmplifyClass {
55
54
  libraryOptions
56
55
  );
57
56
 
57
+ // Make resource config immutable
58
+ this.resourcesConfig = deepFreeze(this.resourcesConfig);
59
+
58
60
  this.Auth.configure(this.resourcesConfig.Auth!, this.libraryOptions.Auth);
59
61
 
60
62
  Hub.dispatch(
@@ -71,10 +73,10 @@ export class AmplifyClass {
71
73
  /**
72
74
  * Provides access to the current back-end resource configuration for the Library.
73
75
  *
74
- * @returns Returns the current back-end resource configuration.
76
+ * @returns Returns the immutable back-end resource configuration.
75
77
  */
76
- getConfig(): ResourcesConfig {
77
- return JSON.parse(JSON.stringify(this.resourcesConfig));
78
+ getConfig(): Readonly<ResourcesConfig> {
79
+ return this.resourcesConfig;
78
80
  }
79
81
  }
80
82
 
@@ -70,6 +70,33 @@ export type AuthTokens = {
70
70
  accessToken: JWT;
71
71
  };
72
72
 
73
+ export type AuthStandardAttributeKey =
74
+ | 'address'
75
+ | 'birthdate'
76
+ | 'email_verified'
77
+ | 'family_name'
78
+ | 'gender'
79
+ | 'given_name'
80
+ | 'locale'
81
+ | 'middle_name'
82
+ | 'name'
83
+ | 'nickname'
84
+ | 'phone_number_verified'
85
+ | 'picture'
86
+ | 'preferred_username'
87
+ | 'profile'
88
+ | 'sub'
89
+ | 'updated_at'
90
+ | 'website'
91
+ | 'zoneinfo'
92
+ | AuthVerifiableAttributeKey;
93
+
94
+ export type AuthVerifiableAttributeKey = 'email' | 'phone_number';
95
+
96
+ export type AuthConfigUserAttributes = Partial<
97
+ Record<AuthStandardAttributeKey, { required: boolean }>
98
+ >;
99
+
73
100
  export type AuthConfig = StrictUnion<
74
101
  | AuthIdentityPoolConfig
75
102
  | AuthUserPoolConfig
@@ -87,6 +114,11 @@ export type AuthIdentityPoolConfig = {
87
114
  userPoolClientId?: never;
88
115
  userPoolId?: never;
89
116
  loginWith?: never;
117
+ signUpVerificationMethod?: never;
118
+ userAttributes?: never;
119
+ mfa?: never;
120
+ passwordFormat?: never;
121
+ endpoint?: never;
90
122
  };
91
123
  };
92
124
 
@@ -108,7 +140,24 @@ export type CognitoUserPoolConfig = {
108
140
  signUpVerificationMethod?: 'code' | 'link';
109
141
  loginWith?: {
110
142
  oauth?: OAuthConfig;
143
+ username?: boolean;
144
+ email?: boolean;
145
+ phone?: boolean;
146
+ };
147
+ userAttributes?: AuthConfigUserAttributes;
148
+ mfa?: {
149
+ status?: 'on' | 'off' | 'optional';
150
+ totpEnabled?: boolean;
151
+ smsEnabled?: boolean;
152
+ };
153
+ passwordFormat?: {
154
+ minLength?: number;
155
+ requireLowercase?: boolean;
156
+ requireUppercase?: boolean;
157
+ requireNumbers?: boolean;
158
+ requireSpecialCharacters?: boolean;
111
159
  };
160
+ endpoint?: string;
112
161
  };
113
162
 
114
163
  export type OAuthConfig = {
@@ -168,7 +217,7 @@ export type AWSCredentialsAndIdentityId = {
168
217
  identityId?: string;
169
218
  };
170
219
 
171
- type AWSCredentials = {
220
+ export type AWSCredentials = {
172
221
  accessKeyId: string;
173
222
  secretAccessKey: string;
174
223
  sessionToken?: string;
@@ -0,0 +1,27 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Cache instance options
6
+ */
7
+ export interface CacheConfig {
8
+ /** Prepend to key to avoid conflicts */
9
+ keyPrefix: string;
10
+
11
+ /** Cache capacity, in bytes */
12
+ capacityInBytes: number;
13
+
14
+ /** Max size of one item */
15
+ itemMaxSize: number;
16
+
17
+ /** Time to live, in milliseconds */
18
+ defaultTTL: number;
19
+
20
+ /** Warn when over threshold percentage of capacity, maximum 1 */
21
+ warningThreshold: number;
22
+
23
+ /** default priority number put on cached items */
24
+ defaultPriority: number;
25
+
26
+ storage?: Storage;
27
+ }
@@ -12,6 +12,7 @@ import {
12
12
  GetCredentialsOptions,
13
13
  CognitoIdentityPoolConfig,
14
14
  } from './Auth/types';
15
+ import { CacheConfig } from './Cache/types';
15
16
  import { GeoConfig } from './Geo/types';
16
17
  import {
17
18
  LibraryStorageOptions,
@@ -32,7 +33,7 @@ export type ResourcesConfig = {
32
33
  API?: APIConfig;
33
34
  Analytics?: AnalyticsConfig;
34
35
  Auth?: AuthConfig;
35
- // Cache?: CacheConfig;
36
+ Cache?: CacheConfig;
36
37
  // DataStore?: {};
37
38
  I18n?: I18nConfig;
38
39
  // Interactions?: {};
@@ -55,6 +56,7 @@ export {
55
56
  AuthUserPoolConfig,
56
57
  AuthIdentityPoolConfig,
57
58
  AuthUserPoolAndIdentityPoolConfig,
59
+ CacheConfig,
58
60
  GetCredentialsOptions,
59
61
  StorageAccessLevel,
60
62
  StorageConfig,
@@ -2,13 +2,13 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { KeyValueStorage } from './KeyValueStorage';
5
- import { getDefaultStorageWithFallback } from './utils';
5
+ import { getLocalStorageWithFallback } from './utils';
6
6
 
7
7
  /**
8
8
  * @internal
9
9
  */
10
10
  export class DefaultStorage extends KeyValueStorage {
11
11
  constructor() {
12
- super(getDefaultStorageWithFallback());
12
+ super(getLocalStorageWithFallback());
13
13
  }
14
14
  }
@@ -7,7 +7,7 @@ import { InMemoryStorage } from './InMemoryStorage';
7
7
  * @internal
8
8
  * @returns Either a reference to window.localStorage or an in-memory storage as fallback
9
9
  */
10
- export const getDefaultStorageWithFallback = (): Storage =>
10
+ export const getLocalStorageWithFallback = (): Storage =>
11
11
  typeof window !== 'undefined' && window.localStorage
12
12
  ? window.localStorage
13
13
  : new InMemoryStorage();