@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
@@ -0,0 +1,13 @@
1
+ import './polyfill';
2
+ declare const AmplifyUrl: {
3
+ new (url: string | URL, base?: string | URL | undefined): URL;
4
+ prototype: URL;
5
+ createObjectURL(obj: Blob | MediaSource): string;
6
+ revokeObjectURL(url: string): void;
7
+ };
8
+ declare const AmplifyUrlSearchParams: {
9
+ new (init?: string | URLSearchParams | Record<string, string> | string[][] | undefined): URLSearchParams;
10
+ prototype: URLSearchParams;
11
+ toString(): string;
12
+ };
13
+ export { AmplifyUrl, AmplifyUrlSearchParams };
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import './polyfill';
4
+ var AmplifyUrl = URL;
5
+ var AmplifyUrlSearchParams = URLSearchParams;
6
+ export { AmplifyUrl, AmplifyUrlSearchParams };
@@ -0,0 +1,3 @@
1
+ import './polyfill';
2
+ declare const amplifyUuid: (<T extends ArrayLike<number>>(options: import("uuid").V4Options | null | undefined, buffer: T, offset?: number | undefined) => T) & ((options?: import("uuid").V4Options | undefined) => string);
3
+ export { amplifyUuid };
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import './polyfill';
4
+ import { v4 } from 'uuid';
5
+ var amplifyUuid = v4;
6
+ export { amplifyUuid };
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { loadGetRandomValues } from '@aws-amplify/react-native';
4
+ loadGetRandomValues();
@@ -0,0 +1 @@
1
+ export declare const deepFreeze: (object: any) => any;
@@ -0,0 +1,34 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var __values = (this && this.__values) || function(o) {
4
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
5
+ if (m) return m.call(o);
6
+ if (o && typeof o.length === "number") return {
7
+ next: function () {
8
+ if (o && i >= o.length) o = void 0;
9
+ return { value: o && o[i++], done: !o };
10
+ }
11
+ };
12
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
13
+ };
14
+ export var deepFreeze = function (object) {
15
+ var e_1, _a;
16
+ var propNames = Reflect.ownKeys(object);
17
+ try {
18
+ for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
19
+ var name_1 = propNames_1_1.value;
20
+ var value = object[name_1];
21
+ if ((value && typeof value === "object") || typeof value === "function") {
22
+ deepFreeze(value);
23
+ }
24
+ }
25
+ }
26
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
27
+ finally {
28
+ try {
29
+ if (propNames_1_1 && !propNames_1_1.done && (_a = propNames_1.return)) _a.call(propNames_1);
30
+ }
31
+ finally { if (e_1) throw e_1.error; }
32
+ }
33
+ return Object.freeze(object);
34
+ };
@@ -1,4 +1,4 @@
1
- export declare const clientInfo: () => {
1
+ export declare const getClientInfo: () => {
2
2
  platform: string;
3
3
  version: string;
4
4
  appVersion: string;
@@ -2,9 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // @ts-ignore: missing type definition
4
4
  import { Platform, Dimensions } from 'react-native';
5
- import { ConsoleLogger as Logger } from '../Logger';
5
+ import { ConsoleLogger as Logger } from '../../Logger';
6
6
  var logger = new Logger('DeviceInfo');
7
- export var clientInfo = function () {
7
+ export var getClientInfo = function () {
8
8
  var dim = Dimensions.get('screen');
9
9
  logger.debug(Platform, dim);
10
10
  var OS = 'android';
@@ -1,4 +1,4 @@
1
- export declare function clientInfo(): {
1
+ export declare function getClientInfo(): {
2
2
  platform?: undefined;
3
3
  make?: undefined;
4
4
  model?: undefined;
@@ -15,11 +15,3 @@ export declare function clientInfo(): {
15
15
  language: string;
16
16
  timezone: string;
17
17
  };
18
- export declare function dimension(): {
19
- width: number;
20
- height: number;
21
- };
22
- export declare function browserType(userAgent: string): {
23
- type: string;
24
- version: string;
25
- };
@@ -1,4 +1,4 @@
1
- export declare const clientInfo: () => {
1
+ export declare const getClientInfo: () => {
2
2
  platform: string;
3
3
  version: string;
4
4
  appVersion: string;
@@ -2,9 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // @ts-ignore: missing type definition
4
4
  import { Platform, Dimensions } from 'react-native';
5
- import { ConsoleLogger as Logger } from '../Logger';
5
+ import { ConsoleLogger as Logger } from '../../Logger';
6
6
  var logger = new Logger('DeviceInfo');
7
- export var clientInfo = function () {
7
+ export var getClientInfo = function () {
8
8
  var dim = Dimensions.get('screen');
9
9
  logger.debug(Platform, dim);
10
10
  var OS = 'ios';
@@ -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
- import { ConsoleLogger as Logger } from '../Logger';
3
+ import { ConsoleLogger as Logger } from '../../Logger';
4
4
  var logger = new Logger('ClientDevice_Browser');
5
- export function clientInfo() {
5
+ export function getClientInfo() {
6
6
  if (typeof window === 'undefined') {
7
7
  return {};
8
8
  }
@@ -19,7 +19,7 @@ function browserClientInfo() {
19
19
  return {};
20
20
  }
21
21
  var platform = nav.platform, product = nav.product, vendor = nav.vendor, userAgent = nav.userAgent, language = nav.language;
22
- var type = browserType(userAgent);
22
+ var type = getBrowserType(userAgent);
23
23
  var timezone = browserTimezone();
24
24
  return {
25
25
  platform: platform,
@@ -31,21 +31,11 @@ function browserClientInfo() {
31
31
  timezone: timezone,
32
32
  };
33
33
  }
34
- export function dimension() {
35
- if (typeof window === 'undefined') {
36
- logger.warn('No window object available to get browser client info');
37
- return { width: 320, height: 320 };
38
- }
39
- return {
40
- width: window.innerWidth,
41
- height: window.innerHeight,
42
- };
43
- }
44
34
  function browserTimezone() {
45
35
  var tzMatch = /\(([A-Za-z\s].*)\)/.exec(new Date().toString());
46
36
  return tzMatch ? tzMatch[1] || '' : '';
47
37
  }
48
- export function browserType(userAgent) {
38
+ function getBrowserType(userAgent) {
49
39
  var operaMatch = /.+(Opera[\s[A-Z]*|OPR[\sA-Z]*)\/([0-9\.]+).*/i.exec(userAgent);
50
40
  if (operaMatch) {
51
41
  return { type: operaMatch[1], version: operaMatch[2] };
@@ -0,0 +1 @@
1
+ export { getClientInfo } from './getClientInfo';
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { getClientInfo } from './getClientInfo';
@@ -1,6 +1,8 @@
1
1
  export { generateRandomString } from './generateRandomString';
2
+ export { getClientInfo } from './getClientInfo';
2
3
  export { isBrowser } from './isBrowser';
3
4
  export { isWebWorker } from './isWebWorker';
4
5
  export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './retry';
5
6
  export { urlSafeDecode } from './urlSafeDecode';
6
7
  export { urlSafeEncode } from './urlSafeEncode';
8
+ export { deepFreeze } from './deepFreeze';
@@ -1,8 +1,10 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export { generateRandomString } from './generateRandomString';
4
+ export { getClientInfo } from './getClientInfo';
4
5
  export { isBrowser } from './isBrowser';
5
6
  export { isWebWorker } from './isWebWorker';
6
7
  export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './retry';
7
8
  export { urlSafeDecode } from './urlSafeDecode';
8
9
  export { urlSafeEncode } from './urlSafeEncode';
10
+ export { deepFreeze } from './deepFreeze';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.0.1-console-preview.5f040a2.0+5f040a2",
3
+ "version": "6.0.1-console-preview.23dc225.0+23dc225",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -13,10 +13,8 @@
13
13
  "./lib/Credentials.js",
14
14
  "./lib-esm/I18n/index.js",
15
15
  "./lib-esm/Credentials.js",
16
- "./lib/Cache/BrowserStorageCache.js",
17
- "./lib/Cache/AsyncStorageCache.js",
18
- "./lib-esm/Cache/BrowserStorageCache.js",
19
- "./lib-esm/Cache/AsyncStorageCache.js"
16
+ "./lib/Cache/index.js",
17
+ "./lib-esm/Cache/index.js"
20
18
  ],
21
19
  "scripts": {
22
20
  "test": "npm run lint && jest -w 1 --coverage",
@@ -36,9 +34,7 @@
36
34
  "ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 92.36"
37
35
  },
38
36
  "react-native": {
39
- "./lib/index": "./lib-esm/index.js",
40
- "./lib-esm/ClientDevice": "./lib-esm/ClientDevice/reactnative.js",
41
- "./lib-esm/Cache": "./lib-esm/Cache/reactnative.js"
37
+ "./lib/index": "./lib-esm/index.js"
42
38
  },
43
39
  "repository": {
44
40
  "type": "git",
@@ -68,7 +64,7 @@
68
64
  "uuid": "^9.0.0"
69
65
  },
70
66
  "devDependencies": {
71
- "@aws-amplify/react-native": "1.0.1-console-preview.5f040a2.0+5f040a2",
67
+ "@aws-amplify/react-native": "1.0.1-console-preview.23dc225.0+23dc225",
72
68
  "@types/js-cookie": "^2.2.7",
73
69
  "@types/uuid": "^9.0.0",
74
70
  "find": "^0.2.7",
@@ -86,7 +82,7 @@
86
82
  "name": "Core (I18n)",
87
83
  "path": "./lib-esm/index.js",
88
84
  "import": "{ I18n }",
89
- "limit": "5.48 kB"
85
+ "limit": "5.60 kB"
90
86
  },
91
87
  {
92
88
  "name": "Custom clients (fetch handler)",
@@ -129,12 +125,6 @@
129
125
  "path": "./lib-esm/index.js",
130
126
  "import": "{ Cache }",
131
127
  "limit": "4.13 kB"
132
- },
133
- {
134
- "name": "Cache (in-memory)",
135
- "path": "./lib-esm/index.js",
136
- "import": "{ InMemoryCache }",
137
- "limit": "4.15 kB"
138
128
  }
139
129
  ],
140
130
  "jest": {
@@ -179,5 +169,5 @@
179
169
  "lib-esm"
180
170
  ]
181
171
  },
182
- "gitHead": "5f040a29ecebf29374ae9b58abc661f45143ac4f"
172
+ "gitHead": "23dc22531b963319f2b421f6f7c6cf867635b20e"
183
173
  }
@@ -0,0 +1,65 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { loadAsyncStorage } from '@aws-amplify/react-native';
5
+ import { ConsoleLogger as Logger } from '../Logger';
6
+ import { defaultConfig } from './constants';
7
+ import { StorageCacheCommon } from './StorageCacheCommon';
8
+ import { Cache, CacheConfig } from './types';
9
+ import { getCurrentSizeKey, getCurrentTime } from './utils';
10
+
11
+ const logger = new Logger('StorageCache');
12
+ const AsyncStorage = loadAsyncStorage();
13
+
14
+ /*
15
+ * Customized cache which based on the AsyncStorage with LRU implemented
16
+ */
17
+ export class StorageCache extends StorageCacheCommon implements Cache {
18
+ /**
19
+ * initialize the cache
20
+ * @param config - the configuration of the cache
21
+ */
22
+ constructor(config?: CacheConfig) {
23
+ super({ config, keyValueStorage: AsyncStorage });
24
+
25
+ this.getItem = this.getItem.bind(this);
26
+ this.setItem = this.setItem.bind(this);
27
+ this.removeItem = this.removeItem.bind(this);
28
+ }
29
+
30
+ protected async getAllCacheKeys(options?: { omitSizeKey?: boolean }) {
31
+ const { omitSizeKey } = options ?? {};
32
+ const keys: string[] = [];
33
+ for (const key of await AsyncStorage.getAllKeys()) {
34
+ if (omitSizeKey && key === getCurrentSizeKey(this.config.keyPrefix)) {
35
+ continue;
36
+ }
37
+ if (key?.startsWith(this.config.keyPrefix)) {
38
+ keys.push(key.substring(this.config.keyPrefix.length));
39
+ }
40
+ }
41
+ return keys;
42
+ }
43
+
44
+ protected async getAllStorageKeys() {
45
+ try {
46
+ return AsyncStorage.getAllKeys();
47
+ } catch (e) {
48
+ logger.warn(`getAllKeys failed! ${e}`);
49
+ return [];
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Return a new instance of cache with customized configuration.
55
+ * @param {Object} config - the customized configuration
56
+ * @return {Object} - the new instance of Cache
57
+ */
58
+ public createInstance(config: CacheConfig): Cache {
59
+ if (!config.keyPrefix || config.keyPrefix === defaultConfig.keyPrefix) {
60
+ logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
61
+ config.keyPrefix = getCurrentTime.toString();
62
+ }
63
+ return new StorageCache(config);
64
+ }
65
+ }
@@ -1,158 +1,61 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { getCurrTime, getByteLength, defaultConfig } from './Utils';
5
- import { Amplify } from '../singleton';
6
- import { CacheConfig, CacheItem, CacheItemOptions } from './types';
7
- import { ConsoleLogger as Logger } from '../Logger';
8
-
9
- const logger = new Logger('StorageCache');
10
-
11
- /**
12
- * Initialization of the cache
13
- *
14
- */
15
- export class StorageCache {
16
- // Contains any fields that have been customized for this Cache instance (i.e. without default values)
17
- private instanceConfig?: CacheConfig;
18
-
19
- /**
20
- * Initialize the cache
21
- *
22
- * @param config - Custom configuration for this instance.
23
- */
24
- constructor(config?: CacheConfig) {
25
- if (config) {
26
- // A configuration was specified for this specific instance
27
- this.instanceConfig = config;
28
- }
29
-
30
- this.sanitizeConfig();
31
- }
32
-
33
- public getModuleName() {
34
- return 'Cache';
35
- }
36
-
37
- private sanitizeConfig(): void {
38
- const tempInstanceConfig = this.instanceConfig || ({} as CacheConfig);
39
-
40
- if (this.cacheConfig.itemMaxSize > this.cacheConfig.capacityInBytes) {
41
- logger.error(
42
- 'Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.'
43
- );
44
- tempInstanceConfig.itemMaxSize = defaultConfig.itemMaxSize;
45
- }
46
-
47
- if (
48
- this.cacheConfig.defaultPriority > 5 ||
49
- this.cacheConfig.defaultPriority < 1
50
- ) {
51
- logger.error(
52
- 'Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.'
53
- );
54
- tempInstanceConfig.defaultPriority = defaultConfig.defaultPriority;
55
- }
56
-
57
- if (
58
- Number(this.cacheConfig.warningThreshold) > 1 ||
59
- Number(this.cacheConfig.warningThreshold) < 0
60
- ) {
61
- logger.error(
62
- 'Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.'
63
- );
64
- tempInstanceConfig.warningThreshold = defaultConfig.warningThreshold;
65
- }
66
-
67
- // Set 5MB limit
68
- const cacheLimit: number = 5 * 1024 * 1024;
69
- if (this.cacheConfig.capacityInBytes > cacheLimit) {
70
- logger.error(
71
- 'Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.'
72
- );
73
- tempInstanceConfig.capacityInBytes = defaultConfig.capacityInBytes;
74
- }
75
-
76
- // Apply sanitized values to the instance config
77
- if (Object.keys(tempInstanceConfig).length > 0) {
78
- this.instanceConfig = tempInstanceConfig;
79
- }
80
- }
81
-
82
- /**
83
- * produce a JSON object with meta-data and data value
84
- * @param value - the value of the item
85
- * @param options - optional, the specified meta-data
86
- *
87
- * @return - the item which has the meta-data and the value
88
- */
89
- protected fillCacheItem(
90
- key: string,
91
- value: object | number | string | boolean,
92
- options: CacheItemOptions
93
- ): CacheItem {
94
- const ret: CacheItem = {
95
- key,
96
- data: value,
97
- timestamp: getCurrTime(),
98
- visitedTime: getCurrTime(),
99
- priority: options.priority ?? 0,
100
- expires: options.expires ?? 0,
101
- type: typeof value,
102
- byteSize: 0,
103
- };
104
-
105
- ret.byteSize = getByteLength(JSON.stringify(ret));
106
-
107
- // for accurate size
108
- ret.byteSize = getByteLength(JSON.stringify(ret));
109
- return ret;
110
- }
111
-
112
- /**
113
- * Set custom configuration for the cache instance.
114
- *
115
- * @param config - customized configuration (without keyPrefix, which can't be changed)
116
- *
117
- * @return - the current configuration
118
- */
119
- public configure(config?: Omit<CacheConfig, 'keyPrefix'>): CacheConfig {
120
- if (config) {
121
- if ((config as CacheConfig).keyPrefix) {
122
- logger.warn(
123
- 'keyPrefix can not be re-configured on an existing Cache instance.'
124
- );
125
- }
126
-
127
- this.instanceConfig = this.instanceConfig
128
- ? Object.assign({}, this.instanceConfig, config)
129
- : (config as CacheConfig);
130
- }
131
-
132
- this.sanitizeConfig();
133
-
134
- return this.cacheConfig;
135
- }
136
-
137
- /**
138
- * Returns an appropriate configuration for the Cache instance. Will apply any custom configuration for this
139
- * instance on top of the global configuration. Default configuration will be applied in all cases.
140
- *
141
- * @internal
142
- */
143
- protected get cacheConfig(): CacheConfig {
144
- // const globalCacheConfig = Amplify.getConfig().Cache || {};
145
- const globalCacheConfig = {};
146
-
147
- if (this.instanceConfig) {
148
- return Object.assign(
149
- {},
150
- defaultConfig,
151
- globalCacheConfig,
152
- this.instanceConfig
153
- );
154
- } else {
155
- return Object.assign({}, defaultConfig, globalCacheConfig);
156
- }
157
- }
158
- }
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ConsoleLogger as Logger } from '../Logger';
5
+ import { KeyValueStorage } from '../storage/KeyValueStorage';
6
+ import { getLocalStorageWithFallback } from '../storage/utils';
7
+ import { defaultConfig } from './constants';
8
+ import { StorageCacheCommon } from './StorageCacheCommon';
9
+ import { Cache, CacheConfig } from './types';
10
+ import { getCurrentSizeKey, getCurrentTime } from './utils';
11
+
12
+ const logger = new Logger('Cache');
13
+
14
+ /**
15
+ * Customized storage based on the SessionStorage or LocalStorage with LRU implemented
16
+ */
17
+ export class StorageCache extends StorageCacheCommon implements Cache {
18
+ storage: Storage;
19
+ /**
20
+ * initialize the cache
21
+ * @param config - the configuration of the cache
22
+ */
23
+ constructor(config?: CacheConfig) {
24
+ const storage = getLocalStorageWithFallback();
25
+ super({ config, keyValueStorage: new KeyValueStorage(storage) });
26
+
27
+ this.storage = storage;
28
+ this.getItem = this.getItem.bind(this);
29
+ this.setItem = this.setItem.bind(this);
30
+ this.removeItem = this.removeItem.bind(this);
31
+ }
32
+
33
+ protected async getAllCacheKeys(options?: { omitSizeKey?: boolean }) {
34
+ const { omitSizeKey } = options ?? {};
35
+ const keys: string[] = [];
36
+ for (let i = 0; i < this.storage.length; i++) {
37
+ const key = this.storage.key(i);
38
+ if (omitSizeKey && key === getCurrentSizeKey(this.config.keyPrefix)) {
39
+ continue;
40
+ }
41
+ if (key?.startsWith(this.config.keyPrefix)) {
42
+ keys.push(key.substring(this.config.keyPrefix.length));
43
+ }
44
+ }
45
+ return keys;
46
+ }
47
+
48
+ /**
49
+ * Return a new instance of cache with customized configuration.
50
+ * @param {Object} config - the customized configuration
51
+ * @return {Object} - the new instance of Cache
52
+ */
53
+ public createInstance(config: CacheConfig): Cache {
54
+ if (!config.keyPrefix || config.keyPrefix === defaultConfig.keyPrefix) {
55
+ logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
56
+ config.keyPrefix = getCurrentTime.toString();
57
+ }
58
+
59
+ return new StorageCache(config);
60
+ }
61
+ }