@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,6 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- var _a;
4
3
  import { createAssertionFunction } from '../../../errors';
5
4
  export var AuthConfigurationErrorCode;
6
5
  (function (AuthConfigurationErrorCode) {
@@ -9,22 +8,22 @@ export var AuthConfigurationErrorCode;
9
8
  AuthConfigurationErrorCode["InvalidIdentityPoolIdException"] = "InvalidIdentityPoolIdException";
10
9
  AuthConfigurationErrorCode["OAuthNotConfigureException"] = "OAuthNotConfigureException";
11
10
  })(AuthConfigurationErrorCode || (AuthConfigurationErrorCode = {}));
12
- var authConfigurationErrorMap = (_a = {},
13
- _a[AuthConfigurationErrorCode.AuthTokenConfigException] = {
11
+ const authConfigurationErrorMap = {
12
+ [AuthConfigurationErrorCode.AuthTokenConfigException]: {
14
13
  message: 'Auth Token Provider not configured.',
15
14
  recoverySuggestion: 'Make sure to call Amplify.configure in your app.',
16
15
  },
17
- _a[AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException] = {
16
+ [AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException]: {
18
17
  message: 'Auth UserPool or IdentityPool not configured.',
19
18
  recoverySuggestion: 'Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId.',
20
19
  },
21
- _a[AuthConfigurationErrorCode.InvalidIdentityPoolIdException] = {
20
+ [AuthConfigurationErrorCode.InvalidIdentityPoolIdException]: {
22
21
  message: 'Invalid identity pool id provided.',
23
22
  recoverySuggestion: 'Make sure a valid identityPoolId is given in the config.',
24
23
  },
25
- _a[AuthConfigurationErrorCode.OAuthNotConfigureException] = {
24
+ [AuthConfigurationErrorCode.OAuthNotConfigureException]: {
26
25
  message: 'oauth param not configured.',
27
26
  recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app.',
28
27
  },
29
- _a);
30
- export var assert = createAssertionFunction(authConfigurationErrorMap);
28
+ };
29
+ export const assert = createAssertionFunction(authConfigurationErrorMap);
@@ -3,7 +3,7 @@
3
3
  import { AuthConfigurationErrorCode, assert } from './errorHelpers';
4
4
  import { base64Decoder } from '../../../utils/convert';
5
5
  export function assertTokenProviderConfig(cognitoConfig) {
6
- var assertionValid = true; // assume valid until otherwise proveed
6
+ let assertionValid = true; // assume valid until otherwise proveed
7
7
  if (!cognitoConfig) {
8
8
  assertionValid = false;
9
9
  }
@@ -14,38 +14,37 @@ export function assertTokenProviderConfig(cognitoConfig) {
14
14
  return assert(assertionValid, AuthConfigurationErrorCode.AuthTokenConfigException);
15
15
  }
16
16
  export function assertOAuthConfig(cognitoConfig) {
17
- var _a, _b, _c, _d, _e, _f, _g, _h;
18
- var validOAuthConfig = !!((_b = (_a = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _a === void 0 ? void 0 : _a.oauth) === null || _b === void 0 ? void 0 : _b.domain) &&
19
- !!((_d = (_c = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _c === void 0 ? void 0 : _c.oauth) === null || _d === void 0 ? void 0 : _d.redirectSignOut) &&
20
- !!((_f = (_e = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _e === void 0 ? void 0 : _e.oauth) === null || _f === void 0 ? void 0 : _f.redirectSignIn) &&
21
- !!((_h = (_g = cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.loginWith) === null || _g === void 0 ? void 0 : _g.oauth) === null || _h === void 0 ? void 0 : _h.responseType);
17
+ const validOAuthConfig = !!cognitoConfig?.loginWith?.oauth?.domain &&
18
+ !!cognitoConfig?.loginWith?.oauth?.redirectSignOut &&
19
+ !!cognitoConfig?.loginWith?.oauth?.redirectSignIn &&
20
+ !!cognitoConfig?.loginWith?.oauth?.responseType;
22
21
  return assert(validOAuthConfig, AuthConfigurationErrorCode.OAuthNotConfigureException);
23
22
  }
24
23
  export function assertIdentityPoolIdConfig(cognitoConfig) {
25
- var validConfig = !!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId);
24
+ const validConfig = !!cognitoConfig?.identityPoolId;
26
25
  return assert(validConfig, AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
27
26
  }
28
27
  function assertUserPoolAndIdentityPoolConfig(authConfig) {
29
- var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.identityPoolId) && !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.Cognito.userPoolId);
28
+ const validConfig = !!authConfig?.Cognito.identityPoolId && !!authConfig?.Cognito.userPoolId;
30
29
  return assert(validConfig, AuthConfigurationErrorCode.AuthUserPoolAndIdentityPoolException);
31
30
  }
32
31
  export function decodeJWT(token) {
33
- var tokenParts = token.split('.');
32
+ const tokenParts = token.split('.');
34
33
  if (tokenParts.length !== 3) {
35
34
  throw new Error('Invalid token');
36
35
  }
37
36
  try {
38
- var base64WithUrlSafe = tokenParts[1];
39
- var base64_1 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');
40
- var jsonStr = decodeURIComponent(base64Decoder
41
- .convert(base64_1)
37
+ const base64WithUrlSafe = tokenParts[1];
38
+ const base64 = base64WithUrlSafe.replace(/-/g, '+').replace(/_/g, '/');
39
+ const jsonStr = decodeURIComponent(base64Decoder
40
+ .convert(base64)
42
41
  .split('')
43
- .map(function (char) { return "%".concat("00".concat(char.charCodeAt(0).toString(16)).slice(-2)); })
42
+ .map(char => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`)
44
43
  .join(''));
45
- var payload = JSON.parse(jsonStr);
44
+ const payload = JSON.parse(jsonStr);
46
45
  return {
47
- toString: function () { return token; },
48
- payload: payload,
46
+ toString: () => token,
47
+ payload,
49
48
  };
50
49
  }
51
50
  catch (err) {
@@ -0,0 +1,49 @@
1
+ type SpeechGeneratorDefaults = {
2
+ voiceId?: string;
3
+ };
4
+ type TranscriptionDefaults = {
5
+ language?: string;
6
+ };
7
+ type TranslateTextDefaults = {
8
+ sourceLanguage?: string;
9
+ targetLanguage?: string;
10
+ };
11
+ type IdentifyEntitiesDefaults = {
12
+ collectionId?: string;
13
+ maxEntities?: number;
14
+ };
15
+ type IdentityLabelsDefaults = {
16
+ type?: string;
17
+ };
18
+ type IdentifyTextDefaults = {
19
+ format?: string;
20
+ };
21
+ type InterpretTextDefaults = {
22
+ type?: string;
23
+ };
24
+ type ConvertConfig = {
25
+ speechGenerator?: PredictionsProviderConfig<SpeechGeneratorDefaults>;
26
+ transcription?: PredictionsProviderConfig<TranscriptionDefaults>;
27
+ translateText?: PredictionsProviderConfig<TranslateTextDefaults>;
28
+ };
29
+ type IdentifyConfig = {
30
+ identifyEntities?: PredictionsProviderConfig<IdentifyEntitiesDefaults> & {
31
+ celebrityDetectionEnabled?: boolean;
32
+ };
33
+ identifyLabels?: PredictionsProviderConfig<IdentityLabelsDefaults>;
34
+ identifyText?: PredictionsProviderConfig<IdentifyTextDefaults>;
35
+ };
36
+ type InterpretConfig = {
37
+ interpretText?: PredictionsProviderConfig<InterpretTextDefaults>;
38
+ };
39
+ export type PredictionsProviderConfig<T> = {
40
+ region?: string;
41
+ proxy?: boolean;
42
+ defaults?: T;
43
+ };
44
+ export type PredictionsConfig = {
45
+ convert?: ConvertConfig;
46
+ identify?: IdentifyConfig;
47
+ interpret?: InterpretConfig;
48
+ };
49
+ export {};
@@ -0,0 +1,3 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
@@ -2,6 +2,6 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { fetchAuthSession as fetchAuthSessionInternal } from './internal/fetchAuthSession';
4
4
  import { Amplify } from '../Amplify';
5
- export var fetchAuthSession = function (options) {
5
+ export const fetchAuthSession = (options) => {
6
6
  return fetchAuthSessionInternal(Amplify, options);
7
7
  };
@@ -1,5 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- export var fetchAuthSession = function (amplify, options) {
3
+ export const fetchAuthSession = (amplify, options) => {
4
4
  return amplify.Auth.fetchAuthSession(options);
5
5
  };
@@ -2,6 +2,6 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { getAmplifyServerContext } from '../../../adapterCore';
4
4
  import { fetchAuthSession as fetchAuthSessionInternal } from '../internal/fetchAuthSession';
5
- export var fetchAuthSession = function (contextSpec, options) {
5
+ export const fetchAuthSession = (contextSpec, options) => {
6
6
  return fetchAuthSessionInternal(getAmplifyServerContext(contextSpec).amplify, options);
7
7
  };
@@ -2,6 +2,7 @@ import { APIConfig, LibraryAPIOptions } from './API/types';
2
2
  import { AnalyticsConfig } from './Analytics/types';
3
3
  import { AuthConfig, LibraryAuthOptions, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, CognitoIdentityPoolConfig } from './Auth/types';
4
4
  import { GeoConfig } from './Geo/types';
5
+ import { PredictionsConfig } from './Predictions/types';
5
6
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
6
7
  import { NotificationsConfig } from './Notifications/types';
7
8
  import { InteractionsConfig } from './Interactions/types';
@@ -17,6 +18,7 @@ export type ResourcesConfig = {
17
18
  Auth?: AuthConfig;
18
19
  Interactions?: InteractionsConfig;
19
20
  Notifications?: NotificationsConfig;
21
+ Predictions?: PredictionsConfig;
20
22
  Storage?: StorageConfig;
21
23
  Geo?: GeoConfig;
22
24
  };
@@ -26,4 +28,4 @@ export type LibraryOptions = {
26
28
  Storage?: LibraryStorageOptions;
27
29
  ssr?: boolean;
28
30
  };
29
- export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, InteractionsConfig, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
31
+ export { APIConfig, AuthConfig, AuthUserPoolConfig, AuthIdentityPoolConfig, AuthUserPoolAndIdentityPoolConfig, GetCredentialsOptions, InteractionsConfig, PredictionsConfig, StorageAccessLevel, StorageConfig, AnalyticsConfig, CognitoIdentityPoolConfig, GeoConfig, };
@@ -1,57 +1,9 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __generator = (this && this.__generator) || function (thisArg, body) {
24
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
- function verb(n) { return function (v) { return step([n, v]); }; }
27
- function step(op) {
28
- if (f) throw new TypeError("Generator is already executing.");
29
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
30
- 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;
31
- if (y = 0, t) op = [op[0] & 2, t.value];
32
- switch (op[0]) {
33
- case 0: case 1: t = op; break;
34
- case 4: _.label++; return { value: op[1], done: false };
35
- case 5: _.label++; y = op[1]; op = [0]; continue;
36
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
- default:
38
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
- if (t[2]) _.ops.pop();
43
- _.trys.pop(); continue;
44
- }
45
- op = body.call(thisArg, _);
46
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
- }
49
- };
50
3
  import JsCookie from 'js-cookie';
51
- var CookieStorage = /** @class */ (function () {
52
- function CookieStorage(data) {
53
- if (data === void 0) { data = {}; }
54
- var path = data.path, domain = data.domain, expires = data.expires, sameSite = data.sameSite, secure = data.secure;
4
+ export class CookieStorage {
5
+ constructor(data = {}) {
6
+ const { path, domain, expires, sameSite, secure } = data;
55
7
  this.domain = domain;
56
8
  this.path = path ? path : '/';
57
9
  this.expires = data.hasOwnProperty('expires') ? expires : 365;
@@ -66,51 +18,28 @@ var CookieStorage = /** @class */ (function () {
66
18
  this.sameSite = sameSite;
67
19
  }
68
20
  }
69
- CookieStorage.prototype.setItem = function (key, value) {
70
- return __awaiter(this, void 0, void 0, function () {
71
- return __generator(this, function (_a) {
72
- JsCookie.set(key, value, this.getData());
73
- return [2 /*return*/];
74
- });
75
- });
76
- };
77
- CookieStorage.prototype.getItem = function (key) {
78
- return __awaiter(this, void 0, void 0, function () {
79
- var item;
80
- return __generator(this, function (_a) {
81
- item = JsCookie.get(key);
82
- return [2 /*return*/, item !== null && item !== void 0 ? item : null];
83
- });
84
- });
85
- };
86
- CookieStorage.prototype.removeItem = function (key) {
87
- return __awaiter(this, void 0, void 0, function () {
88
- return __generator(this, function (_a) {
89
- JsCookie.remove(key, this.getData());
90
- return [2 /*return*/];
91
- });
92
- });
93
- };
94
- CookieStorage.prototype.clear = function () {
95
- return __awaiter(this, void 0, void 0, function () {
96
- var cookie, promises;
97
- var _this = this;
98
- return __generator(this, function (_a) {
99
- switch (_a.label) {
100
- case 0:
101
- cookie = JsCookie.get();
102
- promises = Object.keys(cookie).map(function (key) { return _this.removeItem(key); });
103
- return [4 /*yield*/, Promise.all(promises)];
104
- case 1:
105
- _a.sent();
106
- return [2 /*return*/];
107
- }
108
- });
109
- });
110
- };
111
- CookieStorage.prototype.getData = function () {
112
- return __assign({ path: this.path, expires: this.expires, domain: this.domain, secure: this.secure }, (this.sameSite && { sameSite: this.sameSite }));
113
- };
114
- return CookieStorage;
115
- }());
116
- export { CookieStorage };
21
+ async setItem(key, value) {
22
+ JsCookie.set(key, value, this.getData());
23
+ }
24
+ async getItem(key) {
25
+ const item = JsCookie.get(key);
26
+ return item ?? null;
27
+ }
28
+ async removeItem(key) {
29
+ JsCookie.remove(key, this.getData());
30
+ }
31
+ async clear() {
32
+ const cookie = JsCookie.get();
33
+ const promises = Object.keys(cookie).map(key => this.removeItem(key));
34
+ await Promise.all(promises);
35
+ }
36
+ getData() {
37
+ return {
38
+ path: this.path,
39
+ expires: this.expires,
40
+ domain: this.domain,
41
+ secure: this.secure,
42
+ ...(this.sameSite && { sameSite: this.sameSite }),
43
+ };
44
+ }
45
+ }
@@ -1,29 +1,11 @@
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
3
  import { KeyValueStorage } from './KeyValueStorage';
19
4
  /**
20
5
  * @internal
21
6
  */
22
- var CookieStorage = /** @class */ (function (_super) {
23
- __extends(CookieStorage, _super);
24
- function CookieStorage() {
25
- return _super.call(this) || this;
7
+ export class CookieStorage extends KeyValueStorage {
8
+ constructor() {
9
+ super();
26
10
  }
27
- return CookieStorage;
28
- }(KeyValueStorage));
29
- export { CookieStorage };
11
+ }
@@ -1,30 +1,12 @@
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
3
  import { KeyValueStorage } from './KeyValueStorage';
19
4
  import { getLocalStorageWithFallback } from './utils';
20
5
  /**
21
6
  * @internal
22
7
  */
23
- var DefaultStorage = /** @class */ (function (_super) {
24
- __extends(DefaultStorage, _super);
25
- function DefaultStorage() {
26
- return _super.call(this, getLocalStorageWithFallback()) || this;
8
+ export class DefaultStorage extends KeyValueStorage {
9
+ constructor() {
10
+ super(getLocalStorageWithFallback());
27
11
  }
28
- return DefaultStorage;
29
- }(KeyValueStorage));
30
- export { DefaultStorage };
12
+ }
@@ -1,48 +1,12 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __generator = (this && this.__generator) || function (thisArg, body) {
13
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
- function verb(n) { return function (v) { return step([n, v]); }; }
16
- function step(op) {
17
- if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
- if (y = 0, t) op = [op[0] & 2, t.value];
21
- switch (op[0]) {
22
- case 0: case 1: t = op; break;
23
- case 4: _.label++; return { value: op[1], done: false };
24
- case 5: _.label++; y = op[1]; op = [0]; continue;
25
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
- default:
27
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
- if (t[2]) _.ops.pop();
32
- _.trys.pop(); continue;
33
- }
34
- op = body.call(thisArg, _);
35
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
- }
38
- };
39
3
  import { loadAsyncStorage } from '@aws-amplify/react-native';
40
- var MEMORY_KEY_PREFIX = '@MemoryStorage:';
4
+ const MEMORY_KEY_PREFIX = '@MemoryStorage:';
41
5
  /**
42
6
  * @internal
43
7
  */
44
- var DefaultStorage = /** @class */ (function () {
45
- function DefaultStorage() {
8
+ export class DefaultStorage {
9
+ constructor() {
46
10
  this.asyncStorage = loadAsyncStorage();
47
11
  }
48
12
  /**
@@ -51,43 +15,32 @@ var DefaultStorage = /** @class */ (function () {
51
15
  * @param {object} value - the value
52
16
  * @returns {string} value that was set
53
17
  */
54
- DefaultStorage.prototype.setItem = function (key, value) {
55
- return this.asyncStorage.setItem("".concat(MEMORY_KEY_PREFIX).concat(key), value);
56
- };
18
+ setItem(key, value) {
19
+ return this.asyncStorage.setItem(`${MEMORY_KEY_PREFIX}${key}`, value);
20
+ }
57
21
  /**
58
22
  * This is used to get a specific key from storage
59
23
  * @param {string} key - the key for the item
60
24
  * This is used to clear the storage
61
25
  * @returns {string} the data item
62
26
  */
63
- DefaultStorage.prototype.getItem = function (key) {
64
- return this.asyncStorage.getItem("".concat(MEMORY_KEY_PREFIX).concat(key));
65
- };
27
+ getItem(key) {
28
+ return this.asyncStorage.getItem(`${MEMORY_KEY_PREFIX}${key}`);
29
+ }
66
30
  /**
67
31
  * This is used to remove an item from storage
68
32
  * @param {string} key - the key being set
69
33
  * @returns {string} value - value that was deleted
70
34
  */
71
- DefaultStorage.prototype.removeItem = function (key) {
72
- return this.asyncStorage.removeItem("".concat(MEMORY_KEY_PREFIX).concat(key));
73
- };
35
+ removeItem(key) {
36
+ return this.asyncStorage.removeItem(`${MEMORY_KEY_PREFIX}${key}`);
37
+ }
74
38
  /**
75
39
  * This is used to clear the storage
76
40
  * @returns {string} nothing
77
41
  */
78
- DefaultStorage.prototype.clear = function () {
79
- return __awaiter(this, void 0, void 0, function () {
80
- var allKeys;
81
- return __generator(this, function (_a) {
82
- switch (_a.label) {
83
- case 0: return [4 /*yield*/, this.asyncStorage.getAllKeys()];
84
- case 1:
85
- allKeys = _a.sent();
86
- return [2 /*return*/, this.asyncStorage.multiRemove(allKeys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); }))];
87
- }
88
- });
89
- });
90
- };
91
- return DefaultStorage;
92
- }());
93
- export { DefaultStorage };
42
+ async clear() {
43
+ const allKeys = await this.asyncStorage.getAllKeys();
44
+ return this.asyncStorage.multiRemove(allKeys.filter(key => key.startsWith(MEMORY_KEY_PREFIX)));
45
+ }
46
+ }
@@ -3,36 +3,29 @@
3
3
  /**
4
4
  * @internal
5
5
  */
6
- var InMemoryStorage = /** @class */ (function () {
7
- function InMemoryStorage() {
6
+ export class InMemoryStorage {
7
+ constructor() {
8
8
  this.storage = new Map();
9
9
  }
10
- Object.defineProperty(InMemoryStorage.prototype, "length", {
11
- get: function () {
12
- return this.storage.size;
13
- },
14
- enumerable: false,
15
- configurable: true
16
- });
17
- InMemoryStorage.prototype.key = function (index) {
10
+ get length() {
11
+ return this.storage.size;
12
+ }
13
+ key(index) {
18
14
  if (index > this.length - 1) {
19
15
  return null;
20
16
  }
21
17
  return Array.from(this.storage.keys())[index];
22
- };
23
- InMemoryStorage.prototype.setItem = function (key, value) {
18
+ }
19
+ setItem(key, value) {
24
20
  this.storage.set(key, value);
25
- };
26
- InMemoryStorage.prototype.getItem = function (key) {
27
- var _a;
28
- return (_a = this.storage.get(key)) !== null && _a !== void 0 ? _a : null;
29
- };
30
- InMemoryStorage.prototype.removeItem = function (key) {
21
+ }
22
+ getItem(key) {
23
+ return this.storage.get(key) ?? null;
24
+ }
25
+ removeItem(key) {
31
26
  this.storage.delete(key);
32
- };
33
- InMemoryStorage.prototype.clear = function () {
27
+ }
28
+ clear() {
34
29
  this.storage.clear();
35
- };
36
- return InMemoryStorage;
37
- }());
38
- export { InMemoryStorage };
30
+ }
31
+ }