@aws-amplify/core 5.8.2 → 6.0.1-console-preview.7919075.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 (300) hide show
  1. package/README.md +3 -0
  2. package/lib/Amplify.d.ts +18 -17
  3. package/lib/Amplify.js +9 -0
  4. package/lib/AwsClients/CognitoIdentity/base.d.ts +3 -10
  5. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
  6. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
  7. package/lib/AwsClients/CognitoIdentity/getId.d.ts +3 -17
  8. package/lib/AwsClients/Pinpoint/base.d.ts +2 -10
  9. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
  10. package/lib/AwsClients/Pinpoint/getInAppMessages.js +1 -1
  11. package/lib/AwsClients/Pinpoint/putEvents.d.ts +3 -17
  12. package/lib/AwsClients/Pinpoint/putEvents.js +6 -0
  13. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
  14. package/lib/AwsClients/Pinpoint/updateEndpoint.js +2 -2
  15. package/lib/Cache/AsyncStorageCache.d.ts +154 -0
  16. package/lib/Cache/AsyncStorageCache.js +744 -0
  17. package/lib/Cache/BrowserStorageCache.d.ts +166 -0
  18. package/lib/Cache/BrowserStorageCache.js +469 -0
  19. package/lib/Cache/InMemoryCache.d.ts +129 -0
  20. package/lib/Cache/InMemoryCache.js +349 -0
  21. package/lib/Cache/StorageCache.d.ts +39 -0
  22. package/lib/Cache/StorageCache.js +121 -0
  23. package/lib/Cache/Utils/CacheList.d.ts +89 -0
  24. package/lib/Cache/Utils/CacheList.js +196 -0
  25. package/lib/Cache/Utils/CacheUtils.d.ts +25 -0
  26. package/lib/Cache/Utils/CacheUtils.js +88 -0
  27. package/lib/Cache/Utils/index.d.ts +2 -0
  28. package/lib/Cache/Utils/index.js +16 -0
  29. package/lib/Cache/reactnative.d.ts +3 -0
  30. package/lib/Cache/reactnative.js +8 -0
  31. package/lib/Cache/types/Cache.d.ts +55 -0
  32. package/lib/Cache/types/Cache.js +4 -0
  33. package/lib/Cache/types/index.d.ts +1 -0
  34. package/lib/Cache/types/index.js +19 -0
  35. package/lib/ClientDevice/android.js +3 -2
  36. package/lib/ClientDevice/ios.d.ts +2 -2
  37. package/lib/ClientDevice/ios.js +3 -2
  38. package/lib/ClientDevice/reactnative.js +3 -2
  39. package/lib/Credentials.d.ts +1 -1
  40. package/lib/Credentials.js +2 -1
  41. package/lib/Errors.d.ts +19 -0
  42. package/lib/Errors.js +50 -1
  43. package/lib/Hub.js +1 -0
  44. package/lib/I18n/I18n.d.ts +29 -9
  45. package/lib/I18n/I18n.js +30 -5
  46. package/lib/I18n/index.d.ts +18 -5
  47. package/lib/I18n/index.js +35 -5
  48. package/lib/I18n/types.d.ts +4 -1
  49. package/lib/I18n/types.js +3 -0
  50. package/lib/JS.d.ts +6 -6
  51. package/lib/Logger/ConsoleLogger.d.ts +11 -11
  52. package/lib/OAuthHelper/GoogleOAuth.js +2 -1
  53. package/lib/Platform/detectFramework.js +2 -1
  54. package/lib/Platform/detection/Next.d.ts +1 -1
  55. package/lib/Platform/detection/React.js +1 -0
  56. package/lib/Platform/version.d.ts +1 -1
  57. package/lib/Platform/version.js +1 -1
  58. package/lib/Providers/AWSCloudWatchProvider.d.ts +2 -2
  59. package/lib/Providers/AWSCloudWatchProvider.js +35 -12
  60. package/lib/RNComponents/index.d.ts +1 -1
  61. package/lib/RNComponents/reactnative.js +3 -2
  62. package/lib/ServiceWorker/ServiceWorker.d.ts +4 -4
  63. package/lib/ServiceWorker/ServiceWorker.js +37 -11
  64. package/lib/Signer.d.ts +14 -1
  65. package/lib/StorageHelper/cookieStorage.d.ts +13 -0
  66. package/lib/StorageHelper/cookieStorage.js +167 -0
  67. package/lib/StorageHelper/inMemoryStorage.d.ts +10 -0
  68. package/lib/StorageHelper/inMemoryStorage.js +82 -0
  69. package/lib/StorageHelper/index.d.ts +7 -3
  70. package/lib/StorageHelper/index.js +9 -1
  71. package/lib/StorageHelper/localStorage.d.ts +32 -0
  72. package/lib/StorageHelper/localStorage.js +114 -0
  73. package/lib/StorageHelper/reactnative.d.ts +71 -1
  74. package/lib/StorageHelper/reactnative.js +154 -10
  75. package/lib/StorageHelper/sessionStorage.d.ts +32 -0
  76. package/lib/StorageHelper/sessionStorage.js +114 -0
  77. package/lib/UniversalStorage/index.d.ts +2 -2
  78. package/lib/Util/BackgroundProcessManager.d.ts +2 -2
  79. package/lib/Util/BackgroundProcessManager.js +1 -0
  80. package/lib/Util/DateUtils.d.ts +12 -1
  81. package/lib/Util/Reachability.js +7 -5
  82. package/lib/Util/Reachability.native.d.ts +3 -2
  83. package/lib/Util/StringUtils.js +3 -10
  84. package/lib/Util/errors/AssertError.d.ts +2 -0
  85. package/lib/Util/errors/AssertError.js +11 -0
  86. package/lib/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
  87. package/lib/clients/middleware/retry/defaultRetryDecider.js +17 -13
  88. package/lib/clients/middleware/retry/isClockSkewError.js +1 -1
  89. package/lib/clients/middleware/retry/middleware.d.ts +1 -1
  90. package/lib/clients/middleware/retry/middleware.js +13 -13
  91. package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
  92. package/lib/clients/serde/responseInfo.js +1 -1
  93. package/lib/clients/types/aws.d.ts +4 -0
  94. package/lib/clients/types/index.d.ts +1 -1
  95. package/lib/constants.d.ts +7 -0
  96. package/lib/constants.js +9 -1
  97. package/lib/index.d.ts +18 -4
  98. package/lib/index.js +32 -5
  99. package/lib/parseAWSExports.d.ts +1 -1
  100. package/lib/singleton/Auth/index.d.ts +30 -0
  101. package/lib/singleton/Auth/index.js +133 -0
  102. package/lib/singleton/Auth/types.d.ts +95 -0
  103. package/lib/singleton/Auth/types.js +6 -0
  104. package/lib/singleton/Auth/utils/index.d.ts +5 -0
  105. package/lib/singleton/Auth/utils/index.js +52 -0
  106. package/lib/singleton/Storage/types.d.ts +14 -0
  107. package/lib/singleton/Storage/types.js +4 -0
  108. package/lib/singleton/index.d.ts +46 -0
  109. package/lib/singleton/index.js +160 -0
  110. package/lib/singleton/types.d.ts +21 -0
  111. package/lib/singleton/types.js +4 -0
  112. package/lib/tsconfig.tsbuildinfo +1 -1
  113. package/lib/types/types.d.ts +31 -1
  114. package/lib/types/types.js +2 -0
  115. package/lib-esm/Amplify.d.ts +18 -17
  116. package/lib-esm/Amplify.js +9 -0
  117. package/lib-esm/AwsClients/CognitoIdentity/base.d.ts +3 -10
  118. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +3 -17
  119. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.js +8 -8
  120. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +3 -17
  121. package/lib-esm/AwsClients/Pinpoint/base.d.ts +2 -10
  122. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +3 -17
  123. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.js +1 -1
  124. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +3 -17
  125. package/lib-esm/AwsClients/Pinpoint/putEvents.js +6 -0
  126. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +3 -17
  127. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.js +2 -2
  128. package/lib-esm/Cache/AsyncStorageCache.d.ts +154 -0
  129. package/lib-esm/Cache/AsyncStorageCache.js +737 -0
  130. package/lib-esm/Cache/BrowserStorageCache.d.ts +166 -0
  131. package/lib-esm/Cache/BrowserStorageCache.js +466 -0
  132. package/lib-esm/Cache/InMemoryCache.d.ts +129 -0
  133. package/lib-esm/Cache/InMemoryCache.js +346 -0
  134. package/lib-esm/Cache/StorageCache.d.ts +39 -0
  135. package/lib-esm/Cache/StorageCache.js +118 -0
  136. package/lib-esm/Cache/Utils/CacheList.d.ts +89 -0
  137. package/lib-esm/Cache/Utils/CacheList.js +194 -0
  138. package/lib-esm/Cache/Utils/CacheUtils.d.ts +25 -0
  139. package/lib-esm/Cache/Utils/CacheUtils.js +81 -0
  140. package/lib-esm/Cache/Utils/index.d.ts +2 -0
  141. package/lib-esm/Cache/Utils/index.js +4 -0
  142. package/lib-esm/Cache/reactnative.d.ts +3 -0
  143. package/lib-esm/Cache/reactnative.js +6 -0
  144. package/lib-esm/Cache/types/Cache.d.ts +55 -0
  145. package/lib-esm/Cache/types/Cache.js +3 -0
  146. package/lib-esm/Cache/types/index.d.ts +1 -0
  147. package/lib-esm/Cache/types/index.js +3 -0
  148. package/lib-esm/ClientDevice/android.js +1 -0
  149. package/lib-esm/ClientDevice/ios.d.ts +2 -2
  150. package/lib-esm/ClientDevice/ios.js +1 -0
  151. package/lib-esm/ClientDevice/reactnative.js +1 -0
  152. package/lib-esm/Credentials.d.ts +1 -1
  153. package/lib-esm/Credentials.js +2 -1
  154. package/lib-esm/Errors.d.ts +19 -0
  155. package/lib-esm/Errors.js +49 -0
  156. package/lib-esm/Hub.js +1 -0
  157. package/lib-esm/I18n/I18n.d.ts +29 -9
  158. package/lib-esm/I18n/I18n.js +30 -5
  159. package/lib-esm/I18n/index.d.ts +18 -5
  160. package/lib-esm/I18n/index.js +35 -5
  161. package/lib-esm/I18n/types.d.ts +4 -1
  162. package/lib-esm/I18n/types.js +3 -0
  163. package/lib-esm/JS.d.ts +6 -6
  164. package/lib-esm/Logger/ConsoleLogger.d.ts +11 -11
  165. package/lib-esm/OAuthHelper/GoogleOAuth.js +2 -1
  166. package/lib-esm/Platform/detectFramework.js +2 -1
  167. package/lib-esm/Platform/detection/Next.d.ts +1 -1
  168. package/lib-esm/Platform/detection/React.js +1 -0
  169. package/lib-esm/Platform/version.d.ts +1 -1
  170. package/lib-esm/Platform/version.js +1 -1
  171. package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +2 -2
  172. package/lib-esm/Providers/AWSCloudWatchProvider.js +33 -10
  173. package/lib-esm/RNComponents/index.d.ts +1 -1
  174. package/lib-esm/RNComponents/reactnative.js +1 -0
  175. package/lib-esm/ServiceWorker/ServiceWorker.d.ts +4 -4
  176. package/lib-esm/ServiceWorker/ServiceWorker.js +37 -11
  177. package/lib-esm/Signer.d.ts +14 -1
  178. package/lib-esm/StorageHelper/cookieStorage.d.ts +13 -0
  179. package/lib-esm/StorageHelper/cookieStorage.js +141 -0
  180. package/lib-esm/StorageHelper/inMemoryStorage.d.ts +10 -0
  181. package/lib-esm/StorageHelper/inMemoryStorage.js +79 -0
  182. package/lib-esm/StorageHelper/index.d.ts +7 -3
  183. package/lib-esm/StorageHelper/index.js +4 -0
  184. package/lib-esm/StorageHelper/localStorage.d.ts +32 -0
  185. package/lib-esm/StorageHelper/localStorage.js +111 -0
  186. package/lib-esm/StorageHelper/reactnative.d.ts +71 -1
  187. package/lib-esm/StorageHelper/reactnative.js +153 -9
  188. package/lib-esm/StorageHelper/sessionStorage.d.ts +32 -0
  189. package/lib-esm/StorageHelper/sessionStorage.js +111 -0
  190. package/lib-esm/UniversalStorage/index.d.ts +2 -2
  191. package/lib-esm/Util/BackgroundProcessManager.d.ts +2 -2
  192. package/lib-esm/Util/BackgroundProcessManager.js +1 -0
  193. package/lib-esm/Util/DateUtils.d.ts +12 -1
  194. package/lib-esm/Util/Reachability.js +5 -3
  195. package/lib-esm/Util/Reachability.native.d.ts +3 -2
  196. package/lib-esm/Util/StringUtils.js +3 -10
  197. package/lib-esm/Util/errors/AssertError.d.ts +2 -0
  198. package/lib-esm/Util/errors/AssertError.js +7 -0
  199. package/lib-esm/clients/middleware/retry/defaultRetryDecider.d.ts +1 -1
  200. package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -13
  201. package/lib-esm/clients/middleware/retry/isClockSkewError.js +1 -1
  202. package/lib-esm/clients/middleware/retry/middleware.d.ts +1 -1
  203. package/lib-esm/clients/middleware/retry/middleware.js +13 -13
  204. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +1 -1
  205. package/lib-esm/clients/serde/responseInfo.js +1 -1
  206. package/lib-esm/clients/types/aws.d.ts +4 -0
  207. package/lib-esm/clients/types/index.d.ts +1 -1
  208. package/lib-esm/constants.d.ts +7 -0
  209. package/lib-esm/constants.js +8 -0
  210. package/lib-esm/index.d.ts +18 -4
  211. package/lib-esm/index.js +15 -3
  212. package/lib-esm/parseAWSExports.d.ts +1 -1
  213. package/lib-esm/singleton/Auth/index.d.ts +30 -0
  214. package/lib-esm/singleton/Auth/index.js +129 -0
  215. package/lib-esm/singleton/Auth/types.d.ts +95 -0
  216. package/lib-esm/singleton/Auth/types.js +5 -0
  217. package/lib-esm/singleton/Auth/utils/index.d.ts +5 -0
  218. package/lib-esm/singleton/Auth/utils/index.js +45 -0
  219. package/lib-esm/singleton/Storage/types.d.ts +14 -0
  220. package/lib-esm/singleton/Storage/types.js +3 -0
  221. package/lib-esm/singleton/index.d.ts +46 -0
  222. package/lib-esm/singleton/index.js +156 -0
  223. package/lib-esm/singleton/types.d.ts +21 -0
  224. package/lib-esm/singleton/types.js +3 -0
  225. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  226. package/lib-esm/types/types.d.ts +31 -1
  227. package/lib-esm/types/types.js +2 -0
  228. package/package.json +38 -15
  229. package/src/Amplify.ts +9 -3
  230. package/src/AwsClients/CognitoIdentity/base.ts +2 -1
  231. package/src/AwsClients/CognitoIdentity/getCredentialsForIdentity.ts +13 -6
  232. package/src/AwsClients/Pinpoint/base.ts +6 -2
  233. package/src/AwsClients/Pinpoint/getInAppMessages.ts +1 -1
  234. package/src/AwsClients/Pinpoint/putEvents.ts +6 -0
  235. package/src/AwsClients/Pinpoint/updateEndpoint.ts +2 -2
  236. package/src/Cache/AsyncStorageCache.ts +500 -0
  237. package/src/Cache/BrowserStorageCache.ts +517 -0
  238. package/src/Cache/CHANGELOG.md +1227 -0
  239. package/src/Cache/InMemoryCache.ts +354 -0
  240. package/src/Cache/StorageCache.ts +157 -0
  241. package/src/Cache/Utils/CacheList.ts +198 -0
  242. package/src/Cache/Utils/CacheUtils.ts +92 -0
  243. package/src/Cache/Utils/index.ts +11 -0
  244. package/src/Cache/reactnative.ts +9 -0
  245. package/src/Cache/types/Cache.ts +75 -0
  246. package/src/Cache/types/index.ts +4 -0
  247. package/src/ClientDevice/android.ts +1 -1
  248. package/src/ClientDevice/ios.ts +2 -2
  249. package/src/ClientDevice/reactnative.ts +1 -1
  250. package/src/Credentials.ts +19 -17
  251. package/src/Errors.ts +41 -0
  252. package/src/Hub.ts +1 -0
  253. package/src/I18n/I18n.ts +40 -12
  254. package/src/I18n/index.ts +45 -12
  255. package/src/I18n/types.ts +3 -0
  256. package/src/JS.ts +24 -17
  257. package/src/Logger/ConsoleLogger.ts +10 -10
  258. package/src/OAuthHelper/FacebookOAuth.ts +2 -2
  259. package/src/OAuthHelper/GoogleOAuth.ts +9 -6
  260. package/src/Platform/detectFramework.ts +1 -1
  261. package/src/Platform/detection/React.ts +5 -3
  262. package/src/Platform/version.ts +1 -1
  263. package/src/Providers/AWSCloudWatchProvider.ts +39 -14
  264. package/src/RNComponents/index.ts +1 -1
  265. package/src/RNComponents/reactnative.ts +1 -1
  266. package/src/ServiceWorker/ServiceWorker.ts +58 -18
  267. package/src/Signer.ts +22 -3
  268. package/src/StorageHelper/cookieStorage.ts +99 -0
  269. package/src/StorageHelper/inMemoryStorage.ts +32 -0
  270. package/src/StorageHelper/index.ts +6 -1
  271. package/src/StorageHelper/localStorage.ts +60 -0
  272. package/src/StorageHelper/reactnative.ts +94 -14
  273. package/src/StorageHelper/sessionStorage.ts +60 -0
  274. package/src/Util/BackgroundProcessManager.ts +33 -9
  275. package/src/Util/DateUtils.ts +14 -5
  276. package/src/Util/Reachability.native.ts +3 -2
  277. package/src/Util/Reachability.ts +9 -7
  278. package/src/Util/Retry.ts +2 -1
  279. package/src/Util/StringUtils.ts +3 -10
  280. package/src/Util/errors/AssertError.ts +11 -0
  281. package/src/clients/handlers/fetch.ts +2 -2
  282. package/src/clients/middleware/retry/defaultRetryDecider.ts +12 -6
  283. package/src/clients/middleware/retry/isClockSkewError.ts +1 -1
  284. package/src/clients/middleware/retry/middleware.ts +9 -9
  285. package/src/clients/middleware/signing/middleware.ts +1 -1
  286. package/src/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.ts +1 -1
  287. package/src/clients/serde/responseInfo.ts +2 -1
  288. package/src/clients/types/aws.ts +10 -0
  289. package/src/clients/types/index.ts +1 -0
  290. package/src/constants.ts +16 -0
  291. package/src/global.d.ts +11 -0
  292. package/src/index.ts +66 -4
  293. package/src/parseAWSExports.ts +1 -1
  294. package/src/singleton/Auth/index.ts +113 -0
  295. package/src/singleton/Auth/types.ts +129 -0
  296. package/src/singleton/Auth/utils/index.ts +68 -0
  297. package/src/singleton/Storage/types.ts +21 -0
  298. package/src/singleton/index.ts +144 -0
  299. package/src/singleton/types.ts +48 -0
  300. package/src/types/types.ts +38 -1
