@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,111 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ 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;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ import { PlatformNotSupportedError } from '../Errors';
40
+ var LocalStorageClass = /** @class */ (function () {
41
+ function LocalStorageClass() {
42
+ if (typeof window !== undefined) {
43
+ try {
44
+ this.storage = window === null || window === void 0 ? void 0 : window.localStorage;
45
+ }
46
+ catch (error) { }
47
+ }
48
+ }
49
+ /**
50
+ * This is used to set a specific item in storage
51
+ * @param {string} key - the key for the item
52
+ * @param {object} value - the value
53
+ * @returns {string} value that was set
54
+ */
55
+ LocalStorageClass.prototype.setItem = function (key, value) {
56
+ return __awaiter(this, void 0, void 0, function () {
57
+ return __generator(this, function (_a) {
58
+ if (!this.storage)
59
+ throw PlatformNotSupportedError;
60
+ this.storage.setItem(key, value);
61
+ return [2 /*return*/];
62
+ });
63
+ });
64
+ };
65
+ /**
66
+ * This is used to get a specific key from storage
67
+ * @param {string} key - the key for the item
68
+ * This is used to clear the storage
69
+ * @returns {string} the data item
70
+ */
71
+ LocalStorageClass.prototype.getItem = function (key) {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ return __generator(this, function (_a) {
74
+ if (!this.storage)
75
+ throw PlatformNotSupportedError;
76
+ return [2 /*return*/, this.storage.getItem(key)];
77
+ });
78
+ });
79
+ };
80
+ /**
81
+ * This is used to remove an item from storage
82
+ * @param {string} key - the key being set
83
+ * @returns {string} value - value that was deleted
84
+ */
85
+ LocalStorageClass.prototype.removeItem = function (key) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ return __generator(this, function (_a) {
88
+ if (!this.storage)
89
+ throw PlatformNotSupportedError;
90
+ this.storage.removeItem(key);
91
+ return [2 /*return*/];
92
+ });
93
+ });
94
+ };
95
+ /**
96
+ * This is used to clear the storage
97
+ * @returns {string} nothing
98
+ */
99
+ LocalStorageClass.prototype.clear = function () {
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ return __generator(this, function (_a) {
102
+ if (!this.storage)
103
+ throw PlatformNotSupportedError;
104
+ this.storage.clear();
105
+ return [2 /*return*/];
106
+ });
107
+ });
108
+ };
109
+ return LocalStorageClass;
110
+ }());
111
+ export var 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,3 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
38
  // SPDX-License-Identifier: Apache-2.0
3
39
  import AsyncStorage from '@react-native-async-storage/async-storage';
