@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,154 +1,64 @@
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
- var __read = (this && this.__read) || function (o, n) {
41
- var m = typeof Symbol === "function" && o[Symbol.iterator];
42
- if (!m) return o;
43
- var i = m.call(o), r, ar = [], e;
44
- try {
45
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
46
- }
47
- catch (error) { e = { error: error }; }
48
- finally {
49
- try {
50
- if (r && !r.done && (m = i["return"])) m.call(i);
51
- }
52
- finally { if (e) throw e.error; }
53
- }
54
- return ar;
55
- };
56
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
58
- if (ar || !(i in from)) {
59
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
60
- ar[i] = from[i];
61
- }
62
- }
63
- return to.concat(ar || Array.prototype.slice.call(from));
64
- };
65
4
  Object.defineProperty(exports, "__esModule", { value: true });
66
5
  exports.retry = void 0;
67
- var ConsoleLogger_1 = require("../../Logger/ConsoleLogger");
68
- var isNonRetryableError_1 = require("./isNonRetryableError");
69
- var logger = new ConsoleLogger_1.ConsoleLogger('Util');
6
+ const ConsoleLogger_1 = require("../../Logger/ConsoleLogger");
7
+ const isNonRetryableError_1 = require("./isNonRetryableError");
8
+ const logger = new ConsoleLogger_1.ConsoleLogger('Util');
70
9
  /**
71
10
  * @private
72
11
  * Internal use of Amplify only
73
12
  */
