@aws-amplify/core 6.0.1-api-v6-models.9351bcf.0 → 6.0.1-api-v6-models.58f2536.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
@@ -3,10 +3,9 @@
3
3
  import { ConsoleLogger as Logger } from './Logger';
4
4
  import {
5
5
  OAuthConfig,
6
- AuthStandardAttributeKey,
7
6
  AuthConfigUserAttributes,
7
+ OAuthProvider,
8
8
  } from './singleton/Auth/types';
9
-
10
9
  import { ResourcesConfig } from './singleton/types';
11
10
 
12
11
  const logger = new Logger('parseAWSExports');
@@ -46,6 +45,7 @@ export const parseAWSExports = (
46
45
  aws_cognito_password_protection_settings,
47
46
  aws_cognito_verification_mechanisms,
48
47
  aws_cognito_signup_attributes,
48
+ aws_cognito_social_providers,
49
49
  aws_cognito_username_attributes,
50
50
  aws_mandatory_sign_in,
51
51
  aws_mobile_analytics_app_id,
@@ -57,6 +57,7 @@ export const parseAWSExports = (
57
57
  aws_user_pools_web_client_id,
58
58
  geo,
59
59
  oauth,
60
+ predictions,
60
61
  aws_cloud_logic_custom,
61
62
  Notifications,
62
63
  modelIntrospection,
@@ -188,15 +189,27 @@ export const parseAWSExports = (
188
189
  loginWithEmailEnabled || loginWithPhoneEnabled ? false : true,
189
190
  email: loginWithEmailEnabled,
190
191
  phone: loginWithPhoneEnabled,
191
- ...(oauth &&
192
- Object.keys(oauth).length > 0 && {
193
- oauth: getOAuthConfig(oauth),
194
- }),
195
192
  },
196
193
  },
197
194
  };
198
195
  }
199
196
 
197
+ const hasOAuthConfig = oauth ? Object.keys(oauth).length > 0 : false;
198
+ const hasSocialProviderConfig = aws_cognito_social_providers
199
+ ? aws_cognito_social_providers.length > 0
200
+ : false;
201
+ if (amplifyConfig.Auth && hasOAuthConfig) {
202
+ amplifyConfig.Auth.Cognito.loginWith = {
203
+ ...amplifyConfig.Auth.Cognito.loginWith,
204
+ oauth: {
205
+ ...getOAuthConfig(oauth),
206
+ ...(hasSocialProviderConfig && {
207
+ providers: parseSocialProviders(aws_cognito_social_providers),
208
+ }),
209
+ },
210
+ };
211
+ }
212
+
200
213
  // Storage
201
214
  if (aws_user_files_s3_bucket) {
202
215
  amplifyConfig.Storage = {
@@ -244,6 +257,25 @@ export const parseAWSExports = (
244
257
  };
245
258
  }
246
259
 
260
+ // Predictions
261
+ if (predictions) {
262
+ // map VoiceId from speechGenerator defaults to voiceId
263
+ const { VoiceId: voiceId } =
264
+ predictions?.convert?.speechGenerator?.defaults ?? {};
265
+ amplifyConfig.Predictions = voiceId
266
+ ? {
267
+ ...predictions,
268
+ convert: {
269
+ ...predictions.convert,
270
+ speechGenerator: {
271
+ ...predictions.convert.speechGenerator,
272
+ defaults: { voiceId },
273
+ },
274
+ },
275
+ }
276
+ : predictions;
277
+ }
278
+
247
279
  return amplifyConfig;
248
280
  };
249
281
 
@@ -263,3 +295,10 @@ const getOAuthConfig = ({
263
295
  redirectSignOut: getRedirectUrl(redirectSignOut),
264
296
  responseType,
265
297
  });