@@ -56,20 +92,20 @@ var MemoryStorage = /** @class */ (function () {
56
92
  if (!MemoryStorage.syncPromise) {
57
93
  MemoryStorage.syncPromise = new Promise(function (res, rej) {
58
94
  AsyncStorage.getAllKeys(function (errKeys, keys) {
95
+ var _a;
59
96
  if (errKeys)
60
97
  rej(errKeys);
61
- var memoryKeys = keys.filter(function (key) {
62
- return key.startsWith(MEMORY_KEY_PREFIX);
63
- });
98
+ 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 : [];
64
99
  AsyncStorage.multiGet(memoryKeys, function (err, stores) {
65
100
  if (err)
66
101
  rej(err);
67
- stores.map(function (result, index, store) {
68
- var key = store[index][0];
69
- var value = store[index][1];
70
- var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
71
- dataMemory[memoryKey] = value;
72
- });
102
+ stores &&
103
+ stores.map(function (result, index, store) {
104
+ var key = store[index][0];
105
+ var value = store[index][1];
106
+ var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
107
+ dataMemory[memoryKey] = value;
108
+ });
73
109
  res();
74
110
  });
75
111
  });
@@ -98,3 +134,111 @@ var StorageHelper = /** @class */ (function () {
98
134
  return StorageHelper;
99
135
  }());
100
136
  export { StorageHelper };
137
+ var AsyncStorageClass = /** @class */ (function () {
138
+ function AsyncStorageClass() {
139
+ this.syncPromise = null;
140
+ }
141
+ /**
142
+ * This is used to set a specific item in storage
143
+ * @param {string} key - the key for the item
144
+ * @param {object} value - the value
145
+ * @returns {string} value that was set
146
+ */
147
+ AsyncStorageClass.prototype.setItem = function (key, value) {
148
+ return __awaiter(this, void 0, void 0, function () {
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ if (!value) return [3 /*break*/, 2];
153
+ return [4 /*yield*/, AsyncStorage.setItem(MEMORY_KEY_PREFIX + key, value)];
154
+ case 1:
155
+ _a.sent();
156
+ dataMemory[key] = value;
157
+ _a.label = 2;
158
+ case 2: return [2 /*return*/];
159
+ }
160
+ });
161
+ });
162
+ };
163
+ /**
164
+ * This is used to get a specific key from storage
165
+ * @param {string} key - the key for the item
166
+ * This is used to clear the storage
167
+ * @returns {string} the data item
168
+ */
169
+ AsyncStorageClass.prototype.getItem = function (key) {
170
+ return __awaiter(this, void 0, void 0, function () {
171
+ return __generator(this, function (_a) {
172
+ return [2 /*return*/, Object.prototype.hasOwnProperty.call(dataMemory, key)
173
+ ? dataMemory[key]
174
+ : null];
175
+ });
176
+ });
177
+ };
178
+ /**
179
+ * This is used to remove an item from storage
180
+ * @param {string} key - the key being set
181
+ * @returns {string} value - value that was deleted
182
+ */
183
+ AsyncStorageClass.prototype.removeItem = function (key) {
184
+ return __awaiter(this, void 0, void 0, function () {
185
+ return __generator(this, function (_a) {
186
+ switch (_a.label) {
187
+ case 0: return [4 /*yield*/, AsyncStorage.removeItem(MEMORY_KEY_PREFIX + key)];
188
+ case 1:
189
+ _a.sent();
190
+ delete dataMemory[key];
191
+ return [2 /*return*/];
192
+ }
193
+ });
194
+ });
195
+ };
196
+ /**
197
+ * This is used to clear the storage
198
+ * @returns {string} nothing
199
+ */
200
+ AsyncStorageClass.prototype.clear = function () {
201
+ return __awaiter(this, void 0, void 0, function () {
202
+ return __generator(this, function (_a) {
203
+ dataMemory = {};
204
+ return [2 /*return*/];
205
+ });
206
+ });
207
+ };
208
+ /**
209
+ * Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
210
+ * @returns {void}
211
+ */
212
+ AsyncStorageClass.prototype.sync = function () {
213
+ return __awaiter(this, void 0, void 0, function () {
214
+ return __generator(this, function (_a) {
215
+ if (!this.syncPromise) {
216
+ this.syncPromise = new Promise(function (res, rej) {
217
+ AsyncStorage.getAllKeys(function (errKeys, keys) {
218
+ var _a;
219
+ if (errKeys)
220
+ rej(errKeys);
221
+ 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 : [];
222
+ AsyncStorage.multiGet(memoryKeys, function (err, stores) {
223
+ if (err)
224
+ rej(err);
225
+ stores &&
226
+ stores.map(function (result, index, store) {
227
+ var key = store[index][0];
228
+ var value = store[index][1];
229
+ var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
230
+ dataMemory[memoryKey] = value;
231
+ });
232
+ res();
233
+ });
234
+ });
235
+ });
236
+ }
237
+ return [2 /*return*/];
238
+ });
239
+ });
240
+ };
241
+ return AsyncStorageClass;
242
+ }());
243
+ // TODO: Add this to the react-native Amplify package.
244
+ export var 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,111 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ 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;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ import { PlatformNotSupportedError } from '../Errors';
40
+ var SessionStorageClass = /** @class */ (function () {
41
+ function SessionStorageClass() {
42
+ if (typeof window !== undefined) {
43
+ try {
44
+ this.storage = window === null || window === void 0 ? void 0 : window.sessionStorage;
45
+ }
46
+ catch (error) { }
47
+ }
48
+ }
49
+ /**
50
+ * This is used to set a specific item in storage
51
+ * @param {string} key - the key for the item
52
+ * @param {object} value - the value
53
+ * @returns {string} value that was set
54
+ */
55
+ SessionStorageClass.prototype.setItem = function (key, value) {
56
+ return __awaiter(this, void 0, void 0, function () {
57
+ return __generator(this, function (_a) {
58
+ if (!this.storage)
59
+ throw PlatformNotSupportedError;
60
+ this.storage.setItem(key, value);
61
+ return [2 /*return*/];
62
+ });
63
+ });
64
+ };
65
+ /**
66
+ * This is used to get a specific key from storage
67
+ * @param {string} key - the key for the item
68
+ * This is used to clear the storage
69
+ * @returns {string} the data item
70
+ */
71
+ SessionStorageClass.prototype.getItem = function (key) {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ return __generator(this, function (_a) {
74
+ if (!this.storage)
75
+ throw PlatformNotSupportedError;
76
+ return [2 /*return*/, this.storage.getItem(key)];
77
+ });
78
+ });
79
+ };
80
+ /**
81
+ * This is used to remove an item from storage
82
+ * @param {string} key - the key being set
83
+ * @returns {string} value - value that was deleted
84
+ */
85
+ SessionStorageClass.prototype.removeItem = function (key) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ return __generator(this, function (_a) {
88
+ if (!this.storage)
89
+ throw PlatformNotSupportedError;
90
+ this.storage.removeItem(key);
91
+ return [2 /*return*/];
92
+ });
93
+ });
94
+ };
95
+ /**
96
+ * This is used to clear the storage
97
+ * @returns {string} nothing
98
+ */
99
+ SessionStorageClass.prototype.clear = function () {
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ return __generator(this, function (_a) {
102
+ if (!this.storage)
103
+ throw PlatformNotSupportedError;
104
+ this.storage.clear();
105
+ return [2 /*return*/];
106
+ });
107
+ });
108
+ };
109
+ return SessionStorageClass;
110
+ }());
111
+ export var 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
  */
