@aws-amplify/core 5.8.2 → 6.0.1-console-preview.f63250a.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 +147 -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 +143 -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 +131 -0
  299. package/src/singleton/types.ts +48 -0
  300. package/src/types/types.ts +38 -1
@@ -0,0 +1,32 @@
1
+ import { KeyValueStorageInterface } from "../types";
2
+ declare class LocalStorageClass implements KeyValueStorageInterface {
3
+ storage?: Storage;
4
+ constructor();
5
+ /**
6
+ * This is used to set a specific item in storage
7
+ * @param {string} key - the key for the item
8
+ * @param {object} value - the value
9
+ * @returns {string} value that was set
10
+ */
11
+ setItem(key: string, value: string): Promise<void>;
12
+ /**
13
+ * This is used to get a specific key from storage
14
+ * @param {string} key - the key for the item
15
+ * This is used to clear the storage
16
+ * @returns {string} the data item
17
+ */
18
+ getItem(key: string): Promise<string | null>;
19
+ /**
20
+ * This is used to remove an item from storage
21
+ * @param {string} key - the key being set
22
+ * @returns {string} value - value that was deleted
23
+ */
24
+ removeItem(key: string): Promise<void>;
25
+ /**
26
+ * This is used to clear the storage
27
+ * @returns {string} nothing
28
+ */
29
+ clear(): Promise<void>;
30
+ }
31
+ export declare const LocalStorage: LocalStorageClass;
32
+ export {};
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ var __generator = (this && this.__generator) || function (thisArg, body) {
14
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
15
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16
+ function verb(n) { return function (v) { return step([n, v]); }; }
17
+ function step(op) {
18
+ if (f) throw new TypeError("Generator is already executing.");
19
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
20
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
21
+ if (y = 0, t) op = [op[0] & 2, t.value];
22
+ switch (op[0]) {
23
+ case 0: case 1: t = op; break;
24
+ case 4: _.label++; return { value: op[1], done: false };
25
+ case 5: _.label++; y = op[1]; op = [0]; continue;
26
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
27
+ default:
28
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
29
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
30
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
31
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
32
+ if (t[2]) _.ops.pop();
33
+ _.trys.pop(); continue;
34
+ }
35
+ op = body.call(thisArg, _);
36
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
37
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
38
+ }
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.LocalStorage = void 0;
42
+ var Errors_1 = require("../Errors");
43
+ var LocalStorageClass = /** @class */ (function () {
44
+ function LocalStorageClass() {
45
+ if (typeof window !== undefined) {
46
+ try {
47
+ this.storage = window === null || window === void 0 ? void 0 : window.localStorage;
48
+ }
49
+ catch (error) { }
50
+ }
51
+ }
52
+ /**
53
+ * This is used to set a specific item in storage
54
+ * @param {string} key - the key for the item
55
+ * @param {object} value - the value
56
+ * @returns {string} value that was set
57
+ */
58
+ LocalStorageClass.prototype.setItem = function (key, value) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ return __generator(this, function (_a) {
61
+ if (!this.storage)
62
+ throw Errors_1.PlatformNotSupportedError;
63
+ this.storage.setItem(key, value);
64
+ return [2 /*return*/];
65
+ });
66
+ });
67
+ };
68
+ /**
69
+ * This is used to get a specific key from storage
70
+ * @param {string} key - the key for the item
71
+ * This is used to clear the storage
72
+ * @returns {string} the data item
73
+ */
74
+ LocalStorageClass.prototype.getItem = function (key) {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ if (!this.storage)
78
+ throw Errors_1.PlatformNotSupportedError;
79
+ return [2 /*return*/, this.storage.getItem(key)];
80
+ });
81
+ });
82
+ };
83
+ /**
84
+ * This is used to remove an item from storage
85
+ * @param {string} key - the key being set
86
+ * @returns {string} value - value that was deleted
87
+ */
88
+ LocalStorageClass.prototype.removeItem = function (key) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ if (!this.storage)
92
+ throw Errors_1.PlatformNotSupportedError;
93
+ this.storage.removeItem(key);
94
+ return [2 /*return*/];
95
+ });
96
+ });
97
+ };
98
+ /**
99
+ * This is used to clear the storage
100
+ * @returns {string} nothing
101
+ */
102
+ LocalStorageClass.prototype.clear = function () {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ if (!this.storage)
106
+ throw Errors_1.PlatformNotSupportedError;
107
+ this.storage.clear();
108
+ return [2 /*return*/];
109
+ });
110
+ });
111
+ };
112
+ return LocalStorageClass;
113
+ }());
114
+ exports.LocalStorage = new LocalStorageClass();
@@ -1,3 +1,38 @@
1
+ import { KeyValueStorageInterface } from '../types';
2
+ /** @class */
3
+ declare class MemoryStorage {
4
+ static syncPromise: Promise<void> | null;
5
+ /**
6
+ * This is used to set a specific item in storage
7
+ * @param {string} key - the key for the item
8
+ * @param {object} value - the value
9
+ * @returns {string} value that was set
10
+ */
11
+ static setItem(key: string, value: string): string | null | undefined;
12
+ /**
13
+ * This is used to get a specific key from storage
14
+ * @param {string} key - the key for the item
15
+ * This is used to clear the storage
16
+ * @returns {string} the data item
17
+ */
18
+ static getItem(key: string): string | null | undefined;
19
+ /**
20
+ * This is used to remove an item from storage
21
+ * @param {string} key - the key being set
22
+ * @returns {string} value - value that was deleted
23
+ */
24
+ static removeItem(key: string): boolean;
25
+ /**
26
+ * This is used to clear the storage
27
+ * @returns {string} nothing
28
+ */
29
+ static clear(): Record<string, string | null>;
30
+ /**
31
+ * Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
32
+ * @returns {void}
33
+ */
34
+ static sync(): Promise<void>;
35
+ }
1
36
  export declare class StorageHelper {
2
37
  private storageWindow;
3
38
  /**
@@ -9,5 +44,40 @@ export declare class StorageHelper {
9
44
  * This is used to return the storage
10
45
  * @returns {object} the storage
11
46
  */
12
- getStorage(): any;
47
+ getStorage(): typeof MemoryStorage;
48
+ }
49
+ declare class AsyncStorageClass implements KeyValueStorageInterface {
50
+ syncPromise: Promise<void> | null;
51
+ /**
52
+ * This is used to set a specific item in storage
53
+ * @param {string} key - the key for the item
54
+ * @param {object} value - the value
55
+ * @returns {string} value that was set
56
+ */
57
+ setItem(key: string, value: string): Promise<void>;
58
+ /**
59
+ * This is used to get a specific key from storage
60
+ * @param {string} key - the key for the item
61
+ * This is used to clear the storage
62
+ * @returns {string} the data item
63
+ */
64
+ getItem(key: string): Promise<string | null>;
65
+ /**
66
+ * This is used to remove an item from storage
67
+ * @param {string} key - the key being set
68
+ * @returns {string} value - value that was deleted
69
+ */
70
+ removeItem(key: string): Promise<void>;
71
+ /**
72
+ * This is used to clear the storage
73
+ * @returns {string} nothing
74
+ */
75
+ clear(): Promise<void>;
76
+ /**
77
+ * Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
78
+ * @returns {void}
79
+ */
80
+ sync(): Promise<void>;
13
81
  }
