@aws-amplify/core 6.0.1-api-v6-models.9351bcf.0 → 6.0.1-api-v6-models.891fe0d.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 (360) hide show
  1. package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.js +4 -21
  2. package/lib/BackgroundProcessManager/BackgroundProcessManager.js +126 -245
  3. package/lib/Cache/StorageCache.js +32 -92
  4. package/lib/Cache/StorageCache.native.js +38 -140
  5. package/lib/Cache/StorageCacheCommon.js +271 -600
  6. package/lib/Cache/index.js +1 -1
  7. package/lib/Cache/utils/CacheList.js +42 -66
  8. package/lib/Cache/utils/cacheHelpers.js +6 -8
  9. package/lib/Cache/utils/errorHelpers.js +6 -7
  10. package/lib/Hub/index.js +34 -74
  11. package/lib/I18n/I18n.js +24 -39
  12. package/lib/I18n/errorHelpers.js +4 -5
  13. package/lib/I18n/index.js +24 -27
  14. package/lib/I18n/types.js +3 -4
  15. package/lib/Logger/ConsoleLogger.js +53 -129
  16. package/lib/Mutex/Mutex.js +15 -19
  17. package/lib/Platform/customUserAgent.js +13 -26
  18. package/lib/Platform/detectFramework.js +12 -13
  19. package/lib/Platform/detection/Angular.js +4 -5
  20. package/lib/Platform/detection/Expo.js +1 -1
  21. package/lib/Platform/detection/Next.js +1 -1
  22. package/lib/Platform/detection/Nuxt.js +1 -1
  23. package/lib/Platform/detection/React.js +5 -5
  24. package/lib/Platform/detection/Svelte.js +2 -2
  25. package/lib/Platform/detection/Vue.js +1 -1
  26. package/lib/Platform/detection/Web.js +1 -1
  27. package/lib/Platform/detection/helpers.js +7 -7
  28. package/lib/Platform/detection/index.js +13 -13
  29. package/lib/Platform/index.js +26 -55
  30. package/lib/Platform/types.d.ts +1 -1
  31. package/lib/Platform/types.js +1 -1
  32. package/lib/Platform/version.d.ts +1 -1
  33. package/lib/Platform/version.js +1 -1
  34. package/lib/Reachability/Reachability.js +20 -48
  35. package/lib/Reachability/Reachability.native.js +12 -16
  36. package/lib/ServiceWorker/ServiceWorker.js +80 -136
  37. package/lib/ServiceWorker/errorHelpers.js +6 -7
  38. package/lib/Signer/DateUtils.d.ts +9 -0
  39. package/lib/Signer/DateUtils.js +19 -28
  40. package/lib/Signer/Signer.d.ts +9 -0
  41. package/lib/Signer/Signer.js +58 -54
  42. package/lib/adapterCore/error/AmplifyServerContextError.js +9 -27
  43. package/lib/adapterCore/serverContext/serverContext.js +8 -8
  44. package/lib/adapterCore/serverContext/serverContextRegistry.js +6 -6
  45. package/lib/awsClients/cognitoIdentity/base.js +25 -73
  46. package/lib/awsClients/cognitoIdentity/getCredentialsForIdentity.js +24 -68
  47. package/lib/awsClients/cognitoIdentity/getId.js +19 -62
  48. package/lib/awsClients/pinpoint/base.js +12 -15
  49. package/lib/awsClients/pinpoint/errorHelpers.js +4 -5
  50. package/lib/awsClients/pinpoint/getInAppMessages.js +24 -68
  51. package/lib/awsClients/pinpoint/putEvents.js +26 -70
  52. package/lib/awsClients/pinpoint/updateEndpoint.js +28 -72
  53. package/lib/clients/endpoints/getDnsSuffix.js +7 -29
  54. package/lib/clients/handlers/authenticated.js +5 -5
  55. package/lib/clients/handlers/fetch.js +41 -98
  56. package/lib/clients/handlers/unauthenticated.js +4 -4
  57. package/lib/clients/internal/composeServiceApi.js +17 -67
  58. package/lib/clients/internal/composeTransferHandler.js +9 -11
  59. package/lib/clients/middleware/retry/defaultRetryDecider.js +18 -75
  60. package/lib/clients/middleware/retry/isClockSkewError.js +2 -4
  61. package/lib/clients/middleware/retry/jitteredBackoff.js +5 -5
  62. package/lib/clients/middleware/retry/middleware.js +61 -125
  63. package/lib/clients/middleware/signing/middleware.js +24 -86
  64. package/lib/clients/middleware/signing/signer/signatureV4/index.js +0 -1
  65. package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +21 -56
  66. package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js +14 -25
  67. package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +7 -7
  68. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +8 -30
  69. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +11 -38
  70. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +13 -17
  71. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +5 -8
  72. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +2 -2
  73. package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -3
  74. package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +7 -11
  75. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +9 -10
  76. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +4 -6
  77. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +8 -8
  78. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +15 -16
  79. package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +2 -4
  80. package/lib/clients/middleware/signing/utils/extendedEncodeURIComponent.js +3 -5
  81. package/lib/clients/middleware/signing/utils/getSkewCorrectedDate.js +1 -3
  82. package/lib/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +2 -2
  83. package/lib/clients/middleware/signing/utils/isClockSkewed.js +4 -6
  84. package/lib/clients/middleware/userAgent/middleware.js +14 -63
  85. package/lib/clients/serde/json.js +30 -96
  86. package/lib/clients/serde/responseInfo.js +12 -18
  87. package/lib/clients/utils/memoization.js +3 -3
  88. package/lib/constants.js +1 -1
  89. package/lib/errors/AmplifyError.js +9 -28
  90. package/lib/errors/PlatformNotSupportedError.js +7 -24
  91. package/lib/errors/createAssertionFunction.js +12 -15
  92. package/lib/errors/errorHelpers.js +7 -8
  93. package/lib/index.d.ts +1 -1
  94. package/lib/libraryUtils.d.ts +4 -0
  95. package/lib/libraryUtils.js +13 -3
  96. package/lib/parseAWSExports.js +109 -100
  97. package/lib/providers/kinesis/types/kinesis.d.ts +1 -1
  98. package/lib/providers/kinesis-firehose/types/kinesis-firehose.d.ts +1 -1
  99. package/lib/providers/personalize/types/personalize.d.ts +1 -1
  100. package/lib/providers/pinpoint/apis/flushEvents.js +8 -8
  101. package/lib/providers/pinpoint/apis/record.js +58 -93
  102. package/lib/providers/pinpoint/apis/updateEndpoint.js +65 -112
  103. package/lib/providers/pinpoint/types/pinpoint.d.ts +3 -1
  104. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +105 -196
  105. package/lib/providers/pinpoint/utils/cacheEndpointId.js +12 -49
  106. package/lib/providers/pinpoint/utils/getCacheKey.js +2 -2
  107. package/lib/providers/pinpoint/utils/getEndpointId.js +7 -51
  108. package/lib/providers/pinpoint/utils/getEventBuffer.js +19 -21
  109. package/lib/providers/pinpoint/utils/isAppInForeground.js +1 -1
  110. package/lib/providers/pinpoint/utils/isAppInForeground.native.js +2 -2
  111. package/lib/providers/pinpoint/utils/resolveEndpointId.js +20 -71
  112. package/lib/singleton/Amplify.d.ts +4 -0
  113. package/lib/singleton/Amplify.js +21 -103
  114. package/lib/singleton/Analytics/types.d.ts +5 -1
  115. package/lib/singleton/Auth/index.js +48 -115
  116. package/lib/singleton/Auth/types.d.ts +2 -2
  117. package/lib/singleton/Auth/utils/errorHelpers.js +7 -8
  118. package/lib/singleton/Auth/utils/index.js +18 -19
  119. package/lib/singleton/Predictions/types.d.ts +49 -0
  120. package/lib/singleton/Predictions/types.js +4 -0
  121. package/lib/singleton/apis/clearCredentials.js +1 -1
  122. package/lib/singleton/apis/fetchAuthSession.js +3 -3
  123. package/lib/singleton/apis/internal/fetchAuthSession.js +1 -1
  124. package/lib/singleton/apis/server/fetchAuthSession.js +3 -3
  125. package/lib/singleton/types.d.ts +3 -1
  126. package/lib/storage/CookieStorage.js +29 -99
  127. package/lib/storage/CookieStorage.native.js +5 -22
  128. package/lib/storage/DefaultStorage.js +6 -23
  129. package/lib/storage/DefaultStorage.native.js +18 -64
  130. package/lib/storage/InMemoryStorage.js +17 -23
  131. package/lib/storage/KeyValueStorage.js +24 -80
  132. package/lib/storage/SessionStorage.js +6 -23
  133. package/lib/storage/index.js +4 -4
  134. package/lib/storage/utils.js +7 -11
  135. package/lib/tsconfig.tsbuildinfo +1 -1
  136. package/lib/utils/WordArray.d.ts +7 -0
  137. package/lib/utils/WordArray.js +49 -0
  138. package/lib/utils/amplifyUrl/index.js +2 -2
  139. package/lib/utils/amplifyUrl/polyfill.native.js +1 -1
  140. package/lib/utils/amplifyUuid/index.d.ts +1 -1
  141. package/lib/utils/amplifyUuid/index.js +2 -2
  142. package/lib/utils/amplifyUuid/polyfill.native.js +1 -1
  143. package/lib/utils/convert/base64/base64Decoder.js +2 -2
  144. package/lib/utils/convert/base64/base64Encoder.js +5 -6
  145. package/lib/utils/convert/base64/bytesToString.js +1 -1
  146. package/lib/utils/cryptoSecureRandomInt.d.ts +1 -0
  147. package/lib/utils/cryptoSecureRandomInt.js +16 -0
  148. package/lib/utils/deepFreeze.js +6 -28
  149. package/lib/utils/generateRandomString.js +4 -4
  150. package/lib/utils/getClientInfo/getClientInfo.android.js +7 -7
  151. package/lib/utils/getClientInfo/getClientInfo.ios.js +12 -12
  152. package/lib/utils/getClientInfo/getClientInfo.js +16 -16
  153. package/lib/utils/globalHelpers/index.js +4 -4
  154. package/lib/utils/globalHelpers/index.native.js +6 -6
  155. package/lib/utils/isBrowser.js +1 -3
  156. package/lib/utils/isWebWorker.js +2 -2
  157. package/lib/utils/retry/NonRetryableError.js +5 -23
  158. package/lib/utils/retry/isNonRetryableError.js +2 -2
  159. package/lib/utils/retry/jitteredBackoff.js +6 -7
  160. package/lib/utils/retry/jitteredExponentialRetry.js +4 -7
  161. package/lib/utils/retry/retry.js +50 -140
  162. package/lib/utils/sessionListener/SessionListener.js +17 -19
  163. package/lib/utils/sessionListener/SessionListener.native.js +18 -22
  164. package/lib/utils/sessionListener/constants.d.ts +2 -0
  165. package/lib/utils/sessionListener/constants.js +8 -0
  166. package/lib/utils/sessionListener/index.d.ts +1 -0
  167. package/lib/utils/sessionListener/index.js +5 -2
  168. package/lib/utils/urlSafeDecode.js +2 -2
  169. package/lib/utils/urlSafeEncode.js +1 -1
  170. package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.js +4 -22
  171. package/lib-esm/BackgroundProcessManager/BackgroundProcessManager.js +124 -244
  172. package/lib-esm/Cache/StorageCache.js +26 -87
  173. package/lib-esm/Cache/StorageCache.native.js +33 -136
  174. package/lib-esm/Cache/StorageCacheCommon.js +267 -597
  175. package/lib-esm/Cache/constants.js +2 -2
  176. package/lib-esm/Cache/index.js +1 -1
  177. package/lib-esm/Cache/utils/CacheList.js +41 -66
  178. package/lib-esm/Cache/utils/cacheHelpers.js +5 -7
  179. package/lib-esm/Cache/utils/errorHelpers.js +6 -7
  180. package/lib-esm/Hub/index.js +34 -75
  181. package/lib-esm/I18n/I18n.js +23 -39
  182. package/lib-esm/I18n/errorHelpers.js +4 -5
  183. package/lib-esm/I18n/index.js +21 -25
  184. package/lib-esm/I18n/types.js +3 -5
  185. package/lib-esm/Logger/ConsoleLogger.js +52 -128
  186. package/lib-esm/Mutex/Mutex.js +15 -20
  187. package/lib-esm/Platform/customUserAgent.js +13 -26
  188. package/lib-esm/Platform/detectFramework.js +11 -12
  189. package/lib-esm/Platform/detection/Angular.js +3 -4
  190. package/lib-esm/Platform/detection/React.js +4 -4
  191. package/lib-esm/Platform/detection/Svelte.js +1 -1
  192. package/lib-esm/Platform/detection/helpers.js +7 -7
  193. package/lib-esm/Platform/detection/index.js +3 -3
  194. package/lib-esm/Platform/index.js +23 -52
  195. package/lib-esm/Platform/types.d.ts +1 -1
  196. package/lib-esm/Platform/types.js +1 -1
  197. package/lib-esm/Platform/version.d.ts +1 -1
  198. package/lib-esm/Platform/version.js +1 -1
  199. package/lib-esm/Reachability/Reachability.js +18 -46
  200. package/lib-esm/Reachability/Reachability.native.js +10 -15
  201. package/lib-esm/ServiceWorker/ServiceWorker.js +74 -131
  202. package/lib-esm/ServiceWorker/errorHelpers.js +6 -7
  203. package/lib-esm/Signer/DateUtils.d.ts +9 -0
  204. package/lib-esm/Signer/DateUtils.js +20 -29
  205. package/lib-esm/Signer/Signer.d.ts +9 -0
  206. package/lib-esm/Signer/Signer.js +54 -51
  207. package/lib-esm/adapterCore/error/AmplifyServerContextError.js +8 -27
  208. package/lib-esm/adapterCore/serverContext/serverContext.js +6 -6
  209. package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +7 -7
  210. package/lib-esm/awsClients/cognitoIdentity/base.js +21 -69
  211. package/lib-esm/awsClients/cognitoIdentity/getCredentialsForIdentity.js +22 -66
  212. package/lib-esm/awsClients/cognitoIdentity/getId.js +17 -60
  213. package/lib-esm/awsClients/pinpoint/base.js +8 -11
  214. package/lib-esm/awsClients/pinpoint/errorHelpers.js +4 -5
  215. package/lib-esm/awsClients/pinpoint/getInAppMessages.js +19 -63
  216. package/lib-esm/awsClients/pinpoint/putEvents.js +20 -64
  217. package/lib-esm/awsClients/pinpoint/updateEndpoint.js +23 -67
  218. package/lib-esm/clients/endpoints/getDnsSuffix.js +6 -28
  219. package/lib-esm/clients/endpoints/partitions.js +2 -2
  220. package/lib-esm/clients/handlers/authenticated.js +1 -1
  221. package/lib-esm/clients/handlers/fetch.js +40 -97
  222. package/lib-esm/clients/handlers/unauthenticated.js +1 -1
  223. package/lib-esm/clients/internal/composeServiceApi.js +17 -67
  224. package/lib-esm/clients/internal/composeTransferHandler.js +9 -11
  225. package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -74
  226. package/lib-esm/clients/middleware/retry/isClockSkewError.js +2 -4
  227. package/lib-esm/clients/middleware/retry/jitteredBackoff.js +4 -4
  228. package/lib-esm/clients/middleware/retry/middleware.js +61 -125
  229. package/lib-esm/clients/middleware/signing/middleware.js +21 -83
  230. package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js +17 -17
  231. package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
  232. package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +17 -52
  233. package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js +10 -21
  234. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +5 -5
  235. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +8 -30
  236. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +11 -38
  237. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +8 -12
  238. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +5 -8
  239. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +1 -1
  240. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -3
  241. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +5 -9
  242. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +5 -6
  243. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +4 -6
  244. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +6 -6
  245. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +13 -14
  246. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +1 -3
  247. package/lib-esm/clients/middleware/signing/utils/extendedEncodeURIComponent.js +3 -5
  248. package/lib-esm/clients/middleware/signing/utils/getSkewCorrectedDate.js +1 -3
  249. package/lib-esm/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +1 -1
  250. package/lib-esm/clients/middleware/signing/utils/isClockSkewed.js +3 -5
  251. package/lib-esm/clients/middleware/userAgent/middleware.js +14 -63
  252. package/lib-esm/clients/serde/json.js +29 -95
  253. package/lib-esm/clients/serde/responseInfo.js +11 -17
  254. package/lib-esm/clients/utils/memoization.js +3 -3
  255. package/lib-esm/constants.js +5 -5
  256. package/lib-esm/errors/AmplifyError.js +9 -29
  257. package/lib-esm/errors/PlatformNotSupportedError.js +5 -23
  258. package/lib-esm/errors/createAssertionFunction.js +11 -14
  259. package/lib-esm/errors/errorHelpers.js +6 -7
  260. package/lib-esm/index.d.ts +1 -1
  261. package/lib-esm/libraryUtils.d.ts +4 -0
  262. package/lib-esm/libraryUtils.js +4 -0
  263. package/lib-esm/parseAWSExports.js +108 -99
  264. package/lib-esm/providers/kinesis/types/kinesis.d.ts +1 -1
  265. package/lib-esm/providers/kinesis-firehose/types/kinesis-firehose.d.ts +1 -1
  266. package/lib-esm/providers/personalize/types/personalize.d.ts +1 -1
  267. package/lib-esm/providers/pinpoint/apis/flushEvents.js +6 -6
  268. package/lib-esm/providers/pinpoint/apis/record.js +54 -89
  269. package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +61 -108
  270. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +3 -1
  271. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +102 -194
  272. package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +10 -47
  273. package/lib-esm/providers/pinpoint/utils/constants.js +4 -4
  274. package/lib-esm/providers/pinpoint/utils/getCacheKey.js +2 -2
  275. package/lib-esm/providers/pinpoint/utils/getEndpointId.js +5 -49
  276. package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +17 -19
  277. package/lib-esm/providers/pinpoint/utils/isAppInForeground.js +1 -1
  278. package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +1 -1
  279. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +16 -67
  280. package/lib-esm/singleton/Amplify.d.ts +4 -0
  281. package/lib-esm/singleton/Amplify.js +18 -101
  282. package/lib-esm/singleton/Analytics/types.d.ts +5 -1
  283. package/lib-esm/singleton/Auth/index.js +48 -116
  284. package/lib-esm/singleton/Auth/types.d.ts +2 -2
  285. package/lib-esm/singleton/Auth/utils/errorHelpers.js +7 -8
  286. package/lib-esm/singleton/Auth/utils/index.js +16 -17
  287. package/lib-esm/singleton/Predictions/types.d.ts +49 -0
  288. package/lib-esm/singleton/Predictions/types.js +3 -0
  289. package/lib-esm/singleton/apis/fetchAuthSession.js +1 -1
  290. package/lib-esm/singleton/apis/internal/fetchAuthSession.js +1 -1
  291. package/lib-esm/singleton/apis/server/fetchAuthSession.js +1 -1
  292. package/lib-esm/singleton/types.d.ts +3 -1
  293. package/lib-esm/storage/CookieStorage.js +28 -99
  294. package/lib-esm/storage/CookieStorage.native.js +4 -22
  295. package/lib-esm/storage/DefaultStorage.js +4 -22
  296. package/lib-esm/storage/DefaultStorage.native.js +17 -64
  297. package/lib-esm/storage/InMemoryStorage.js +17 -24
  298. package/lib-esm/storage/KeyValueStorage.js +23 -80
  299. package/lib-esm/storage/SessionStorage.js +4 -22
  300. package/lib-esm/storage/index.js +3 -3
  301. package/lib-esm/storage/utils.js +6 -10
  302. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  303. package/lib-esm/utils/WordArray.d.ts +7 -0
  304. package/lib-esm/utils/WordArray.js +46 -0
  305. package/lib-esm/utils/amplifyUrl/index.js +2 -2
  306. package/lib-esm/utils/amplifyUuid/index.d.ts +1 -1
  307. package/lib-esm/utils/amplifyUuid/index.js +1 -1
  308. package/lib-esm/utils/convert/base64/base64Decoder.js +2 -2
  309. package/lib-esm/utils/convert/base64/base64Encoder.js +4 -5
  310. package/lib-esm/utils/convert/base64/bytesToString.js +1 -1
  311. package/lib-esm/utils/cryptoSecureRandomInt.d.ts +1 -0
  312. package/lib-esm/utils/cryptoSecureRandomInt.js +12 -0
  313. package/lib-esm/utils/deepFreeze.js +6 -28
  314. package/lib-esm/utils/generateRandomString.js +4 -4
  315. package/lib-esm/utils/getClientInfo/getClientInfo.android.js +5 -5
  316. package/lib-esm/utils/getClientInfo/getClientInfo.ios.js +10 -10
  317. package/lib-esm/utils/getClientInfo/getClientInfo.js +15 -15
  318. package/lib-esm/utils/globalHelpers/index.js +3 -3
  319. package/lib-esm/utils/globalHelpers/index.native.js +4 -4
  320. package/lib-esm/utils/isBrowser.js +1 -3
  321. package/lib-esm/utils/isWebWorker.js +2 -2
  322. package/lib-esm/utils/retry/NonRetryableError.js +5 -24
  323. package/lib-esm/utils/retry/constants.js +1 -1
  324. package/lib-esm/utils/retry/isNonRetryableError.js +2 -2
  325. package/lib-esm/utils/retry/jitteredBackoff.js +5 -6
  326. package/lib-esm/utils/retry/jitteredExponentialRetry.js +1 -4
  327. package/lib-esm/utils/retry/retry.js +48 -138
  328. package/lib-esm/utils/sessionListener/SessionListener.js +16 -19
  329. package/lib-esm/utils/sessionListener/SessionListener.native.js +17 -22
  330. package/lib-esm/utils/sessionListener/constants.d.ts +2 -0
  331. package/lib-esm/utils/sessionListener/constants.js +5 -0
  332. package/lib-esm/utils/sessionListener/index.d.ts +1 -0
  333. package/lib-esm/utils/sessionListener/index.js +2 -1
  334. package/lib-esm/utils/urlSafeDecode.js +2 -2
  335. package/lib-esm/utils/urlSafeEncode.js +1 -1
  336. package/package.json +11 -24
  337. package/src/Cache/types/index.ts +4 -4
  338. package/src/Platform/types.ts +1 -1
  339. package/src/Platform/version.ts +1 -1
  340. package/src/Signer/DateUtils.ts +10 -2
  341. package/src/Signer/Signer.ts +9 -2
  342. package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -1
  343. package/src/index.ts +1 -0
  344. package/src/libraryUtils.ts +7 -1
  345. package/src/parseAWSExports.ts +45 -6
  346. package/src/providers/kinesis/types/kinesis.ts +1 -1
  347. package/src/providers/kinesis-firehose/types/kinesis-firehose.ts +1 -1
  348. package/src/providers/personalize/types/personalize.ts +1 -1
  349. package/src/providers/pinpoint/apis/record.ts +22 -5
  350. package/src/providers/pinpoint/types/pinpoint.ts +3 -1
  351. package/src/singleton/Amplify.ts +9 -52
  352. package/src/singleton/Analytics/types.ts +9 -4
  353. package/src/singleton/Auth/types.ts +2 -2
  354. package/src/singleton/Predictions/types.ts +61 -0
  355. package/src/singleton/types.ts +3 -1
  356. package/src/utils/WordArray.ts +57 -0
  357. package/src/utils/amplifyUuid/index.ts +1 -1
  358. package/src/utils/cryptoSecureRandomInt.ts +14 -0
  359. package/src/utils/sessionListener/constants.ts +6 -0
  360. package/src/utils/sessionListener/index.ts +1 -0