@@ -0,0 +1,89 @@
1
+ /**
2
+ * double linked list plus a hash table inside
3
+ * each key in the cache stored as a node in the list
4
+ * recently visited node will be rotated to the head
5
+ * so the Last Recently Visited node will be at the tail
6
+ *
7
+ * @member head - dummy head of the linked list
8
+ * @member tail - dummy tail of the linked list
9
+ * @member hashtable - the hashtable which maps cache key to list node
10
+ * @member length - length of the list
11
+ */
12
+ export default class CacheList {
13
+ private head;
14
+ private tail;
15
+ private hashtable;
16
+ private length;
17
+ /**
18
+ * initialization
19
+ */
20
+ constructor();
21
+ /**
22
+ * insert node to the head of the list
23
+ *
24
+ * @param node
25
+ */
26
+ private insertNodeToHead;
27
+ /**
28
+ * remove node
29
+ *
30
+ * @param node
31
+ */
32
+ private removeNode;
33
+ /**
34
+ * @return true if list is empty
35
+ */
36
+ isEmpty(): boolean;
37
+ /**
38
+ * refresh node so it is rotated to the head
39
+ *
40
+ * @param key - key of the node
41
+ */
42
+ refresh(key: string): void;
43
+ /**
44
+ * insert new node to the head and add it in the hashtable
45
+ *
46
+ * @param key - the key of the node
47
+ */
48
+ insertItem(key: string): void;
49
+ /**
50
+ * @return the LAST Recently Visited key
51
+ */
52
+ getLastItem(): string;
53
+ /**
54
+ * remove the cache key from the list and hashtable
55
+ * @param key - the key of the node
56
+ */
57
+ removeItem(key: string): void;
58
+ /**
59
+ * @return length of the list
60
+ */
61
+ getSize(): number;
62
+ /**
63
+ * @return true if the key is in the hashtable
64
+ * @param key
65
+ */
66
+ containsKey(key: string): boolean;
67
+ /**
68
+ * clean up the list and hashtable
69
+ */
70
+ clearList(): void;
71
+ /**
72
+ * @return all keys in the hashtable
73
+ */
74
+ getKeys(): string[];
75
+ /**
76
+ * mainly for test
77
+ *
78
+ * @param key
79
+ * @return true if key is the head node
80
+ */
81
+ isHeadNode(key: string): boolean;
82
+ /**
83
+ * mainly for test
84
+ *
85
+ * @param key
86
+ * @return true if key is the tail node
87
+ */
88
+ isTailNode(key: string): boolean;
89
+ }
@@ -0,0 +1,194 @@
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
+ import { asserts } from '../../Util/errors/AssertError';
15
+ import { CACHE_LIST_EXCEPTION } from '../../constants';
16
+ var DoubleLinkedNode = /** @class */ (function () {
17
+ function DoubleLinkedNode(keyVal) {
18
+ this.key = keyVal ? keyVal : '';
19
+ this.prevNode = null;
20
+ this.nextNode = null;
21
+ }
22
+ return DoubleLinkedNode;
23
+ }());
24
+ /**
25
+ * double linked list plus a hash table inside
26
+ * each key in the cache stored as a node in the list
27
+ * recently visited node will be rotated to the head
28
+ * so the Last Recently Visited node will be at the tail
29
+ *
30
+ * @member head - dummy head of the linked list
31
+ * @member tail - dummy tail of the linked list
32
+ * @member hashtable - the hashtable which maps cache key to list node
33
+ * @member length - length of the list
34
+ */
35
+ var CacheList = /** @class */ (function () {
36
+ /**
37
+ * initialization
38
+ */
39
+ function CacheList() {
40
+ this.head = new DoubleLinkedNode();
41
+ this.tail = new DoubleLinkedNode();
42
+ this.hashtable = {};
43
+ this.length = 0;
44
+ this.head.nextNode = this.tail;
45
+ this.tail.prevNode = this.head;
46
+ }
47
+ /**
48
+ * insert node to the head of the list
49
+ *
50
+ * @param node
51
+ */
52
+ CacheList.prototype.insertNodeToHead = function (node) {
53
+ var tmp = this.head.nextNode;
54
+ this.head.nextNode = node;
55
+ node.nextNode = tmp;
56
+ node.prevNode = this.head;
57
+ asserts(tmp !== null, {
58
+ name: CACHE_LIST_EXCEPTION,
59
+ message: 'previous node is null',
60
+ });
61
+ tmp.prevNode = node;
62
+ this.length = this.length + 1;
63
+ };
64
+ /**
65
+ * remove node
66
+ *
67
+ * @param node
68
+ */
69
+ CacheList.prototype.removeNode = function (node) {
70
+ asserts(node.prevNode !== null, {
71
+ name: CACHE_LIST_EXCEPTION,
72
+ message: 'previous node is null',
73
+ });
74
+ asserts(node.nextNode !== null, {
75
+ name: CACHE_LIST_EXCEPTION,
76
+ message: 'nextNode node is null',
77
+ });
78
+ node.prevNode.nextNode = node.nextNode;
79
+ node.nextNode.prevNode = node.prevNode;
80
+ node.prevNode = null;
81
+ node.nextNode = null;
82
+ this.length = this.length - 1;
83
+ };
84
+ /**
85
+ * @return true if list is empty
86
+ */
87
+ CacheList.prototype.isEmpty = function () {
88
+ return this.length === 0;
89
+ };
90
+ /**
91
+ * refresh node so it is rotated to the head
92
+ *
93
+ * @param key - key of the node
94
+ */
95
+ CacheList.prototype.refresh = function (key) {
96
+ var node = this.hashtable[key];
97
+ this.removeNode(node);
98
+ this.insertNodeToHead(node);
99
+ };
100
+ /**
101
+ * insert new node to the head and add it in the hashtable
102
+ *
103
+ * @param key - the key of the node
104
+ */
105
+ CacheList.prototype.insertItem = function (key) {
106
+ var node = new DoubleLinkedNode(key);
107
+ this.hashtable[key] = node;
108
+ this.insertNodeToHead(node);
109
+ };
110
+ /**
111
+ * @return the LAST Recently Visited key
112
+ */
113
+ CacheList.prototype.getLastItem = function () {
114
+ asserts(this.tail.prevNode !== null, {
115
+ name: CACHE_LIST_EXCEPTION,
116
+ message: 'previous node is null',
117
+ });
118
+ return this.tail.prevNode.key;
119
+ };
120
+ /**
121
+ * remove the cache key from the list and hashtable
122
+ * @param key - the key of the node
123
+ */
124
+ CacheList.prototype.removeItem = function (key) {
125
+ var removedItem = this.hashtable[key];
126
+ this.removeNode(removedItem);
127
+ delete this.hashtable[key];
128
+ };
129
+ /**
130
+ * @return length of the list
131
+ */
132
+ CacheList.prototype.getSize = function () {
133
+ return this.length;
134
+ };
135
+ /**
136
+ * @return true if the key is in the hashtable
137
+ * @param key
138
+ */
139
+ CacheList.prototype.containsKey = function (key) {
140
+ return key in this.hashtable;
141
+ };
142
+ /**
143
+ * clean up the list and hashtable
144
+ */
145
+ CacheList.prototype.clearList = function () {
146
+ var e_1, _a;
147
+ try {
148
+ for (var _b = __values(Object.keys(this.hashtable)), _c = _b.next(); !_c.done; _c = _b.next()) {
149
+ var key = _c.value;
150
+ if (this.hashtable.hasOwnProperty(key)) {
151
+ delete this.hashtable[key];
152
+ }
153
+ }
154
+ }
155
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
156
+ finally {
157
+ try {
158
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
159
+ }
160
+ finally { if (e_1) throw e_1.error; }
161
+ }
162
+ this.head.nextNode = this.tail;
163
+ this.tail.prevNode = this.head;
164
+ this.length = 0;
165
+ };
166
+ /**
167
+ * @return all keys in the hashtable
168
+ */
169
+ CacheList.prototype.getKeys = function () {
170
+ return Object.keys(this.hashtable);
171
+ };
172
+ /**
173
+ * mainly for test
174
+ *
175
+ * @param key
176
+ * @return true if key is the head node
177
+ */
178
+ CacheList.prototype.isHeadNode = function (key) {
179
+ var node = this.hashtable[key];
180
+ return node.prevNode === this.head;
181
+ };
182
+ /**
183
+ * mainly for test
184
+ *
185
+ * @param key
186
+ * @return true if key is the tail node
187
+ */
188
+ CacheList.prototype.isTailNode = function (key) {
189
+ var node = this.hashtable[key];
190
+ return node.nextNode === this.tail;
191
+ };
192
+ return CacheList;
193
+ }());
194
+ export default CacheList;
@@ -0,0 +1,25 @@
1
+ import { CacheConfig } from '../types';
2
+ /**
3
+ * Default cache config
4
+ */
5
+ export declare const defaultConfig: CacheConfig;
6
+ /**
7
+ * return the byte size of the string
8
+ * @param str
9
+ */
10
+ export declare function getByteLength(str: string): number;
11
+ /**
12
+ * get current time
13
+ */
14
+ export declare function getCurrTime(): number;
15
+ /**
16
+ * check if passed value is an integer
17
+ */
18
+ export declare function isInteger(value?: number): boolean;
19
+ export declare class CacheObject {
20
+ static clear(): void;
21
+ static getItem(key: string): string | null;
22
+ static setItem(key: string, value: string): void;
23
+ static removeItem(key: string): void;
24
+ }
25
+ export declare const getCurrSizeKey: (keyPrefix: string) => string;
@@ -0,0 +1,81 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { StorageHelper } from '../../StorageHelper';
4
+ /**
5
+ * Default cache config
6
+ */
7
+ export var defaultConfig = {
8
+ keyPrefix: 'aws-amplify-cache',
9
+ capacityInBytes: 1048576,
10
+ itemMaxSize: 210000,
11
+ defaultTTL: 259200000,
12
+ defaultPriority: 5,
13
+ warningThreshold: 0.8,
14
+ // the storage helper will check if localStorage exists,
15
+ // if not, will use a in-memory object instead
16
+ storage: new StorageHelper().getStorage(),
17
+ };
18
+ /**
19
+ * return the byte size of the string
20
+ * @param str
21
+ */
22
+ export function getByteLength(str) {
23
+ var ret = 0;
24
+ ret = str.length;
25
+ for (var i = str.length; i >= 0; i -= 1) {
26
+ var charCode = str.charCodeAt(i);
27
+ if (charCode > 0x7f && charCode <= 0x7ff) {
28
+ ret += 1;
29
+ }
30
+ else if (charCode > 0x7ff && charCode <= 0xffff) {
31
+ ret += 2;
32
+ }
33
+ // trail surrogate
34
+ if (charCode >= 0xdc00 && charCode <= 0xdfff) {
35
+ i -= 1;
36
+ }
37
+ }
38
+ return ret;
39
+ }
40
+ /**
41
+ * get current time
42
+ */
43
+ export function getCurrTime() {
44
+ var currTime = new Date();
45
+ return currTime.getTime();
46
+ }
47
+ /**
48
+ * check if passed value is an integer
49
+ */
50
+ export function isInteger(value) {
51
+ if (Number.isInteger) {
52
+ return Number.isInteger(value);
53
+ }
54
+ return _isInteger(value);
55
+ }
56
+ function _isInteger(value) {
57
+ return (typeof value === 'number' && isFinite(value) && Math.floor(value) === value);
58
+ }
59
+ /**
60
+ * provide an object as the in-memory cache
61
+ */
62
+ var store = {};
63
+ var CacheObject = /** @class */ (function () {
64
+ function CacheObject() {
65
+ }
66
+ CacheObject.clear = function () {
67
+ store = {};
68
+ };
69
+ CacheObject.getItem = function (key) {
70
+ return store[key] || null;
71
+ };
72
+ CacheObject.setItem = function (key, value) {
73
+ store[key] = value;
74
+ };
75
+ CacheObject.removeItem = function (key) {
76
+ delete store[key];
77
+ };
78
+ return CacheObject;
79
+ }());
80
+ export { CacheObject };
81
+ export var getCurrSizeKey = function (keyPrefix) { return keyPrefix + 'CurSize'; };
@@ -0,0 +1,2 @@
1
+ export { CacheObject, defaultConfig, getByteLength, getCurrTime, isInteger, } from './CacheUtils';
2
+ export { default as CacheList } from './CacheList';
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { CacheObject, defaultConfig, getByteLength, getCurrTime, isInteger, } from './CacheUtils';
4
+ export { default as CacheList } from './CacheList';
@@ -0,0 +1,3 @@
1
+ import { Cache, AsyncStorageCache } from './AsyncStorageCache';
2
+ export { AsyncStorageCache };
3
+ export { Cache };
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Cache, AsyncStorageCache } from './AsyncStorageCache';
4
+ export { AsyncStorageCache };
5
+ // Standard `Cache` export to maintain interoperability with React Native
6
+ export { Cache };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Cache Interface
3
+ */
4
+ export interface ICache {
5
+ /** Put item into cache */
6
+ setItem(key: string, value: any, options?: CacheItemOptions): void;
7
+ /** Get item from cache */
8
+ getItem(key: string, options?: CacheItemOptions): any;
9
+ /** Remove item from cache */
10
+ removeItem(key: string): void;
11
+ /** Remove all items from cache */
12
+ clear(): void;
13
+ /** Get all keys form cache */
14
+ getAllKeys(): string[] | Promise<string[]>;
15
+ /** Get current size of the cache */
16
+ getCacheCurSize(): number | Promise<number>;
17
+ /** create a new instance with customized config */
18
+ createInstance(config: CacheConfig): ICache;
19
+ /** change current configuration */
20
+ configure(config: CacheConfig): CacheConfig;
21
+ }
22
+ /**
23
+ * Cache instance options
24
+ */
25
+ export interface CacheConfig {
26
+ /** Prepend to key to avoid conflicts */
27
+ keyPrefix: string;
28
+ /** Cache capacity, in bytes */
29
+ capacityInBytes: number;
30
+ /** Max size of one item */
31
+ itemMaxSize: number;
32
+ /** Time to live, in milliseconds */
33
+ defaultTTL: number;
34
+ /** Warn when over threshold percentage of capacity, maximum 1 */
35
+ warningThreshold: number;
36
+ /** default priority number put on cached items */
37
+ defaultPriority: number;
38
+ storage?: Storage;
39
+ Cache?: Cache;
40
+ }
41
+ export interface CacheItem {
42
+ key: string;
43
+ data: any;
44
+ timestamp: number;
45
+ visitedTime: number;
46
+ priority: number;
47
+ expires: number;
48
+ type: string;
49
+ byteSize: number;
50
+ }
51
+ export interface CacheItemOptions {
52
+ priority?: number;
53
+ expires?: number;
54
+ callback?: Function;
55
+ }
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Cache';
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export * from './Cache';
@@ -1,5 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ // @ts-ignore: missing type definition
3
4
  import { Platform, Dimensions } from 'react-native';
