@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
@@ -25,7 +25,7 @@ export interface ICredentials {
25
25
  * @private
26
26
  * Internal use of Amplify only
27
27
  */
28
- export type DelayFunction = (attempt: number, args?: any[], error?: Error) => number | false;
28
+ export type DelayFunction = (attempt: number, args?: any[], error?: unknown) => number | false;
29
29
  export interface LoggingProvider {
30
30
  getProviderName(): string;
31
31
  getCategoryName(): string;
@@ -44,3 +44,33 @@ export interface CloudWatchDataTracker {
44
44
  logEvents: InputLogEvent[];
45
45
  verifiedLogGroup?: LogGroup;
46
46
  }
47
+ export type ErrorParams = {
48
+ message: string;
49
+ name: string;
50
+ recoverySuggestion?: string;
51
+ underlyingError?: Error | unknown;
52
+ };
53
+ export type AmplifyErrorMap<ErrorCode extends string> = {
54
+ [name in ErrorCode]: {
55
+ message: string;
56
+ recoverySuggestion?: string;
57
+ };
58
+ };
59
+ export type ServiceError = {
60
+ name: string;
61
+ message: string;
62
+ };
63
+ export interface KeyValueStorageInterface {
64
+ setItem(key: string, value: string): Promise<void>;
65
+ getItem(key: string): Promise<string | null>;
66
+ removeItem(key: string): Promise<void>;
67
+ clear(): Promise<void>;
68
+ }
69
+ export type SameSite = 'strict' | 'lax' | 'none';
70
+ export type CookieStorageData = {
71
+ domain?: string;
72
+ path?: string;
73
+ expires?: number;
74
+ secure?: boolean;
75
+ sameSite?: SameSite;
76
+ };
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,24 +3,25 @@ export declare class AmplifyClass {
3
3
  private _components;
4
4
  private _config;
5
5
  private _modules;
6
- Auth: any;
7
- Analytics: any;
8
- API: any;
9
- Credentials: any;
10
- Storage: any;
11
- I18n: any;
12
- Cache: any;
13
- PubSub: any;
14
- Interactions: any;
15
- Pushnotification: any;
16
- UI: any;
17
- XR: any;
18
- Predictions: any;
19
- DataStore: any;
20
- Geo: any;
21
- Notifications: any;
6
+ Auth: null;
7
+ Analytics: null;
8
+ API: null;
9
+ Credentials: null;
10
+ Storage: null;
11
+ I18n: null;
12
+ Cache: null;
13
+ PubSub: null;
14
+ Interactions: null;
15
+ Pushnotification: null;
16
+ UI: null;
17
+ XR: null;
18
+ Predictions: null;
19
+ DataStore: null;
20
+ Geo: null;
21
+ Notifications: null;
22
22
  Logger: typeof LoggerClass;
23
- ServiceWorker: any;
23
+ ServiceWorker: null;
24
+ get config(): any;
24
25
  register(comp: any): void;
25
26
  configure(config?: any): {};
26
27
  addPluggable(pluggable: any): void;
@@ -14,6 +14,7 @@ var __read = (this && this.__read) || function (o, n) {
14
14
  }
15
15
  return ar;
16
16
  };
17
+ // @ts-nocheck
17
18
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
18
19
  // SPDX-License-Identifier: Apache-2.0
19
20
  import { ConsoleLogger as LoggerClass } from './Logger';
@@ -46,6 +47,14 @@ var AmplifyClass = /** @class */ (function () {
46
47
  this.Logger = LoggerClass;
47
48
  this.ServiceWorker = null;
48
49
  }
50
+ Object.defineProperty(AmplifyClass.prototype, "config", {
51
+ // TODO: update "any" when types are determined
52
+ get: function () {
53
+ return Object.assign({}, this._config);
54
+ },
55
+ enumerable: false,
56
+ configurable: true
57
+ });
49
58
  AmplifyClass.prototype.register = function (comp) {
50
59
  logger.debug('component registered in amplify', comp);
51
60
  this._components.push(comp);
@@ -1,4 +1,5 @@
1
- import { Endpoint, EndpointResolverOptions, Headers, HttpRequest, HttpResponse } from '../../clients';
1
+ import { Endpoint, Headers, HttpRequest, HttpResponse } from '../../clients';
2
+ import { DefaultConfigOptions } from '../../clients/types';
2
3
  /**
3
4
  * A Cognito Identity-specific transfer handler that does NOT sign requests, and
4
5
  * disables caching.
@@ -9,15 +10,7 @@ export declare const cognitoIdentityTransferHandler: (request: HttpRequest, opti
9
10
  /**
10
11
  * @internal
11
12
  */
12
- export declare const defaultConfig: {
13
- service: string;
14
- endpointResolver: ({ region }: EndpointResolverOptions) => {
15
- url: URL;
16
- };
17
- retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
18
- computeDelay: (attempt: number) => number;
19
- userAgentValue: string;
20
- };
13
+ export declare const defaultConfig: DefaultConfigOptions;
21
14
  /**
22
15
  * @internal
23
16
  */
@@ -1,23 +1,9 @@
1
- import { Endpoint, HttpResponse } from '../../clients';
1
+ import { HttpResponse } from '../../clients';
2
2
  import type { GetCredentialsForIdentityCommandInput as GetCredentialsForIdentityInput, GetCredentialsForIdentityCommandOutput as GetCredentialsForIdentityOutput } from './types';
3
3
  export type { GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const getCredentialsForIdentity: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").ServiceClientOptions & {
8
- service: string;
9
- endpointResolver: ({ region }: import("../../clients").EndpointResolverOptions) => {
10
- url: URL;
11
- };
12
- retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
- computeDelay: (attempt: number) => number;
14
- userAgentValue: string;
15
- }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
- retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
17
- computeDelay?: (attempt: number) => number;
18
- userAgentValue?: string;
19
- service?: string;
20
- endpointResolver?: ((options: import("../../clients").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients").EndpointResolverOptions) => {
21
- url: URL;
22
- });
7
+ export declare const getCredentialsForIdentity: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients").ServiceClientOptions>, string> & {
8
+ [x: string]: unknown;
23
9
  }, input: GetCredentialsForIdentityInput) => Promise<GetCredentialsForIdentityOutput>;
@@ -65,14 +65,14 @@ var getCredentialsForIdentityDeserializer = function (response) { return __await
65
65
  }
66
66
  });