@@ -1,61 +1,24 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
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
4
  Object.defineProperty(exports, "__esModule", { value: true });
41
5
  exports.cacheEndpointId = void 0;
42
- var __1 = require("../../..");
43
- var getCacheKey_1 = require("./getCacheKey");
6
+ const __1 = require("../../..");
7
+ const getCacheKey_1 = require("./getCacheKey");
44
8
  /**
45
9
  * Writes an endpoint id to a long-lived cache.
46
10
  *
47
11
  * @internal
48
12
  */
49
- var cacheEndpointId = function (appId, category, endpointId) { return __awaiter(void 0, void 0, void 0, function () {
50
- var cacheKey, ttl, expiration;
51
- return __generator(this, function (_a) {
52
- cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);
53
- ttl = 1000 * 60 * 60 * 24 * 365 * 100;
54
- expiration = new Date().getTime() + ttl;
55
- return [2 /*return*/, __1.Cache.setItem(cacheKey, endpointId, {
56
- expires: expiration,
57
- priority: 1,
58
- })];
13
+ const cacheEndpointId = async (appId, category, endpointId) => {
14
+ const cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);
15
+ // Set a longer TTL to avoid endpoint id being deleted after the default TTL (3 days)
16
+ // Also set its priority to the highest to reduce its chance of being deleted when cache is full
17
+ const ttl = 1000 * 60 * 60 * 24 * 365 * 100; // 100 years
18
+ const expiration = new Date().getTime() + ttl;
19
+ return __1.Cache.setItem(cacheKey, endpointId, {
20
+ expires: expiration,
21
+ priority: 1,
59
22
  });
60
- }); };
23
+ };
61
24
  exports.cacheEndpointId = cacheEndpointId;