4
5
  import { ConsoleLogger as Logger } from '../Logger';
5
6
  var logger = new Logger('DeviceInfo');
@@ -2,6 +2,6 @@ export declare const clientInfo: () => {
2
2
  platform: string;
3
3
  version: string;
4
4
  appVersion: string;
5
- make: string;
6
- model: string;
5
+ make: string | null;
6
+ model: string | null;
7
7
  };
@@ -1,5 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ // @ts-ignore: missing type definition
3
4
  import { Platform, Dimensions } from 'react-native';
4
5
  import { ConsoleLogger as Logger } from '../Logger';
5
6
  var logger = new Logger('DeviceInfo');
@@ -1,5 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ // @ts-ignore: missing type definition
3
4
  import { Platform } from 'react-native';
4
5
  import { clientInfo as iOSClientInfo } from './ios';
5
6
  import { clientInfo as androidClientInfo } from './android';
@@ -9,7 +9,7 @@ export declare class CredentialsClass {
9
9
  private _storageSync;
10
10
  private _identityId;
11
11
  private _nextCredentialsRefresh;
12
- Auth: any;
12
+ Auth: undefined;
13
13
  constructor(config: any);
14
14
  getModuleName(): string;
15
15
  getCredSource(): any;
@@ -45,6 +45,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
+ // @ts-nocheck
48
49
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
49
50
  // SPDX-License-Identifier: Apache-2.0
50
51
  import { ConsoleLogger as Logger } from './Logger';
@@ -480,7 +481,7 @@ var CredentialsClass = /** @class */ (function () {
480
481
  Logins: logins,
481
482
  })];