74
- function retry(functionToRetry, args, delayFn, onTerminate) {
75
- return __awaiter(this, void 0, void 0, function () {
76
- var _this = this;
77
- return __generator(this, function (_a) {
78
- if (typeof functionToRetry !== 'function') {
79
- throw Error('functionToRetry must be a function');
13
+ async function retry(functionToRetry, args, delayFn, onTerminate) {
14
+ if (typeof functionToRetry !== 'function') {
15
+ throw Error('functionToRetry must be a function');
16
+ }
17
+ return new Promise(async (resolve, reject) => {
18
+ let attempt = 0;
19
+ let terminated = false;
20
+ let timeout;
21
+ let wakeUp = () => { }; // will be replaced with a resolver()
22
+ // used after the loop if terminated while waiting for a timer.
23
+ let lastError;
24
+ onTerminate &&
25
+ onTerminate.then(() => {
26
+ // signal not to try anymore.
27
+ terminated = true;
28
+ // stop sleeping if we're sleeping.
29
+ clearTimeout(timeout);
30
+ wakeUp();
31
+ });
32
+ while (!terminated) {
33
+ attempt++;
34
+ logger.debug(`${functionToRetry.name} attempt #${attempt} with this vars: ${JSON.stringify(args)}`);
35
+ try {
36
+ return resolve(await functionToRetry(...args));
80
37
  }
81
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
82
- var attempt, terminated, timeout, wakeUp, lastError, _loop_1, state_1;
83
- return __generator(this, function (_a) {
84
- switch (_a.label) {
85
- case 0:
86
- attempt = 0;
87
- terminated = false;
88
- wakeUp = function () { };
89
- onTerminate &&
90
- onTerminate.then(function () {
91
- // signal not to try anymore.
92
- terminated = true;
93
- // stop sleeping if we're sleeping.
94
- clearTimeout(timeout);
95
- wakeUp();
96
- });
97
- _loop_1 = function () {
98
- var _b, _c, err_1, retryIn_1;
99
- return __generator(this, function (_d) {
100
- switch (_d.label) {
101
- case 0:
102
- attempt++;
103
- logger.debug("".concat(functionToRetry.name, " attempt #").concat(attempt, " with this vars: ").concat(JSON.stringify(args)));
104
- _d.label = 1;
105
- case 1:
106
- _d.trys.push([1, 3, , 7]);
107
- _b = {};
108
- _c = resolve;
109
- return [4 /*yield*/, functionToRetry.apply(void 0, __spreadArray([], __read(args), false))];
110
- case 2: return [2 /*return*/, (_b.value = _c.apply(void 0, [_d.sent()]), _b)];
111
- case 3:
112
- err_1 = _d.sent();
113
- lastError = err_1;
114
- logger.debug("error on ".concat(functionToRetry.name), err_1);
115
- if ((0, isNonRetryableError_1.isNonRetryableError)(err_1)) {
116
- logger.debug("".concat(functionToRetry.name, " non retryable error"), err_1);
117
- return [2 /*return*/, { value: reject(err_1) }];
118
- }
119
- retryIn_1 = delayFn(attempt, args, err_1);
120
- logger.debug("".concat(functionToRetry.name, " retrying in ").concat(retryIn_1, " ms"));
121
- if (!(retryIn_1 === false || terminated)) return [3 /*break*/, 4];
122
- return [2 /*return*/, { value: reject(err_1) }];
123
- case 4: return [4 /*yield*/, new Promise(function (r) {
124
- wakeUp = r; // export wakeUp for onTerminate handling
125
- timeout = setTimeout(wakeUp, retryIn_1);
126
- })];
127
- case 5:
128
- _d.sent();
129
- _d.label = 6;
130
- case 6: return [3 /*break*/, 7];
131
- case 7: return [2 /*return*/];
132
- }
133
- });
134
- };
135
- _a.label = 1;
136
- case 1:
137
- if (!!terminated) return [3 /*break*/, 3];
138
- return [5 /*yield**/, _loop_1()];
139
- case 2:
140
- state_1 = _a.sent();
141
- if (typeof state_1 === "object")
142
- return [2 /*return*/, state_1.value];
143
- return [3 /*break*/, 1];
144
- case 3:
145
- // reached if terminated while waiting for a timer.
146
- reject(lastError);
147
- return [2 /*return*/];
148
- }
38
+ catch (err) {
39
+ lastError = err;
40
+ logger.debug(`error on ${functionToRetry.name}`, err);
41
+ if ((0, isNonRetryableError_1.isNonRetryableError)(err)) {
42
+ logger.debug(`${functionToRetry.name} non retryable error`, err);
43
+ return reject(err);
44
+ }
45
+ const retryIn = delayFn(attempt, args, err);
46
+ logger.debug(`${functionToRetry.name} retrying in ${retryIn} ms`);
47
+ // we check `terminated` again here because it could have flipped
48
+ // in the time it took `functionToRetry` to return.
49
+ if (retryIn === false || terminated) {
50
+ return reject(err);
51
+ }
52
+ else {
53
+ await new Promise(r => {
54
+ wakeUp = r; // export wakeUp for onTerminate handling
55
+ timeout = setTimeout(wakeUp, retryIn);
149
56
  });
150
- }); })];
151
- });
57
+ }
58
+ }
59
+ }
60
+ // reached if terminated while waiting for a timer.
61
+ reject(lastError);
152
62
  });
153
63
  }
154
64
  exports.retry = retry;
@@ -3,10 +3,10 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.SessionListener = void 0;
6
- var isBrowser_1 = require("../isBrowser");
7
- var stateChangeListeners = new Set();
8
- var SessionListener = /** @class */ (function () {
9
- function SessionListener() {
6
+ const isBrowser_1 = require("../isBrowser");
7
+ const stateChangeListeners = new Set();
8
+ class SessionListener {
9
+ constructor() {
10
10
  this.listenerActive = false;
11
11
  this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
12
12
  // Setup state listeners
@@ -15,8 +15,7 @@ var SessionListener = /** @class */ (function () {
15
15
  this.listenerActive = true;
16
16
  }
17
17
  }
18
- SessionListener.prototype.addStateChangeListener = function (listener, notifyOnAdd) {
19
- if (notifyOnAdd === void 0) { notifyOnAdd = false; }
18
+ addStateChangeListener(listener, notifyOnAdd = false) {
20
19
  // No-op if document listener is not active
21
20
  if (!this.listenerActive) {
22
21
  return;
@@ -26,30 +25,29 @@ var SessionListener = /** @class */ (function () {
26
25
  if (notifyOnAdd) {
27
26
  listener(this.getSessionState());
28
27
  }
29
- };
30
- SessionListener.prototype.removeStateChangeListener = function (handler) {
28
+ }
29
+ removeStateChangeListener(handler) {
31
30
  // No-op if document listener is not active
32
31
  if (!this.listenerActive) {
33
32
  return;
34
33
  }
35
34
  stateChangeListeners.delete(handler);
36
- };
37
- SessionListener.prototype.handleVisibilityChange = function () {
35
+ }
36
+ handleVisibilityChange() {
38
37
  this.notifyHandlers();
39
- };
40
- SessionListener.prototype.notifyHandlers = function () {
41
- var sessionState = this.getSessionState();
42
- stateChangeListeners.forEach(function (listener) {
38
+ }
39
+ notifyHandlers() {
40
+ const sessionState = this.getSessionState();
41
+ stateChangeListeners.forEach(listener => {
43
42
  listener(sessionState);
44
43
  });
45
- };
46
- SessionListener.prototype.getSessionState = function () {
44
+ }
45
+ getSessionState() {
47
46
  if ((0, isBrowser_1.isBrowser)() && document.visibilityState !== 'hidden') {
48
47
  return 'started';
49
48
  }
50
49
  // If, for any reason, document is undefined the session will never start
51
50
  return 'ended';
52
- };
53
- return SessionListener;
54
- }());
51
+ }
52
+ }
55
53
  exports.SessionListener = SessionListener;
@@ -3,30 +3,27 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.SessionListener = void 0;
6
- var react_native_1 = require("@aws-amplify/react-native");
7
- var stateChangeListeners = new Set();
8
- var isActive = function (appState) { return appState === 'active'; };
9
- var isInactive = function (appState) {
10
- return appState === 'inactive' || appState === 'background';
11
- };
12
- var SessionListener = /** @class */ (function () {
13
- function SessionListener() {
6
+ const react_native_1 = require("@aws-amplify/react-native");
7
+ const stateChangeListeners = new Set();
8
+ const isActive = (appState) => appState === 'active';
9
+ const isInactive = (appState) => appState === 'inactive' || appState === 'background';
10
+ class SessionListener {
11
+ constructor() {
14
12
  this.handleStateChange = this.handleStateChange.bind(this);
15
13
  // Setup state listeners
16
14
  (0, react_native_1.loadAppState)().addEventListener('change', this.handleStateChange);
17
15
  }
18
- SessionListener.prototype.addStateChangeListener = function (listener, notifyOnAdd) {
19
- if (notifyOnAdd === void 0) { notifyOnAdd = false; }
16
+ addStateChangeListener(listener, notifyOnAdd = false) {
20
17
  stateChangeListeners.add(listener);
21
18
  // Notify new handlers of the current state on add if the current state has been determined
22
19
  if (notifyOnAdd && this.currentAppState !== undefined) {
23
20
  listener(this.getSessionState());
24
21
  }
25
- };
26
- SessionListener.prototype.removeStateChangeListener = function (handler) {
22
+ }
23
+ removeStateChangeListener(handler) {
27
24
  stateChangeListeners.delete(handler);
28
- };
29
- SessionListener.prototype.handleStateChange = function (nextAppState) {
25
+ }
26
+ handleStateChange(nextAppState) {
30
27
  if ((this.currentAppState === undefined ||
31
28
  isInactive(this.currentAppState)) &&
32
29
  isActive(nextAppState)) {
@@ -36,19 +33,18 @@ var SessionListener = /** @class */ (function () {
36
33
  this.notifyHandlers('ended');
37
34
  }
38
35
  this.currentAppState = nextAppState;
39
- };
40
- SessionListener.prototype.notifyHandlers = function (state) {
41
- stateChangeListeners.forEach(function (listener) {
36
+ }
37
+ notifyHandlers(state) {
38
+ stateChangeListeners.forEach(listener => {
42
39
  listener(state);
43
40
  });
44
- };
45
- SessionListener.prototype.getSessionState = function () {
41
+ }
42
+ getSessionState() {
46
43
  if (isActive(this.currentAppState)) {
47
44
  return 'started';
48
45
  }
49
46
  // Consider any other app state as ended
50
47
  return 'ended';
51
- };
52
- return SessionListener;
53
- }());
48
+ }
49
+ }
54
50
  exports.SessionListener = SessionListener;
@@ -0,0 +1,2 @@
1
+ export declare const SESSION_START_EVENT = "_session.start";
2
+ export declare const SESSION_STOP_EVENT = "_session.stop";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.SESSION_STOP_EVENT = exports.SESSION_START_EVENT = void 0;
6
+ // Standard session start & stop event names
7
+ exports.SESSION_START_EVENT = '_session.start';
8
+ exports.SESSION_STOP_EVENT = '_session.stop';
@@ -1,2 +1,3 @@
1
1
  import { SessionListener } from './SessionListener';
2
+ export { SESSION_START_EVENT, SESSION_STOP_EVENT } from './constants';
2
3
  export declare const sessionListener: SessionListener;
@@ -2,6 +2,9 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.sessionListener = void 0;
6
- var SessionListener_1 = require("./SessionListener");
5
+ exports.sessionListener = exports.SESSION_STOP_EVENT = exports.SESSION_START_EVENT = void 0;
6
+ const SessionListener_1 = require("./SessionListener");
7
+ var constants_1 = require("./constants");
8
+ Object.defineProperty(exports, "SESSION_START_EVENT", { enumerable: true, get: function () { return constants_1.SESSION_START_EVENT; } });
9
+ Object.defineProperty(exports, "SESSION_STOP_EVENT", { enumerable: true, get: function () { return constants_1.SESSION_STOP_EVENT; } });
7
10
  exports.sessionListener = new SessionListener_1.SessionListener();
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.urlSafeDecode = void 0;
6
6
  function urlSafeDecode(hex) {
7
- var matchArr = hex.match(/.{2}/g) || [];
8
- return matchArr.map(function (char) { return String.fromCharCode(parseInt(char, 16)); }).join('');
7
+ const matchArr = hex.match(/.{2}/g) || [];
8
+ return matchArr.map(char => String.fromCharCode(parseInt(char, 16))).join('');
9
9
  }
10
10
  exports.urlSafeDecode = urlSafeDecode;
@@ -6,7 +6,7 @@ exports.urlSafeEncode = void 0;
6
6
  function urlSafeEncode(str) {
7
7
  return str
8
8
  .split('')
9
- .map(function (char) { return char.charCodeAt(0).toString(16).padStart(2, '0'); })
9
+ .map(char => char.charCodeAt(0).toString(16).padStart(2, '0'))
10
10
  .join('');
11
11
  }
12
12
  exports.urlSafeEncode = urlSafeEncode;
@@ -1,25 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- var __extends = (this && this.__extends) || (function () {
4
- var extendStatics = function (d, b) {
5
- extendStatics = Object.setPrototypeOf ||
6
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
- return extendStatics(d, b);
9
- };
10
- return function (d, b) {
11
- if (typeof b !== "function" && b !== null)
12
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13
- extendStatics(d, b);
14
- function __() { this.constructor = d; }
15
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
- };
17
- })();
18
- var BackgroundManagerNotOpenError = /** @class */ (function (_super) {
19
- __extends(BackgroundManagerNotOpenError, _super);
20
- function BackgroundManagerNotOpenError(message) {
21
- return _super.call(this, "BackgroundManagerNotOpenError: ".concat(message)) || this;
3
+ export class BackgroundManagerNotOpenError extends Error {
4
+ constructor(message) {
5
+ super(`BackgroundManagerNotOpenError: ${message}`);
22
6
  }
23
- return BackgroundManagerNotOpenError;
24
- }(Error));
25
- export { BackgroundManagerNotOpenError };
7
+ }