@@ -3,11 +3,11 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.getCacheKey = void 0;
6
- var PROVIDER_NAME = 'pinpoint';
6
+ const PROVIDER_NAME = 'pinpoint';
7
7
  /**
8
8
  * Returns a unique cache key for a particular category/appId combination.
9
9
  *
10
10
  * @internal
11
11
  */
12
- var getCacheKey = function (appId, category) { return "".concat(category, ":").concat(PROVIDER_NAME, ":").concat(appId); };
12
+ const getCacheKey = (appId, category) => `${category}:${PROVIDER_NAME}:${appId}`;
13
13
  exports.getCacheKey = getCacheKey;
@@ -1,62 +1,18 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
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
4
  Object.defineProperty(exports, "__esModule", { value: true });
41
5
  exports.getEndpointId = void 0;
42
- var __1 = require("../../..");
43
- var getCacheKey_1 = require("./getCacheKey");
6
+ const __1 = require("../../..");
7
+ const getCacheKey_1 = require("./getCacheKey");
44
8
  /**
45
9
  * Returns an endpoint id from cache or `undefined` if not found.
46
10
  *
47
11
  * @internal
48
12
  */
49
- var getEndpointId = function (appId, category) { return __awaiter(void 0, void 0, void 0, function () {
50
- var cacheKey, cachedEndpointId;
51
- return __generator(this, function (_a) {
52
- switch (_a.label) {
53
- case 0:
54
- cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);
55
- return [4 /*yield*/, __1.Cache.getItem(cacheKey)];
56
- case 1:
57
- cachedEndpointId = _a.sent();
58
- return [2 /*return*/, cachedEndpointId !== null && cachedEndpointId !== void 0 ? cachedEndpointId : undefined];
59
- }
60
- });
61
- }); };
13
+ const getEndpointId = async (appId, category) => {
14
+ const cacheKey = (0, getCacheKey_1.getCacheKey)(appId, category);
15
+ const cachedEndpointId = await __1.Cache.getItem(cacheKey);
16
+ return cachedEndpointId ?? undefined;
17
+ };
62
18
  exports.getEndpointId = getEndpointId;