@@ -443,3 +443,4 @@ export var BackgroundProcessManagerState;
443
443
  */
444
444
  BackgroundProcessManagerState["Closed"] = "Closed";
445
445
  })(BackgroundProcessManagerState || (BackgroundProcessManagerState = {}));
446
+ 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 {};
@@ -11,8 +11,8 @@ var __values = (this && this.__values) || function(o) {
11
11
  };
12
12
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
13
13
  // SPDX-License-Identifier: Apache-2.0
14
- import { browserOrNode, isWebWorker } from '@aws-amplify/core';
15
14
  import Observable from 'zen-observable-ts';
15
+ import { browserOrNode, isWebWorker } from '../JS';
16
16
  var ReachabilityNavigator = /** @class */ (function () {
17
17
  function ReachabilityNavigator() {
18
18
  }
@@ -31,7 +31,8 @@ var ReachabilityNavigator = /** @class */ (function () {
31
31
  return function () {
32
32
  globalObj.removeEventListener('online', notifyOnline);
33
33
  globalObj.removeEventListener('offline', notifyOffline);
34
- ReachabilityNavigator._observers = ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
34
+ ReachabilityNavigator._observers =
35
+ ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
35
36
  };
36
37
  });
37
38
  };
@@ -40,7 +41,8 @@ var ReachabilityNavigator = /** @class */ (function () {
40
41
  var e_1, _a;
41
42
  var _loop_1 = function (observer) {
42
43
  if (observer.closed) {
43
- ReachabilityNavigator._observers = ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
44
+ ReachabilityNavigator._observers =
45
+ ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
44
46
  return "continue";
45
47
  }
46
48
  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 {};
@@ -3,17 +3,10 @@
3
3
  export function urlSafeEncode(str) {
4
4
  return str
5
5
  .split('')
6
- .map(function (char) {
7
- return char
8
- .charCodeAt(0)
9
- .toString(16)
10
- .padStart(2, '0');
11
- })
6
+ .map(function (char) { return char.charCodeAt(0).toString(16).padStart(2, '0'); })
12
7
  .join('');
13
8
  }
14
9
  export function urlSafeDecode(hex) {
15
- return hex
16
- .match(/.{2}/g)
17
- .map(function (char) { return String.fromCharCode(parseInt(char, 16)); })
18
- .join('');
10
+ var matchArr = hex.match(/.{2}/g) || [];
11
+ return matchArr.map(function (char) { return String.fromCharCode(parseInt(char, 16)); }).join('');
19
12
  }
@@ -0,0 +1,2 @@
1
+ import { ErrorParams } from '../../types';
2
+ export declare function asserts(assertion: boolean, errorParams: ErrorParams): asserts assertion;
@@ -0,0 +1,7 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { AmplifyError } from '../../Errors';
4
+ export function asserts(assertion, errorParams) {
5
+ if (!assertion)
6
+ throw new AmplifyError(errorParams);
7
+ }
@@ -3,4 +3,4 @@ import { HttpResponse, ErrorParser } from '../../types';
3
3
  * Get retry decider function
4
4
  * @param errorParser Function to load JavaScript error from HTTP response
5
5
  */
6
- export declare const getRetryDecider: (errorParser: ErrorParser) => (response?: HttpResponse, error?: Error) => Promise<boolean>;
6
+ export declare const getRetryDecider: (errorParser: ErrorParser) => (response?: HttpResponse, error?: unknown) => Promise<boolean>;