82
+ export declare const AsyncStorageKeyValue: AsyncStorageClass;
83
+ export {};
@@ -1,9 +1,45 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
40
  };
5
41
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StorageHelper = void 0;
42
+ exports.AsyncStorageKeyValue = exports.StorageHelper = void 0;
7
43
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8
44
  // SPDX-License-Identifier: Apache-2.0
9
45
  var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
@@ -62,20 +98,20 @@ var MemoryStorage = /** @class */ (function () {
62
98
  if (!MemoryStorage.syncPromise) {
63
99
  MemoryStorage.syncPromise = new Promise(function (res, rej) {
64
100
  async_storage_1.default.getAllKeys(function (errKeys, keys) {
101
+ var _a;
65
102
  if (errKeys)
66
103
  rej(errKeys);
67
- var memoryKeys = keys.filter(function (key) {
68
- return key.startsWith(MEMORY_KEY_PREFIX);
69
- });
104
+ var memoryKeys = (_a = keys === null || keys === void 0 ? void 0 : keys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); })) !== null && _a !== void 0 ? _a : [];
70
105
  async_storage_1.default.multiGet(memoryKeys, function (err, stores) {
71
106
  if (err)
72
107
  rej(err);
73
- stores.map(function (result, index, store) {
74
- var key = store[index][0];
75
- var value = store[index][1];
76
- var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
77
- dataMemory[memoryKey] = value;
78
- });
108
+ stores &&
109
+ stores.map(function (result, index, store) {
110
+ var key = store[index][0];
111
+ var value = store[index][1];
112
+ var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
113
+ dataMemory[memoryKey] = value;
114
+ });
79
115
  res();
80
116
  });
81
117
  });
@@ -104,3 +140,111 @@ var StorageHelper = /** @class */ (function () {
104
140
  return StorageHelper;
105
141
  }());
106
142
  exports.StorageHelper = StorageHelper;
143
+ var AsyncStorageClass = /** @class */ (function () {
144
+ function AsyncStorageClass() {
145
+ this.syncPromise = null;
146
+ }
147
+ /**
148
+ * This is used to set a specific item in storage
149
+ * @param {string} key - the key for the item
150
+ * @param {object} value - the value
151
+ * @returns {string} value that was set
152
+ */
153
+ AsyncStorageClass.prototype.setItem = function (key, value) {
154
+ return __awaiter(this, void 0, void 0, function () {
155
+ return __generator(this, function (_a) {
156
+ switch (_a.label) {
157
+ case 0:
158
+ if (!value) return [3 /*break*/, 2];
159
+ return [4 /*yield*/, async_storage_1.default.setItem(MEMORY_KEY_PREFIX + key, value)];
160
+ case 1:
161
+ _a.sent();
162
+ dataMemory[key] = value;
163
+ _a.label = 2;
164
+ case 2: return [2 /*return*/];
165
+ }
166
+ });
167
+ });
168
+ };
169
+ /**
170
+ * This is used to get a specific key from storage
171
+ * @param {string} key - the key for the item
172
+ * This is used to clear the storage
173
+ * @returns {string} the data item
174
+ */
175
+ AsyncStorageClass.prototype.getItem = function (key) {
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ return __generator(this, function (_a) {
178
+ return [2 /*return*/, Object.prototype.hasOwnProperty.call(dataMemory, key)
179
+ ? dataMemory[key]
180
+ : null];
181
+ });
182
+ });
183
+ };
184
+ /**
185
+ * This is used to remove an item from storage
186
+ * @param {string} key - the key being set
187
+ * @returns {string} value - value that was deleted
188
+ */
189
+ AsyncStorageClass.prototype.removeItem = function (key) {
190
+ return __awaiter(this, void 0, void 0, function () {
191
+ return __generator(this, function (_a) {
192
+ switch (_a.label) {
193
+ case 0: return [4 /*yield*/, async_storage_1.default.removeItem(MEMORY_KEY_PREFIX + key)];
194
+ case 1:
195
+ _a.sent();
196
+ delete dataMemory[key];
197
+ return [2 /*return*/];
198
+ }
199
+ });
200
+ });
201
+ };
202
+ /**
203
+ * This is used to clear the storage
204
+ * @returns {string} nothing
205
+ */
206
+ AsyncStorageClass.prototype.clear = function () {
207
+ return __awaiter(this, void 0, void 0, function () {
208
+ return __generator(this, function (_a) {
209
+ dataMemory = {};
210
+ return [2 /*return*/];
211
+ });
212
+ });
213
+ };
214
+ /**
215
+ * Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
216
+ * @returns {void}
217
+ */
218
+ AsyncStorageClass.prototype.sync = function () {
219
+ return __awaiter(this, void 0, void 0, function () {
220
+ return __generator(this, function (_a) {
221
+ if (!this.syncPromise) {
222
+ this.syncPromise = new Promise(function (res, rej) {
223
+ async_storage_1.default.getAllKeys(function (errKeys, keys) {
224
+ var _a;
225
+ if (errKeys)
226
+ rej(errKeys);
227
+ var memoryKeys = (_a = keys === null || keys === void 0 ? void 0 : keys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); })) !== null && _a !== void 0 ? _a : [];
228
+ async_storage_1.default.multiGet(memoryKeys, function (err, stores) {
229
+ if (err)
230
+ rej(err);
231
+ stores &&
232
+ stores.map(function (result, index, store) {
233
+ var key = store[index][0];
234
+ var value = store[index][1];
235
+ var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
236
+ dataMemory[memoryKey] = value;
237
+ });
238
+ res();
239
+ });
240
+ });
241
+ });
242
+ }
243
+ return [2 /*return*/];
244
+ });
245
+ });
246
+ };
247
+ return AsyncStorageClass;
248
+ }());
249
+ // TODO: Add this to the react-native Amplify package.
250
+ exports.AsyncStorageKeyValue = new AsyncStorageClass();
@@ -0,0 +1,32 @@
1
+ import { KeyValueStorageInterface } from '../types';
2
+ declare class SessionStorageClass implements KeyValueStorageInterface {
3
+ storage?: Storage;
4
+ constructor();
5
+ /**
6
+ * This is used to set a specific item in storage
7
+ * @param {string} key - the key for the item
8
+ * @param {object} value - the value
9
+ * @returns {string} value that was set
10
+ */
11
+ setItem(key: string, value: string): Promise<void>;
12
+ /**
13
+ * This is used to get a specific key from storage
14
+ * @param {string} key - the key for the item
15
+ * This is used to clear the storage
16
+ * @returns {string} the data item
17
+ */
18
+ getItem(key: string): Promise<string | null>;
19
+ /**
20
+ * This is used to remove an item from storage
21
+ * @param {string} key - the key being set
22
+ * @returns {string} value - value that was deleted
23
+ */
24
+ removeItem(key: string): Promise<void>;
25
+ /**
26
+ * This is used to clear the storage
27
+ * @returns {string} nothing
28
+ */
29
+ clear(): Promise<void>;
30
+ }
31
+ export declare const SessionStorage: SessionStorageClass;
32
+ export {};
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ var __generator = (this && this.__generator) || function (thisArg, body) {
14
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
15
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16
+ function verb(n) { return function (v) { return step([n, v]); }; }
17
+ function step(op) {
18
+ if (f) throw new TypeError("Generator is already executing.");
19
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
20
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
21
+ if (y = 0, t) op = [op[0] & 2, t.value];
22
+ switch (op[0]) {
23
+ case 0: case 1: t = op; break;
24
+ case 4: _.label++; return { value: op[1], done: false };
25
+ case 5: _.label++; y = op[1]; op = [0]; continue;
26
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
27
+ default:
28
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
29
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
30
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
31
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
32
+ if (t[2]) _.ops.pop();
33
+ _.trys.pop(); continue;
34
+ }
35
+ op = body.call(thisArg, _);
36
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
37
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
38
+ }
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.SessionStorage = void 0;
42
+ var Errors_1 = require("../Errors");
43
+ var SessionStorageClass = /** @class */ (function () {
44
+ function SessionStorageClass() {
45
+ if (typeof window !== undefined) {
46
+ try {
47
+ this.storage = window === null || window === void 0 ? void 0 : window.sessionStorage;
48
+ }
49
+ catch (error) { }
50
+ }
51
+ }
52
+ /**
53
+ * This is used to set a specific item in storage
54
+ * @param {string} key - the key for the item
55
+ * @param {object} value - the value
56
+ * @returns {string} value that was set
57
+ */
58
+ SessionStorageClass.prototype.setItem = function (key, value) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ return __generator(this, function (_a) {
61
+ if (!this.storage)
62
+ throw Errors_1.PlatformNotSupportedError;
63
+ this.storage.setItem(key, value);
64
+ return [2 /*return*/];
65
+ });
66
+ });
67
+ };
68
+ /**
69
+ * This is used to get a specific key from storage
70
+ * @param {string} key - the key for the item
71
+ * This is used to clear the storage
72
+ * @returns {string} the data item
73
+ */
74
+ SessionStorageClass.prototype.getItem = function (key) {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ if (!this.storage)
78
+ throw Errors_1.PlatformNotSupportedError;
79
+ return [2 /*return*/, this.storage.getItem(key)];
80
+ });
81
+ });
82
+ };
83
+ /**
84
+ * This is used to remove an item from storage
85
+ * @param {string} key - the key being set
86
+ * @returns {string} value - value that was deleted
87
+ */
88
+ SessionStorageClass.prototype.removeItem = function (key) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ if (!this.storage)
92
+ throw Errors_1.PlatformNotSupportedError;
93
+ this.storage.removeItem(key);
94
+ return [2 /*return*/];
95
+ });
96
+ });
97
+ };
98
+ /**
99
+ * This is used to clear the storage
100
+ * @returns {string} nothing
101
+ */
102
+ SessionStorageClass.prototype.clear = function () {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ if (!this.storage)
106
+ throw Errors_1.PlatformNotSupportedError;
107
+ this.storage.clear();
108
+ return [2 /*return*/];
109
+ });
110
+ });
111
+ };
112
+ return SessionStorageClass;
113
+ }());
114
+ exports.SessionStorage = new SessionStorageClass();
@@ -9,8 +9,8 @@ export declare class UniversalStorage implements Storage {
9
9
  constructor(context?: Context);
10
10
  get length(): number;
11
11
  clear(): void;
12
- getItem(key: keyof Store): string;
13
- protected getLocalItem(key: keyof Store): string;
12
+ getItem(key: keyof Store): string | null;
13
+ protected getLocalItem(key: keyof Store): string | null;
14
14
  protected getUniversalItem(key: keyof Store): any;
15
15
  key(index: number): string;
16
16
  removeItem(key: string): void;
@@ -73,7 +73,7 @@ export declare class BackgroundProcessManager {
73
73
  * @param job The inner job manager to await.
74
74
  * @param description Optional description to help identify pending jobs.
75
75
  */
76
- add(job: BackgroundProcessManager, description?: string): any;
76
+ add<T>(job: BackgroundProcessManager, description?: string): Promise<T>;
77
77
  /**
78
78
  * Adds a **cleaner** function that doesn't immediately get executed.
79
79
  * Instead, the caller gets a **terminate** function back. The *cleaner* is
@@ -132,7 +132,7 @@ export declare class BackgroundProcessManager {
132
132
  *
133
133
  * @returns descriptions as an array.
134
134
  */
135
- get pending(): string[];
135
+ get pending(): (string | undefined)[];
136
136
  /**
137
137
  * Whether the manager is accepting new jobs.
138
138
  */
@@ -446,3 +446,4 @@ var BackgroundProcessManagerState;
446
446
  */
447
447
  BackgroundProcessManagerState["Closed"] = "Closed";
448
448
  })(BackgroundProcessManagerState = exports.BackgroundProcessManagerState || (exports.BackgroundProcessManagerState = {}));