298
+
299
+ const parseSocialProviders = (aws_cognito_social_providers: string[]) => {
300
+ return aws_cognito_social_providers.map((provider: string) => {
301
+ const updatedProvider = provider.toLowerCase();
302
+ return updatedProvider.charAt(0).toUpperCase() + updatedProvider.slice(1);
303
+ }) as OAuthProvider[];
304
+ };
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export type KinesisProviderConfig = {
5
- Kinesis?: {
5
+ Kinesis: {
6
6
  region: string;
7
7
  bufferSize?: number;
8
8
  flushSize?: number;
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export type KinesisFirehoseProviderConfig = {
5
- KinesisFirehose?: {
5
+ KinesisFirehose: {
6
6
  region: string;
7
7
  bufferSize?: number;
8
8
  flushSize?: number;
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export type PersonalizeProviderConfig = {
5
- Personalize?: {
5
+ Personalize: {
6
6
  trackingId: string;
7
7
  region: string;
8
8
  flushSize?: number;
@@ -4,6 +4,10 @@
4
4
  import { amplifyUuid } from '../../../utils/amplifyUuid';
5
5
  import { PinpointRecordInput, PinpointSession } from '../types';
6
6
  import { resolveEndpointId } from '../utils';
7
+ import {
8
+ SESSION_START_EVENT,
9
+ SESSION_STOP_EVENT,
10
+ } from '../../../utils/sessionListener';
7
11
  import {
8
12
  BUFFER_SIZE,
9
13
  FLUSH_INTERVAL,
@@ -12,8 +16,7 @@ import {
12
16
  } from '../utils/constants';
13
17
  import { getEventBuffer } from '../utils/getEventBuffer';
14
18
 
15
- // TODO(v6) Refactor when we add support for session tracking & `autoTrack`
16
- let session: PinpointSession;
19
+ let session: PinpointSession | undefined;
17
20
 
18
21
  /**
19
22
  * @internal
@@ -28,7 +31,9 @@ export const record = async ({
28
31
  region,
29
32
  userAgentValue,
30
33
  }: PinpointRecordInput): Promise<void> => {
31
- const timestampISOString = new Date().toISOString();
34
+ let eventSession = session;
35
+ const currentTime = new Date();
36
+ const timestampISOString = currentTime.toISOString();
32
37
  const eventId = amplifyUuid();
33
38
 
34
39
  // Prepare event buffer if required
@@ -55,13 +60,25 @@ export const record = async ({
55
60
  });
56
61
 
57
62
  // Generate session if required
58
- if (!session) {
63
+ if (!eventSession || event.name === SESSION_START_EVENT) {
59
64
  const sessionId = amplifyUuid();
60
65
 
61
66
  session = {
62
67
  Id: sessionId,
63
68
  StartTimestamp: timestampISOString,
64
69
  };
70
+ eventSession = session;
71
+ }
72
+
73
+ // Terminate session when required
74
+ if (session && event.name === SESSION_STOP_EVENT) {
75
+ eventSession = {
76
+ ...session,
77
+ StopTimestamp: timestampISOString,
78
+ Duration:
79
+ currentTime.getTime() - new Date(session.StartTimestamp).getTime(),
80
+ };
81
+ session = undefined;
65
82
  }
66
83
 
67
84
  // Push event to buffer
@@ -69,7 +86,7 @@ export const record = async ({
69
86
  eventId,
70
87
  endpointId,
71
88
  event,
72
- session,
89
+ session: eventSession!,
73
90
  timestamp: timestampISOString,
74
91
  resendLimit: RESEND_LIMIT,
75
92
  });
@@ -13,7 +13,7 @@ export type SupportedCategory =
13
13
  type SupportedChannelType = 'APNS' | 'APNS_SANDBOX' | 'GCM' | 'IN_APP';
14
14
 
15
15
  export type PinpointProviderConfig = {
16
- Pinpoint?: {
16
+ Pinpoint: {
17
17
  appId: string;
18
18
  region: string;
19
19
  };
@@ -27,7 +27,9 @@ export type PinpointServiceOptions = {
27
27
 
28
28
  export type PinpointSession = {
29
29
  Id: string;
30
+ Duration?: number;
30
31
  StartTimestamp: string;
32
+ StopTimestamp?: string;
31
33
  };
32
34
 
33
35
  export type PinpointAnalyticsEvent = {
@@ -27,6 +27,10 @@ export class AmplifyClass {
27
27
  * Configures Amplify for use with your back-end resources.
28
28
  *
29
29
  * @remarks
30
+ * This API does not perform any merging of either `resourcesConfig` or `libraryOptions`. The most recently
31
+ * provided values will be used after configuration.
32
+ *
33
+ * @remarks
30
34
  * `configure` can be used to specify additional library options where available for supported categories.
31
35
  *
32
36
  * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
@@ -34,7 +38,7 @@ export class AmplifyClass {
34
38
  */
35
39
  configure(
36
40
  resourcesConfig: ResourcesConfig | LegacyConfig,
37
- libraryOptions: LibraryOptions = {}
41
+ libraryOptions?: LibraryOptions
38
42
  ): void {
39
43
  let resolvedResourceConfig: ResourcesConfig;
40
44
 
@@ -44,15 +48,11 @@ export class AmplifyClass {
44
48
  resolvedResourceConfig = resourcesConfig as ResourcesConfig;
45
49
  }
46
50
 
47
- this.resourcesConfig = mergeResourceConfig(
48
- this.resourcesConfig,
49
- resolvedResourceConfig
50
- );
51
+ this.resourcesConfig = resolvedResourceConfig;
51
52
 
52
- this.libraryOptions = mergeLibraryOptions(
53
- this.libraryOptions,
54
- libraryOptions
55
- );
53
+ if (libraryOptions) {
54
+ this.libraryOptions = libraryOptions;
55
+ }
56
56
 
57
57
  // Make resource config immutable
58
58
  this.resourcesConfig = deepFreeze(this.resourcesConfig);
@@ -87,46 +87,3 @@ export class AmplifyClass {
87
87
  * `Amplify` is responsible for orchestrating cross-category communication within the library.
88
88
  */
89
89
  export const Amplify = new AmplifyClass();
90
-
91
- // TODO(v6): validate until which level this will nested, during Amplify.configure API review.
92
- function mergeResourceConfig(
93
- existingConfig: ResourcesConfig,
94
- newConfig: ResourcesConfig
95
- ): ResourcesConfig {
96
- const resultConfig: Record<string, any> = {};
97
-
98
- for (const category of Object.keys(existingConfig)) {
99
- resultConfig[category] = existingConfig[category as keyof ResourcesConfig];
100
- }
101
-
102
- for (const key of Object.keys(newConfig)) {
103
- resultConfig[key] = {
104
- ...resultConfig[key],
105
- ...newConfig[key as keyof ResourcesConfig],
106
- };
107
- }
108
-
109
- return resultConfig;
110
- }
111
-
112
- function mergeLibraryOptions(
113
- existingConfig: LibraryOptions,
114
- newConfig: LibraryOptions
115
- ): LibraryOptions {
116
- const resultConfig: Record<string, any> = {};
117
-
118
- for (const category of Object.keys(existingConfig)) {
119
- resultConfig[category] = existingConfig[category as keyof LibraryOptions];
120
- }
121
-
122
- for (const key of Object.keys(newConfig).filter(key => key !== 'ssr')) {
123
- resultConfig[key] = {
124
- ...resultConfig[key],
125
- ...newConfig[key as Exclude<keyof LibraryOptions, 'ssr'>],
126
- };
127
- }
128
-
129
- resultConfig.ssr = newConfig.ssr;
130
-
131
- return resultConfig;
132
- }
@@ -6,7 +6,12 @@ import { KinesisProviderConfig } from '../../providers/kinesis/types';
6
6
  import { KinesisFirehoseProviderConfig } from '../../providers/kinesis-firehose/types';
7
7
  import { PersonalizeProviderConfig } from '../../providers/personalize/types';
8
8
 
9
- export type AnalyticsConfig = PinpointProviderConfig &
10
- KinesisProviderConfig &
11
- KinesisFirehoseProviderConfig &
12
- PersonalizeProviderConfig;
9
+ type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> &
10
+ U[keyof U];
11
+
12
+ export type AnalyticsConfig = AtLeastOne<
13
+ PinpointProviderConfig &
14
+ KinesisProviderConfig &
15
+ KinesisFirehoseProviderConfig &
16
+ PersonalizeProviderConfig
17
+ >;
@@ -166,10 +166,10 @@ export type OAuthConfig = {
166
166
  redirectSignIn: Array<string>;
167
167
  redirectSignOut: Array<string>;
168
168
  responseType: 'code' | 'token';
169
- providers?: Array<OAuthProviders | CustomProvider>;
169
+ providers?: Array<OAuthProvider | CustomProvider>;
170
170
  };
171
171
 
172
- type OAuthProviders = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
172
+ export type OAuthProvider = 'Google' | 'Facebook' | 'Amazon' | 'Apple';
173
173
  type CustomProvider = { custom: string };
174
174
 
175
175
  type CustomScope = string & {};
@@ -0,0 +1,61 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Defaults for ConvertConfig
5
+ type SpeechGeneratorDefaults = {
6
+ voiceId?: string;
7
+ };
8
+ type TranscriptionDefaults = {
9
+ language?: string;
10
+ };
11
+ type TranslateTextDefaults = {
12
+ sourceLanguage?: string;
13
+ targetLanguage?: string;
14
+ };
15
+
16
+ // Defaults for IdentifyConfig
17
+ type IdentifyEntitiesDefaults = {
18
+ collectionId?: string;
19
+ maxEntities?: number;
20
+ };
21
+ type IdentityLabelsDefaults = {
22
+ type?: string;
23
+ };
24
+ type IdentifyTextDefaults = {
25
+ format?: string;
26
+ };
27
+
28
+ // Defaults for InterpretConfig
29
+ type InterpretTextDefaults = {
30
+ type?: string;
31
+ };
32
+
33
+ type ConvertConfig = {
34
+ speechGenerator?: PredictionsProviderConfig<SpeechGeneratorDefaults>;
35
+ transcription?: PredictionsProviderConfig<TranscriptionDefaults>;
36
+ translateText?: PredictionsProviderConfig<TranslateTextDefaults>;
37
+ };
38
+
39
+ type IdentifyConfig = {
40
+ identifyEntities?: PredictionsProviderConfig<IdentifyEntitiesDefaults> & {
41
+ celebrityDetectionEnabled?: boolean;
42
+ };
43
+ identifyLabels?: PredictionsProviderConfig<IdentityLabelsDefaults>;
44
+ identifyText?: PredictionsProviderConfig<IdentifyTextDefaults>;
45
+ };
46
+
47
+ type InterpretConfig = {
48
+ interpretText?: PredictionsProviderConfig<InterpretTextDefaults>;
49
+ };
50
+
51
+ export type PredictionsProviderConfig<T> = {
52
+ region?: string;
53
+ proxy?: boolean;
54
+ defaults?: T;
55
+ };
56
+
57
+ export type PredictionsConfig = {
58
+ convert?: ConvertConfig;
59
+ identify?: IdentifyConfig;
60
+ interpret?: InterpretConfig;
61
+ };
@@ -13,6 +13,7 @@ import {
13
13
  CognitoIdentityPoolConfig,
14
14
  } from './Auth/types';
15
15
  import { GeoConfig } from './Geo/types';
16
+ import { PredictionsConfig } from './Predictions/types';
16
17
  import {
17
18
  LibraryStorageOptions,
18
19
  StorageAccessLevel,
@@ -34,7 +35,7 @@ export type ResourcesConfig = {
34
35
  Auth?: AuthConfig;
35
36
  Interactions?: InteractionsConfig;
36
37
  Notifications?: NotificationsConfig;
37
- // Predictions?: {};
38
+ Predictions?: PredictionsConfig;
38
39
  Storage?: StorageConfig;
39
40
  Geo?: GeoConfig;
40
41
  };
@@ -54,6 +55,7 @@ export {
54
55
  AuthUserPoolAndIdentityPoolConfig,
55
56
  GetCredentialsOptions,
56
57
  InteractionsConfig,
58
+ PredictionsConfig,
57
59
  StorageAccessLevel,
58
60
  StorageConfig,
59
61
  AnalyticsConfig,
@@ -0,0 +1,57 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { cryptoSecureRandomInt } from './cryptoSecureRandomInt';
5
+
6
+ /**
7
+ * Hex encoding strategy.
8
+ * Converts a word array to a hex string.
9
+ * @param {WordArray} wordArray The word array.
10
+ * @return {string} The hex string.
11
+ * @static
12
+ */
13
+ function hexStringify(wordArray: WordArray): string {
14
+ // Shortcuts
15
+ const words = wordArray.words;
16
+ const sigBytes = wordArray.sigBytes;
17
+
18
+ // Convert
19
+ const hexChars: string[] = [];
20
+ for (let i = 0; i < sigBytes; i++) {
21
+ const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
22
+ hexChars.push((bite >>> 4).toString(16));
23
+ hexChars.push((bite & 0x0f).toString(16));
24
+ }
25
+
26
+ return hexChars.join('');
27
+ }
28
+
29
+ export default class WordArray {
30
+ words: number[] = [];
31
+ sigBytes: number;
32
+
33
+ constructor(words?: number[], sigBytes?: number) {
34
+ let Words = words;
35
+ Words = this.words = Words || [];
36
+
37
+ if (sigBytes !== undefined) {
38
+ this.sigBytes = sigBytes;
39
+ } else {
40
+ this.sigBytes = Words.length * 4;
41
+ }
42
+ }
43
+
44
+ random(nBytes: number): WordArray {
45
+ const words: number[] = [];
46
+
47
+ for (let i = 0; i < nBytes; i += 4) {
48
+ words.push(cryptoSecureRandomInt());
49
+ }
50
+
51
+ return new WordArray(words, nBytes);
52
+ }
53
+
54
+ toString(): string {
55
+ return hexStringify(this);
56
+ }
57
+ }
@@ -4,6 +4,6 @@
4
4
  import './polyfill';
5
5
  import { v4 } from 'uuid';
6
6
 
7
- const amplifyUuid = v4;
7
+ const amplifyUuid: () => string = v4;
8
8
 
9
9
  export { amplifyUuid };
@@ -0,0 +1,14 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { getCrypto } from './globalHelpers';
5
+
6
+ /*
7
+ * Cryptographically secure pseudorandom number generator
8
+ * As Math.random() is cryptographically not safe to use
9
+ */
10
+ export function cryptoSecureRandomInt() {
11
+ const crypto = getCrypto();
12
+ const randomResult = crypto.getRandomValues(new Uint32Array(1))[0];
13
+ return randomResult;
14
+ }
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Standard session start & stop event names
5
+ export const SESSION_START_EVENT = '_session.start';
6
+ export const SESSION_STOP_EVENT = '_session.stop';
@@ -2,5 +2,6 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { SessionListener } from './SessionListener';
5
+ export { SESSION_START_EVENT, SESSION_STOP_EVENT } from './constants';
5
6
 
6
7
  export const sessionListener = new SessionListener();