482
483
  case 4:
483
- _a = _c.sent(), _b = _a.Credentials, AccessKeyId = _b.AccessKeyId, Expiration = _b.Expiration, SecretKey = _b.SecretKey, SessionToken = _b.SessionToken, primaryIdentityId = _a.IdentityId;
484
+ _a = (_c.sent()), _b = _a.Credentials, AccessKeyId = _b.AccessKeyId, Expiration = _b.Expiration, SecretKey = _b.SecretKey, SessionToken = _b.SessionToken, primaryIdentityId = _a.IdentityId;
484
485
  this._identityId = primaryIdentityId;
485
486
  if (!guestIdentityId) return [3 /*break*/, 6];
486
487
  // if guestIdentity is found and used by GetCredentialsForIdentity
@@ -1,2 +1,21 @@
1
+ import { ErrorParams } from './types/types';
1
2
  export declare function missingConfig(name: string): Error;
2
3
  export declare function invalidParameter(name: string): Error;
4
+ export declare enum AmplifyErrorString {
5
+ UNKNOWN = "UnknownError",
6
+ PLATFORM_NOT_SUPPORTED_ERROR = "PlatformNotSupportedError"
7
+ }
8
+ export declare class AmplifyError extends Error {
9
+ underlyingError?: Error | unknown;
10
+ recoverySuggestion?: string;
11
+ /**
12
+ * Constructs an AmplifyError.
13
+ *
14
+ * @param message text that describes the main problem.
15
+ * @param underlyingError the underlying cause of the error.
16
+ * @param recoverySuggestion suggestion to recover from the error.
17
+ *
18
+ */
19
+ constructor({ message, name, recoverySuggestion, underlyingError, }: ErrorParams);
20
+ }
21
+ export declare const PlatformNotSupportedError: AmplifyError;
package/lib-esm/Errors.js CHANGED
@@ -1,8 +1,57 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ var __extends = (this && this.__extends) || (function () {
4
+ var extendStatics = function (d, b) {
5
+ extendStatics = Object.setPrototypeOf ||
6
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
+ return extendStatics(d, b);
9
+ };
10
+ return function (d, b) {
11
+ if (typeof b !== "function" && b !== null)
12
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13
+ extendStatics(d, b);
14
+ function __() { this.constructor = d; }
15
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
+ };
17
+ })();
3
18
  export function missingConfig(name) {
4
19
  return new Error('Missing config value of ' + name);
5
20
  }