@@ -3,41 +3,39 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.getEventBuffer = void 0;
6
- var PinpointEventBuffer_1 = require("./PinpointEventBuffer");
7
- var constants_1 = require("./constants");
6
+ const PinpointEventBuffer_1 = require("./PinpointEventBuffer");
7
+ const constants_1 = require("./constants");
8
8
  // Map of buffers by region -> appId
9
- var eventBufferMap = {};
9
+ const eventBufferMap = {};
10
10
  /**
11
11
  * Returns a PinpointEventBuffer instance for the specified region & app ID, creating one if it does not yet exist.
12
12
  *
13
13
  * @internal
14
14
  */
15
- var getEventBuffer = function (_a) {
16
- var _b;
17
- var appId = _a.appId, _c = _a.bufferSize, bufferSize = _c === void 0 ? constants_1.BUFFER_SIZE : _c, credentials = _a.credentials, _d = _a.flushInterval, flushInterval = _d === void 0 ? constants_1.FLUSH_INTERVAL : _d, _e = _a.flushSize, flushSize = _e === void 0 ? constants_1.FLUSH_SIZE : _e, identityId = _a.identityId, region = _a.region, _f = _a.resendLimit, resendLimit = _f === void 0 ? constants_1.RESEND_LIMIT : _f, userAgentValue = _a.userAgentValue;
18
- if ((_b = eventBufferMap[region]) === null || _b === void 0 ? void 0 : _b[appId]) {
19
- var buffer_1 = eventBufferMap[region][appId];
15
+ const getEventBuffer = ({ appId, bufferSize = constants_1.BUFFER_SIZE, credentials, flushInterval = constants_1.FLUSH_INTERVAL, flushSize = constants_1.FLUSH_SIZE, identityId, region, resendLimit = constants_1.RESEND_LIMIT, userAgentValue }) => {
16
+ if (eventBufferMap[region]?.[appId]) {
17
+ const buffer = eventBufferMap[region][appId];
20
18
  /*
21
19
  If the identity has changed flush out the buffer and create a new instance. The old instance will be garbage
22
20
  collected.
23
21
  */
24
- if (buffer_1.identityHasChanged(identityId)) {
25
- buffer_1.flush();
22
+ if (buffer.identityHasChanged(identityId)) {
23
+ buffer.flush();
26
24
  }
27
25
  else {
28
- return buffer_1;
26
+ return buffer;
29
27
  }
30
28
  }
31
- var buffer = new PinpointEventBuffer_1.PinpointEventBuffer({
32
- appId: appId,
33
- bufferSize: bufferSize,
34
- credentials: credentials,
35
- flushInterval: flushInterval,
36
- flushSize: flushSize,
37
- identityId: identityId,
38
- region: region,
39
- resendLimit: resendLimit,
40
- userAgentValue: userAgentValue
29
+ const buffer = new PinpointEventBuffer_1.PinpointEventBuffer({
30
+ appId,
31
+ bufferSize,
32
+ credentials,
33
+ flushInterval,
34
+ flushSize,
35
+ identityId,
36
+ region,
37
+ resendLimit,
38
+ userAgentValue
41
39
  });
42
40
  if (!eventBufferMap[region]) {
43
41
  eventBufferMap[region] = {};
@@ -3,5 +3,5 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.isAppInForeground = void 0;
6
- var isAppInForeground = function () { return true; };
6
+ const isAppInForeground = () => true;
7
7
  exports.isAppInForeground = isAppInForeground;
@@ -4,6 +4,6 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.isAppInForeground = void 0;
6
6
  // @ts-ignore: missing type definition
7
- var react_native_1 = require("react-native");
8
- var isAppInForeground = function () { return react_native_1.AppState.currentState === 'active'; };
7
+ const react_native_1 = require("react-native");
8
+ const isAppInForeground = () => react_native_1.AppState.currentState === 'active';
9
9
  exports.isAppInForeground = isAppInForeground;
@@ -1,85 +1,34 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
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
4
  Object.defineProperty(exports, "__esModule", { value: true });
41
5
  exports.resolveEndpointId = void 0;
42
- var errors_1 = require("../../../errors");
43
- var types_1 = require("../../../types");
44
- var apis_1 = require("../apis");
45
- var getEndpointId_1 = require("./getEndpointId");
6
+ const errors_1 = require("../../../errors");
7
+ const types_1 = require("../../../types");
8
+ const apis_1 = require("../apis");
9
+ const getEndpointId_1 = require("./getEndpointId");
46
10
  /**
47
11
  * Resolves an endpoint id from cache or prepare via updateEndpoint if one does not already exist,
48
12
  * which will generate and cache an endpoint id between calls.
49
13
  *
50
14
  * @internal
51
15
  */
52
- var resolveEndpointId = function (_a) {
53
- var address = _a.address, appId = _a.appId, category = _a.category, channelType = _a.channelType, credentials = _a.credentials, identityId = _a.identityId, region = _a.region, userAgentValue = _a.userAgentValue;
54
- return __awaiter(void 0, void 0, void 0, function () {
55
- var endpointId;
56
- return __generator(this, function (_b) {
57
- switch (_b.label) {
58
- case 0: return [4 /*yield*/, (0, getEndpointId_1.getEndpointId)(appId, category)];
59
- case 1:
60
- endpointId = _b.sent();
61
- if (!!endpointId) return [3 /*break*/, 4];
62
- return [4 /*yield*/, (0, apis_1.updateEndpoint)({
63
- address: address,
64
- appId: appId,
65
- category: category,
66
- channelType: channelType,
67
- credentials: credentials,
68
- identityId: identityId,
69
- region: region,
70
- userAgentValue: userAgentValue,
71
- })];
72
- case 2:
73
- _b.sent();
74
- return [4 /*yield*/, (0, getEndpointId_1.getEndpointId)(appId, category)];
75
- case 3:
76
- endpointId = _b.sent();
77
- _b.label = 4;
78
- case 4:
79
- (0, errors_1.assert)(!!endpointId, types_1.AmplifyErrorCode.NoEndpointId);
80
- return [2 /*return*/, endpointId];
81
- }
16
+ const resolveEndpointId = async ({ address, appId, category, channelType, credentials, identityId, region, userAgentValue, }) => {
17
+ let endpointId = await (0, getEndpointId_1.getEndpointId)(appId, category);
18
+ if (!endpointId) {
19
+ await (0, apis_1.updateEndpoint)({
20
+ address,
21
+ appId,
22
+ category,
23
+ channelType,
24
+ credentials,
25
+ identityId,
26
+ region,
27
+ userAgentValue,
82
28
  });
83
- });
29
+ endpointId = await (0, getEndpointId_1.getEndpointId)(appId, category);
30
+ }
31
+ (0, errors_1.assert)(!!endpointId, types_1.AmplifyErrorCode.NoEndpointId);
32
+ return endpointId;
84
33
  };
85
34
  exports.resolveEndpointId = resolveEndpointId;
@@ -14,6 +14,10 @@ export declare class AmplifyClass {
14
14
  * Configures Amplify for use with your back-end resources.
15
15
  *
16
16
  * @remarks
17
+ * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
18
+ * provided values will be used after configuration.
19
+ *
20
+ * @remarks
17
21
  * `configure` can be used to specify additional library options where available for supported categories.
18
22
  *
19
23
  * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
@@ -1,36 +1,14 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __values = (this && this.__values) || function(o) {
14
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
- if (m) return m.call(o);
16
- if (o && typeof o.length === "number") return {
17
- next: function () {
18
- if (o && i >= o.length) o = void 0;
19
- return { value: o && o[i++], done: !o };
20
- }
21
- };
22
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
- };
24
2
  Object.defineProperty(exports, "__esModule", { value: true });
25
3
  exports.Amplify = exports.AmplifyClass = void 0;
26
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
5
  // SPDX-License-Identifier: Apache-2.0
28
- var Auth_1 = require("./Auth");
29
- var Hub_1 = require("../Hub");
30
- var parseAWSExports_1 = require("../parseAWSExports");
31
- var utils_1 = require("../utils");
32
- var AmplifyClass = /** @class */ (function () {
33
- function AmplifyClass() {
6
+ const Auth_1 = require("./Auth");
7
+ const Hub_1 = require("../Hub");
8
+ const parseAWSExports_1 = require("../parseAWSExports");
9
+ const utils_1 = require("../utils");
10
+ class AmplifyClass {
11
+ constructor() {
34
12
  this.resourcesConfig = {};
35
13
  this.libraryOptions = {};
36
14
  this.Auth = new Auth_1.AuthClass();
@@ -39,22 +17,27 @@ var AmplifyClass = /** @class */ (function () {
39
17
  * Configures Amplify for use with your back-end resources.
40
18
  *
41
19
  * @remarks
20
+ * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
21
+ * provided values will be used after configuration.
22
+ *
23
+ * @remarks
42
24
  * `configure` can be used to specify additional library options where available for supported categories.
43
25
  *
44
26
  * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
45
27
  * @param libraryOptions - Additional options for customizing the behavior of the library.
46
28
  */
47
- AmplifyClass.prototype.configure = function (resourcesConfig, libraryOptions) {
48
- if (libraryOptions === void 0) { libraryOptions = {}; }
49
- var resolvedResourceConfig;
50
- if (Object.keys(resourcesConfig).some(function (key) { return key.startsWith('aws_'); })) {
29
+ configure(resourcesConfig, libraryOptions) {
30
+ let resolvedResourceConfig;
31
+ if (Object.keys(resourcesConfig).some(key => key.startsWith('aws_'))) {
51
32
  resolvedResourceConfig = (0, parseAWSExports_1.parseAWSExports)(resourcesConfig);
52
33
  }
53
34
  else {
54
35
  resolvedResourceConfig = resourcesConfig;
55
36
  }
56
- this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resolvedResourceConfig);
57
- this.libraryOptions = mergeLibraryOptions(this.libraryOptions, libraryOptions);
37
+ this.resourcesConfig = resolvedResourceConfig;
38
+ if (libraryOptions) {
39
+ this.libraryOptions = libraryOptions;
40
+ }
58
41
  // Make resource config immutable
59
42
  this.resourcesConfig = (0, utils_1.deepFreeze)(this.resourcesConfig);
60
43
  this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
@@ -62,17 +45,16 @@ var AmplifyClass = /** @class */ (function () {
62
45
  event: 'configure',
63
46
  data: resourcesConfig,
64
47
  }, 'Configure', Hub_1.AMPLIFY_SYMBOL);
65
- };
48
+ }
66
49
  /**
67
50
  * Provides access to the current back-end resource configuration for the Library.
68
51
  *
69
52
  * @returns Returns the immutable back-end resource configuration.
70
53
  */
71
- AmplifyClass.prototype.getConfig = function () {
54
+ getConfig() {
72
55
  return this.resourcesConfig;
73
- };
74
- return AmplifyClass;
75
- }());
56
+ }
57
+ }
76
58
  exports.AmplifyClass = AmplifyClass;
77
59
  /**
78
60
  * The `Amplify` utility is used to configure the library.
@@ -81,67 +63,3 @@ exports.AmplifyClass = AmplifyClass;
81
63
  * `Amplify` is responsible for orchestrating cross-category communication within the library.
82
64
  */
83
65
  exports.Amplify = new AmplifyClass();
84
- // TODO(v6): validate until which level this will nested, during Amplify.configure API review.
85
- function mergeResourceConfig(existingConfig, newConfig) {
86
- var e_1, _a, e_2, _b;
87
- var resultConfig = {};
88
- try {
89
- for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
90
- var category = _d.value;
91
- resultConfig[category] = existingConfig[category];
92
- }
93
- }
94
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
95
- finally {
96
- try {
97
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
98
- }
99
- finally { if (e_1) throw e_1.error; }
100
- }
101
- try {
102
- for (var _e = __values(Object.keys(newConfig)), _f = _e.next(); !_f.done; _f = _e.next()) {
103
- var key = _f.value;
104
- resultConfig[key] = __assign(__assign({}, resultConfig[key]), newConfig[key]);
105
- }
106
- }
107
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
108
- finally {
109
- try {
110
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
111
- }
112
- finally { if (e_2) throw e_2.error; }
113
- }
114
- return resultConfig;
115
- }
116
- function mergeLibraryOptions(existingConfig, newConfig) {
117
- var e_3, _a, e_4, _b;
118
- var resultConfig = {};
119
- try {
120
- for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
121
- var category = _d.value;
122
- resultConfig[category] = existingConfig[category];
123
- }
124
- }
125
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
126
- finally {
127
- try {
128
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
129
- }
130
- finally { if (e_3) throw e_3.error; }
131
- }
132
- try {
133
- for (var _e = __values(Object.keys(newConfig).filter(function (key) { return key !== 'ssr'; })), _f = _e.next(); !_f.done; _f = _e.next()) {
134
- var key = _f.value;
135
- resultConfig[key] = __assign(__assign({}, resultConfig[key]), newConfig[key]);
136
- }
137
- }
138
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
139
- finally {
140
- try {
141
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
142
- }
143
- finally { if (e_4) throw e_4.error; }
144
- }
145
- resultConfig.ssr = newConfig.ssr;
146
- return resultConfig;
147
- }
@@ -2,4 +2,8 @@ import { PinpointProviderConfig } from '../../providers/pinpoint/types';
2
2
  import { KinesisProviderConfig } from '../../providers/kinesis/types';
3
3
  import { KinesisFirehoseProviderConfig } from '../../providers/kinesis-firehose/types';
4
4
  import { PersonalizeProviderConfig } from '../../providers/personalize/types';
5
- export type AnalyticsConfig = PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig;
5
+ type AtLeastOne<T, U = {
6
+ [K in keyof T]: Pick<T, K>;
7
+ }> = Partial<T> & U[keyof U];
8
+ export type AnalyticsConfig = AtLeastOne<PinpointProviderConfig & KinesisProviderConfig & KinesisFirehoseProviderConfig & PersonalizeProviderConfig>;
9
+ export {};