449
+ var process = new BackgroundProcessManager();
@@ -4,4 +4,15 @@
4
4
  *
5
5
  * @see https://github.com/aws/aws-sdk-js/blob/6edf586dcc1de7fe8fbfbbd9a0d2b1847921e6e1/lib/util.js#L262
6
6
  */
7
- export declare const DateUtils: any;
7
+ type DateUtils = {
8
+ clockOffset: number;
9
+ getDateWithClockOffset: () => Date;
10
+ getClockOffset: () => number;
11
+ getHeaderStringFromDate: (date: Date) => string;
12
+ getDateFromHeaderString: (header: string) => Date;
13
+ isClockSkewed: (serverDate: Date) => boolean;
14
+ isClockSkewError: (error: any) => boolean;
15
+ setClockOffset: (offset: number) => void;
16
+ };
17
+ export declare const DateUtils: DateUtils;
18
+ export {};
@@ -16,16 +16,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
18
18
  // SPDX-License-Identifier: Apache-2.0
19
- var core_1 = require("@aws-amplify/core");
20
19
  var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
20
+ var JS_1 = require("../JS");
21
21
  var ReachabilityNavigator = /** @class */ (function () {
22
22
  function ReachabilityNavigator() {
23
23
  }
24
24
  ReachabilityNavigator.prototype.networkMonitor = function (netInfo) {
25
- if ((0, core_1.browserOrNode)().isNode) {
25
+ if ((0, JS_1.browserOrNode)().isNode) {
26
26
  return zen_observable_ts_1.default.from([{ online: true }]);
27
27
  }
28
- var globalObj = (0, core_1.isWebWorker)() ? self : window;
28
+ var globalObj = (0, JS_1.isWebWorker)() ? self : window;
29
29
  return new zen_observable_ts_1.default(function (observer) {
30
30
  observer.next({ online: globalObj.navigator.onLine });
31
31
  var notifyOnline = function () { return observer.next({ online: true }); };
@@ -36,7 +36,8 @@ var ReachabilityNavigator = /** @class */ (function () {
36
36
  return function () {
37
37
  globalObj.removeEventListener('online', notifyOnline);
38
38
  globalObj.removeEventListener('offline', notifyOffline);
39
- ReachabilityNavigator._observers = ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
39
+ ReachabilityNavigator._observers =
40
+ ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
40
41
  };
41
42
  });
42
43
  };
@@ -45,7 +46,8 @@ var ReachabilityNavigator = /** @class */ (function () {
45
46
  var e_1, _a;
46
47
  var _loop_1 = function (observer) {
47
48
  if (observer.closed) {
48
- ReachabilityNavigator._observers = ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
49
+ ReachabilityNavigator._observers =
50
+ ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
49
51
  return "continue";
50
52
  }
51
53
  observer.next(status);
@@ -1,11 +1,12 @@
1
1
  import Observable from 'zen-observable-ts';
2
+ import type NetInfo from '@react-native-community/netinfo';
2
3
  type NetworkStatus = {
3
4
  online: boolean;
4
5
  };
5
6
  export default class ReachabilityNavigator implements Reachability {
6
- networkMonitor(netInfo?: any): Observable<NetworkStatus>;
7
+ networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
7
8
  }
8
9
  interface Reachability {
9
- networkMonitor(netInfo?: any): Observable<NetworkStatus>;
10
+ networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
10
11
  }
11
12
  export {};