6
21
  export function invalidParameter(name) {
7
22
  return new Error('Invalid parameter value of ' + name);
8
23
  }
24
+ export var AmplifyErrorString;
25
+ (function (AmplifyErrorString) {
26
+ AmplifyErrorString["UNKNOWN"] = "UnknownError";
27
+ AmplifyErrorString["PLATFORM_NOT_SUPPORTED_ERROR"] = "PlatformNotSupportedError";
28
+ })(AmplifyErrorString || (AmplifyErrorString = {}));
29
+ var AmplifyError = /** @class */ (function (_super) {
30
+ __extends(AmplifyError, _super);
31
+ /**
32
+ * Constructs an AmplifyError.
33
+ *
34
+ * @param message text that describes the main problem.
35
+ * @param underlyingError the underlying cause of the error.
36
+ * @param recoverySuggestion suggestion to recover from the error.
37
+ *
38
+ */
39
+ function AmplifyError(_a) {
40
+ var message = _a.message, name = _a.name, recoverySuggestion = _a.recoverySuggestion, underlyingError = _a.underlyingError;
41
+ var _this = _super.call(this, message) || this;
42
+ _this.name = name;
43
+ _this.underlyingError = underlyingError;
44
+ _this.recoverySuggestion = recoverySuggestion;
45
+ // Hack for making the custom error class work when transpiled to es5
46
+ // TODO: Delete the following 2 lines after we change the build target to >= es2015
47
+ _this.constructor = AmplifyError;
48
+ Object.setPrototypeOf(_this, AmplifyError.prototype);
49
+ return _this;
50
+ }
51
+ return AmplifyError;
52
+ }(Error));
53
+ export { AmplifyError };
54
+ export var PlatformNotSupportedError = new AmplifyError({
55
+ name: AmplifyErrorString.PLATFORM_NOT_SUPPORTED_ERROR,
56
+ message: 'Function not supported on current platform',
57
+ });
package/lib-esm/Hub.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
3
  // SPDX-License-Identifier: Apache-2.0
3
4
  var __assign = (this && this.__assign) || function () {