67
67
  }); };
68
- var deserializeCredentials = function (output) {
69
- if (output === void 0) { output = {}; }
70
- return ({
71
- AccessKeyId: output['AccessKeyId'],
72
- SecretKey: output['SecretKey'],
73
- SessionToken: output['SessionToken'],
74
- Expiration: new Date(output['Expiration'] * 1000),
75
- });
68
+ var deserializeCredentials = function (_a) {
69
+ var _b = _a === void 0 ? {} : _a, AccessKeyId = _b.AccessKeyId, SecretKey = _b.SecretKey, SessionToken = _b.SessionToken, Expiration = _b.Expiration;
70
+ return {
71
+ AccessKeyId: AccessKeyId,
72
+ SecretKey: SecretKey,
73
+ SessionToken: SessionToken,
74
+ Expiration: Expiration && new Date(Expiration * 1000),
75
+ };
76
76
  };
77
77
  /**
78
78
  * @internal
@@ -1,23 +1,9 @@
1
- import { Endpoint, HttpResponse } from '../../clients';
1
+ import { HttpResponse } from '../../clients';
2
2
  import { GetIdCommandInput as GetIdInput, GetIdCommandOutput as GetIdOutput } from './types';
3
3
  export type { GetIdInput, GetIdOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const getId: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").ServiceClientOptions & {
8
- service: string;
9
- endpointResolver: ({ region }: import("../../clients").EndpointResolverOptions) => {
10
- url: URL;
11
- };
12
- retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
- computeDelay: (attempt: number) => number;
14
- userAgentValue: string;
15
- }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
- retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
17
- computeDelay?: (attempt: number) => number;
18
- userAgentValue?: string;
19
- service?: string;
20
- endpointResolver?: ((options: import("../../clients").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients").EndpointResolverOptions) => {
21
- url: URL;
22
- });
7
+ export declare const getId: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients").ServiceClientOptions>, string> & {
8
+ [x: string]: unknown;
23
9
  }, input: GetIdInput) => Promise<GetIdOutput>;
@@ -1,16 +1,8 @@
1
- import type { EndpointResolverOptions, Headers } from '../../clients/types';
1
+ import type { DefaultConfigOptions, Headers } from '../../clients/types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare const defaultConfig: {
6
- service: string;
7
- endpointResolver: ({ region }: EndpointResolverOptions) => {
8
- url: URL;
9
- };
10
- retryDecider: (response?: import("../../clients/types").HttpResponse, error?: Error) => Promise<boolean>;
11
- computeDelay: (attempt: number) => number;
12
- userAgentValue: string;
13
- };
5
+ export declare const defaultConfig: DefaultConfigOptions;
14
6
  /**
15
7
  * @internal
16
8
  */
@@ -1,23 +1,9 @@
1
- import { Endpoint, HttpResponse } from '../../clients/types';
1
+ import { HttpResponse } from '../../clients/types';
2
2
  import type { GetInAppMessagesCommandInput as GetInAppMessagesInput, GetInAppMessagesCommandOutput as GetInAppMessagesOutput } from './types';
3
3
  export type { GetInAppMessagesInput, GetInAppMessagesOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const getInAppMessages: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & {
8
- service: string;
9
- endpointResolver: ({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
- url: URL;
11
- };
12
- retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
- computeDelay: (attempt: number) => number;
14
- userAgentValue: string;
15
- }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
- retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
17
- computeDelay?: (attempt: number) => number;
18
- userAgentValue?: string;
19
- service?: string;
20
- endpointResolver?: ((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
21
- url: URL;
22
- });
7
+ export declare const getInAppMessages: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions>, string> & {
8
+ [x: string]: unknown;
23
9
  }, input: GetInAppMessagesInput) => Promise<GetInAppMessagesOutput>;
@@ -42,7 +42,7 @@ import { extendedEncodeURIComponent } from '../../clients/middleware/signing/uti
42
42
  import { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients/serde';
43
43
  import { defaultConfig, getSharedHeaders } from './base';
44
44
  var getInAppMessagesSerializer = function (_a, endpoint) {
45
- var ApplicationId = _a.ApplicationId, EndpointId = _a.EndpointId;
45
+ var _b = _a.ApplicationId, ApplicationId = _b === void 0 ? '' : _b, _c = _a.EndpointId, EndpointId = _c === void 0 ? '' : _c;
46
46
  var headers = getSharedHeaders();
47
47
  var url = new URL(endpoint.url);
48
48
  url.pathname = "v1/apps/".concat(extendedEncodeURIComponent(ApplicationId), "/endpoints/").concat(extendedEncodeURIComponent(EndpointId), "/inappmessages");
@@ -1,23 +1,9 @@
1
- import { Endpoint, HttpResponse } from '../../clients/types';
1
+ import { HttpResponse } from '../../clients/types';
2
2
  import type { PutEventsCommandInput as PutEventsInput, PutEventsCommandOutput as PutEventsOutput } from './types';
3
3
  export type { PutEventsInput, PutEventsOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const putEvents: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & {
8
- service: string;
9
- endpointResolver: ({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
- url: URL;
11
- };
12
- retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
- computeDelay: (attempt: number) => number;
14
- userAgentValue: string;
15
- }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
- retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
17
- computeDelay?: (attempt: number) => number;
18
- userAgentValue?: string;
19
- service?: string;
20
- endpointResolver?: ((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
21
- url: URL;
22
- });
7
+ export declare const putEvents: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions>, string> & {
8
+ [x: string]: unknown;
23
9
  }, input: PutEventsInput) => Promise<PutEventsOutput>;
@@ -36,13 +36,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
37
  }
38
38
  };
39
+ import { asserts } from '../../Util/errors/AssertError';
39
40
  import { authenticatedHandler } from '../../clients/handlers/authenticated';
40
41
  import { composeServiceApi } from '../../clients/internal/composeServiceApi';
41
42
  import { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent';
42
43
  import { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients/serde';
44
+ import { APPLICATION_ID_EXCEPTION } from '../../constants';
43
45
  import { defaultConfig, getSharedHeaders } from './base';
44
46
  var putEventsSerializer = function (_a, endpoint) {
45
47
  var ApplicationId = _a.ApplicationId, EventsRequest = _a.EventsRequest;
48
+ asserts(!!ApplicationId, {
49
+ name: APPLICATION_ID_EXCEPTION,
50
+ message: 'ApplicationId is required for putEvents',
51
+ });
46
52
  var headers = getSharedHeaders();
47
53
  var url = new URL(endpoint.url);
48
54
  url.pathname = "v1/apps/".concat(extendedEncodeURIComponent(ApplicationId), "/events");
@@ -1,23 +1,9 @@
1
- import { Endpoint, HttpResponse } from '../../clients/types';
1
+ import { HttpResponse } from '../../clients/types';
2
2
  import type { UpdateEndpointCommandInput as UpdateEndpointInput, UpdateEndpointCommandOutput as UpdateEndpointOutput } from './types';
3
3
  export type { UpdateEndpointInput, UpdateEndpointOutput };
4
4
  /**
5
5
  * @internal
6
6
  */
7
- export declare const updateEndpoint: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & {
8
- service: string;
9
- endpointResolver: ({ region }: import("../../clients/types").EndpointResolverOptions) => {
10
- url: URL;
11
- };
12
- retryDecider: (response?: HttpResponse, error?: Error) => Promise<boolean>;
13
- computeDelay: (attempt: number) => number;
14
- userAgentValue: string;
15
- }, "retryDecider" | "computeDelay" | "userAgentValue" | "service" | "endpointResolver"> & {
16
- retryDecider?: ((response?: HttpResponse, error?: unknown) => Promise<boolean>) & ((response?: HttpResponse, error?: Error) => Promise<boolean>);
17
- computeDelay?: (attempt: number) => number;
18
- userAgentValue?: string;
19
- service?: string;
20
- endpointResolver?: ((options: import("../../clients/types").EndpointResolverOptions, input?: any) => Endpoint) & (({ region }: import("../../clients/types").EndpointResolverOptions) => {
21
- url: URL;
22
- });
7
+ export declare const updateEndpoint: (config: Omit<import("../../clients").UserAgentOptions & import("../../clients").RetryOptions<HttpResponse> & import("../../clients").SigningOptions & import("../../clients/types").ServiceClientOptions & Partial<Record<string, unknown> & import("../../clients/types").ServiceClientOptions>, string> & {
8
+ [x: string]: unknown;
23
9
  }, input: UpdateEndpointInput) => Promise<UpdateEndpointOutput>;
@@ -42,11 +42,11 @@ import { extendedEncodeURIComponent } from '../../clients/middleware/signing/uti
42
42
  import { parseJsonBody, parseJsonError, parseMetadata, } from '../../clients/serde';
43
43
  import { defaultConfig, getSharedHeaders } from './base';
44
44
  var updateEndpointSerializer = function (_a, endpoint) {
45
- var ApplicationId = _a.ApplicationId, EndpointId = _a.EndpointId, EndpointRequest = _a.EndpointRequest;
45
+ var _b = _a.ApplicationId, ApplicationId = _b === void 0 ? '' : _b, _c = _a.EndpointId, EndpointId = _c === void 0 ? '' : _c, EndpointRequest = _a.EndpointRequest;
46
46
  var headers = getSharedHeaders();
47
47
  var url = new URL(endpoint.url);
48
48
  url.pathname = "v1/apps/".concat(extendedEncodeURIComponent(ApplicationId), "/endpoints/").concat(extendedEncodeURIComponent(EndpointId));
49
- var body = JSON.stringify(EndpointRequest !== null && EndpointRequest !== void 0 ? EndpointRequest : {});
49
+ var body = JSON.stringify(EndpointRequest);
50
50
  return { method: 'PUT', headers: headers, url: url, body: body };
51
51
  };
52
52
  var updateEndpointDeserializer = function (response) { return __awaiter(void 0, void 0, void 0, function () {
@@ -0,0 +1,154 @@
1
+ import AsyncStorage from '@react-native-async-storage/async-storage';
2
+ import { StorageCache } from './StorageCache';
3
+ import { CacheConfig, CacheItem, CacheItemOptions, ICache } from './types';
4
+ export declare class AsyncStorageCache extends StorageCache implements ICache {
5
+ /**
6
+ * initialize the cache
7
+ *
8
+ * @param {Object} config - the configuration of the cache
9
+ */
10
+ constructor(config?: CacheConfig);
11
+ /**
12
+ * decrease current size of the cache
13
+ * @private
14
+ * @param amount - the amount of the cache size which needs to be decreased
15
+ */
16
+ _decreaseCurSizeInBytes(amount: number): Promise<void>;
17
+ /**
18
+ * increase current size of the cache
19
+ * @private
20
+ * @param amount - the amount of the cache szie which need to be increased
21
+ */
22
+ _increaseCurSizeInBytes(amount: number): Promise<void>;
23
+ /**
24
+ * update the visited time if item has been visited
25
+ * @private
26
+ * @param item - the item which need to be refreshed
27
+ * @param prefixedKey - the key of the item
28
+ *
29
+ * @return the refreshed item
30
+ */
31
+ _refreshItem(item: CacheItem, prefixedKey: string): Promise<CacheItem>;
32
+ /**
33
+ * check wether item is expired
34
+ * @private
35
+ * @param key - the key of the item
36
+ *
37
+ * @return true if the item is expired.
38
+ */
39
+ _isExpired(key: string): Promise<boolean>;
40
+ /**
41
+ * delete item from cache
42
+ * @private
43
+ * @param prefixedKey - the key of the item
44
+ * @param size - optional, the byte size of the item
45
+ */
46
+ _removeItem(prefixedKey: string, size?: number): Promise<void>;
47
+ /**
48
+ * put item into cache
49
+ * @private
50
+ * @param prefixedKey - the key of the item
51
+ * @param itemData - the value of the item
52
+ * @param itemSizeInBytes - the byte size of the item
53
+ */
54
+ _setItem(prefixedKey: string, item: any): Promise<void>;
55
+ /**
56
+ * total space needed when poping out items
57
+ * @private
58
+ * @param itemSize
59
+ *
60
+ * @return total space needed
61
+ */
62
+ _sizeToPop(itemSize: number): Promise<number>;
63
+ /**
64
+ * see whether cache is full
65
+ * @private
66
+ * @param itemSize
67
+ *
68
+ * @return true if cache is full
69
+ */
70
+ _isCacheFull(itemSize: number): Promise<boolean>;
71
+ /**
72
+ * scan the storage and find out all the keys owned by this cache
73
+ * also clean the expired keys while scanning
74
+ * @private
75
+ * @return array of keys
76
+ */
77
+ _findValidKeys(): Promise<string[]>;
78
+ /**
79
+ * get all the items we have, sort them by their priority,
80
+ * if priority is same, sort them by their last visited time
81
+ * pop out items from the low priority (5 is the lowest)
82
+ * @private
83
+ * @param keys - all the keys in this cache
84
+ * @param sizeToPop - the total size of the items which needed to be poped out
85
+ */
86
+ _popOutItems(keys: string[], sizeToPop: number): Promise<void>;
87
+ /**
88
+ * Set item into cache. You can put number, string, boolean or object.
89
+ * The cache will first check whether has the same key.
90
+ * If it has, it will delete the old item and then put the new item in
91
+ * The cache will pop out items if it is full
92
+ * You can specify the cache item options. The cache will abort and output a warning:
93
+ * If the key is invalid
94
+ * If the size of the item exceeds itemMaxSize.
95
+ * If the value is undefined
96
+ * If incorrect cache item configuration
97
+ * If error happened with browser storage
98
+ *
99
+ * @param {String} key - the key of the item
100
+ * @param {Object} value - the value of the item
101
+ * @param {Object} [options] - optional, the specified meta-data
102
+ * @return {Promise}
103
+ */
104
+ setItem(key: string, value: any, options: Record<string, any>): Promise<void>;
105
+ /**
106
+ * Get item from cache. It will return null if item doesn’t exist or it has been expired.
107
+ * If you specified callback function in the options,
108
+ * then the function will be executed if no such item in the cache
109
+ * and finally put the return value into cache.
110
+ * Please make sure the callback function will return the value you want to put into the cache.
111
+ * The cache will abort output a warning:
112
+ * If the key is invalid
113
+ * If error happened with AsyncStorage
114
+ *
115
+ * @param {String} key - the key of the item
116
+ * @param {Object} [options] - the options of callback function
117
+ * @return {Promise} - return a promise resolves to be the value of the item
118
+ */
119
+ getItem(key: string, options: CacheItemOptions): Promise<any>;
120
+ /**
121
+ * remove item from the cache
122
+ * The cache will abort output a warning:
123
+ * If error happened with AsyncStorage
124
+ * @param {String} key - the key of the item
125
+ * @return {Promise}
126
+ */
127
+ removeItem(key: string): Promise<void>;
128
+ /**
129
+ * clear the entire cache
130
+ * The cache will abort output a warning:
131
+ * If error happened with AsyncStorage
132
+ * @return {Promise}
133
+ */
134
+ clear(): Promise<void>;
135
+ /**
136
+ * return the current size of the cache
137
+ * @return {Promise}
138
+ */
139
+ getCacheCurSize(): Promise<number>;
140
+ /**
141
+ * Return all the keys in the cache.
142
+ * Will return an empty array if error happend.
143
+ * @return {Promise}
144
+ */
145
+ getAllKeys(): Promise<string[]>;
146
+ /**
147
+ * Return a new instance of cache with customized configuration.
148
+ * @param {Object} config - the customized configuration
149
+ * @return {Object} - the new instance of Cache
150
+ */
151
+ createInstance(config: CacheConfig): ICache;
152
+ }
153
+ declare const instance: ICache;
154
+ export { AsyncStorage, instance as Cache };