@aws-amplify/core 6.0.1-server-generate-client.1e317a1.0 → 6.0.1-ssr-api.df60e41.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 (328) 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.js +10 -27
  39. package/lib/Signer/Signer.js +49 -52
  40. package/lib/adapterCore/error/AmplifyServerContextError.js +9 -27
  41. package/lib/adapterCore/serverContext/serverContext.js +8 -8
  42. package/lib/adapterCore/serverContext/serverContextRegistry.js +6 -6
  43. package/lib/awsClients/cognitoIdentity/base.js +25 -73
  44. package/lib/awsClients/cognitoIdentity/getCredentialsForIdentity.js +24 -68
  45. package/lib/awsClients/cognitoIdentity/getId.js +19 -62
  46. package/lib/awsClients/pinpoint/base.js +12 -15
  47. package/lib/awsClients/pinpoint/errorHelpers.js +4 -5
  48. package/lib/awsClients/pinpoint/getInAppMessages.js +24 -68
  49. package/lib/awsClients/pinpoint/putEvents.js +26 -70
  50. package/lib/awsClients/pinpoint/updateEndpoint.js +28 -72
  51. package/lib/clients/endpoints/getDnsSuffix.js +7 -29
  52. package/lib/clients/handlers/authenticated.js +5 -5
  53. package/lib/clients/handlers/fetch.js +41 -98
  54. package/lib/clients/handlers/unauthenticated.js +4 -4
  55. package/lib/clients/internal/composeServiceApi.js +17 -67
  56. package/lib/clients/internal/composeTransferHandler.js +9 -11
  57. package/lib/clients/middleware/retry/defaultRetryDecider.js +18 -75
  58. package/lib/clients/middleware/retry/isClockSkewError.js +2 -4
  59. package/lib/clients/middleware/retry/jitteredBackoff.js +5 -5
  60. package/lib/clients/middleware/retry/middleware.js +61 -125
  61. package/lib/clients/middleware/signing/middleware.js +24 -86
  62. package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +21 -56
  63. package/lib/clients/middleware/signing/signer/signatureV4/signRequest.js +14 -25
  64. package/lib/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +7 -7
  65. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +8 -30
  66. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +11 -38
  67. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +13 -17
  68. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +5 -8
  69. package/lib/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +2 -2
  70. package/lib/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -3
  71. package/lib/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +7 -11
  72. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +9 -10
  73. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +4 -6
  74. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +8 -8
  75. package/lib/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +15 -16
  76. package/lib/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +2 -4
  77. package/lib/clients/middleware/signing/utils/extendedEncodeURIComponent.js +3 -5
  78. package/lib/clients/middleware/signing/utils/getSkewCorrectedDate.js +1 -3
  79. package/lib/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +2 -2
  80. package/lib/clients/middleware/signing/utils/isClockSkewed.js +4 -6
  81. package/lib/clients/middleware/userAgent/middleware.js +14 -63
  82. package/lib/clients/serde/json.js +30 -96
  83. package/lib/clients/serde/responseInfo.js +12 -18
  84. package/lib/clients/utils/memoization.js +3 -3
  85. package/lib/constants.js +1 -1
  86. package/lib/errors/AmplifyError.js +9 -28
  87. package/lib/errors/PlatformNotSupportedError.js +7 -24
  88. package/lib/errors/createAssertionFunction.js +12 -15
  89. package/lib/errors/errorHelpers.js +7 -8
  90. package/lib/index.d.ts +1 -1
  91. package/lib/libraryUtils.d.ts +1 -0
  92. package/lib/libraryUtils.js +4 -1
  93. package/lib/parseAWSExports.js +109 -103
  94. package/lib/providers/pinpoint/apis/flushEvents.js +8 -8
  95. package/lib/providers/pinpoint/apis/record.js +58 -93
  96. package/lib/providers/pinpoint/apis/updateEndpoint.js +65 -112
  97. package/lib/providers/pinpoint/types/pinpoint.d.ts +2 -0
  98. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +105 -196
  99. package/lib/providers/pinpoint/utils/cacheEndpointId.js +12 -49
  100. package/lib/providers/pinpoint/utils/getCacheKey.js +2 -2
  101. package/lib/providers/pinpoint/utils/getEndpointId.js +7 -51
  102. package/lib/providers/pinpoint/utils/getEventBuffer.js +19 -21
  103. package/lib/providers/pinpoint/utils/isAppInForeground.js +1 -1
  104. package/lib/providers/pinpoint/utils/isAppInForeground.native.js +2 -2
  105. package/lib/providers/pinpoint/utils/resolveEndpointId.js +20 -71
  106. package/lib/singleton/API/types.d.ts +0 -92
  107. package/lib/singleton/API/types.js +0 -10
  108. package/lib/singleton/Amplify.js +29 -89
  109. package/lib/singleton/Auth/index.js +48 -115
  110. package/lib/singleton/Auth/types.d.ts +2 -2
  111. package/lib/singleton/Auth/utils/errorHelpers.js +7 -8
  112. package/lib/singleton/Auth/utils/index.js +18 -19
  113. package/lib/singleton/Predictions/types.d.ts +49 -0
  114. package/lib/singleton/Predictions/types.js +4 -0
  115. package/lib/singleton/apis/clearCredentials.js +1 -1
  116. package/lib/singleton/apis/fetchAuthSession.js +3 -3
  117. package/lib/singleton/apis/internal/fetchAuthSession.js +1 -1
  118. package/lib/singleton/apis/server/fetchAuthSession.js +3 -3
  119. package/lib/singleton/types.d.ts +3 -1
  120. package/lib/storage/CookieStorage.js +29 -99
  121. package/lib/storage/CookieStorage.native.js +5 -22
  122. package/lib/storage/DefaultStorage.js +6 -23
  123. package/lib/storage/DefaultStorage.native.js +18 -64
  124. package/lib/storage/InMemoryStorage.js +17 -23
  125. package/lib/storage/KeyValueStorage.js +24 -80
  126. package/lib/storage/SessionStorage.js +6 -23
  127. package/lib/storage/index.js +4 -4
  128. package/lib/storage/utils.js +7 -11
  129. package/lib/tsconfig.tsbuildinfo +1 -1
  130. package/lib/utils/amplifyUrl/index.js +2 -2
  131. package/lib/utils/amplifyUrl/polyfill.native.js +1 -1
  132. package/lib/utils/amplifyUuid/index.js +2 -2
  133. package/lib/utils/amplifyUuid/polyfill.native.js +1 -1
  134. package/lib/utils/convert/base64/base64Decoder.js +2 -2
  135. package/lib/utils/convert/base64/base64Encoder.js +5 -6
  136. package/lib/utils/convert/base64/bytesToString.js +1 -1
  137. package/lib/utils/deepFreeze.js +6 -28
  138. package/lib/utils/generateRandomString.js +4 -4
  139. package/lib/utils/getClientInfo/getClientInfo.android.js +7 -7
  140. package/lib/utils/getClientInfo/getClientInfo.ios.js +12 -12
  141. package/lib/utils/getClientInfo/getClientInfo.js +16 -16
  142. package/lib/utils/globalHelpers/index.js +4 -4
  143. package/lib/utils/globalHelpers/index.native.js +6 -6
  144. package/lib/utils/isBrowser.js +1 -3
  145. package/lib/utils/isWebWorker.js +2 -2
  146. package/lib/utils/retry/NonRetryableError.js +5 -23
  147. package/lib/utils/retry/isNonRetryableError.js +2 -2
  148. package/lib/utils/retry/jitteredBackoff.js +6 -7
  149. package/lib/utils/retry/jitteredExponentialRetry.js +4 -7
  150. package/lib/utils/retry/retry.js +50 -140
  151. package/lib/utils/sessionListener/SessionListener.js +17 -19
  152. package/lib/utils/sessionListener/SessionListener.native.js +18 -22
  153. package/lib/utils/sessionListener/constants.d.ts +2 -0
  154. package/lib/utils/sessionListener/constants.js +8 -0
  155. package/lib/utils/sessionListener/index.d.ts +1 -0
  156. package/lib/utils/sessionListener/index.js +5 -2
  157. package/lib/utils/urlSafeDecode.js +2 -2
  158. package/lib/utils/urlSafeEncode.js +1 -1
  159. package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.js +4 -22
  160. package/lib-esm/BackgroundProcessManager/BackgroundProcessManager.js +124 -244
  161. package/lib-esm/Cache/StorageCache.js +26 -87
  162. package/lib-esm/Cache/StorageCache.native.js +33 -136
  163. package/lib-esm/Cache/StorageCacheCommon.js +267 -597
  164. package/lib-esm/Cache/constants.js +2 -2
  165. package/lib-esm/Cache/index.js +1 -1
  166. package/lib-esm/Cache/utils/CacheList.js +41 -66
  167. package/lib-esm/Cache/utils/cacheHelpers.js +5 -7
  168. package/lib-esm/Cache/utils/errorHelpers.js +6 -7
  169. package/lib-esm/Hub/index.js +34 -75
  170. package/lib-esm/I18n/I18n.js +23 -39
  171. package/lib-esm/I18n/errorHelpers.js +4 -5
  172. package/lib-esm/I18n/index.js +21 -25
  173. package/lib-esm/I18n/types.js +3 -5
  174. package/lib-esm/Logger/ConsoleLogger.js +52 -128
  175. package/lib-esm/Mutex/Mutex.js +15 -20
  176. package/lib-esm/Platform/customUserAgent.js +13 -26
  177. package/lib-esm/Platform/detectFramework.js +11 -12
  178. package/lib-esm/Platform/detection/Angular.js +3 -4
  179. package/lib-esm/Platform/detection/React.js +4 -4
  180. package/lib-esm/Platform/detection/Svelte.js +1 -1
  181. package/lib-esm/Platform/detection/helpers.js +7 -7
  182. package/lib-esm/Platform/detection/index.js +3 -3
  183. package/lib-esm/Platform/index.js +23 -52
  184. package/lib-esm/Platform/types.d.ts +1 -1
  185. package/lib-esm/Platform/types.js +1 -1
  186. package/lib-esm/Platform/version.d.ts +1 -1
  187. package/lib-esm/Platform/version.js +1 -1
  188. package/lib-esm/Reachability/Reachability.js +18 -46
  189. package/lib-esm/Reachability/Reachability.native.js +10 -15
  190. package/lib-esm/ServiceWorker/ServiceWorker.js +74 -131
  191. package/lib-esm/ServiceWorker/errorHelpers.js +6 -7
  192. package/lib-esm/Signer/DateUtils.js +11 -28
  193. package/lib-esm/Signer/Signer.js +45 -49
  194. package/lib-esm/adapterCore/error/AmplifyServerContextError.js +8 -27
  195. package/lib-esm/adapterCore/serverContext/serverContext.js +6 -6
  196. package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +7 -7
  197. package/lib-esm/awsClients/cognitoIdentity/base.js +21 -69
  198. package/lib-esm/awsClients/cognitoIdentity/getCredentialsForIdentity.js +22 -66
  199. package/lib-esm/awsClients/cognitoIdentity/getId.js +17 -60
  200. package/lib-esm/awsClients/pinpoint/base.js +8 -11
  201. package/lib-esm/awsClients/pinpoint/errorHelpers.js +4 -5
  202. package/lib-esm/awsClients/pinpoint/getInAppMessages.js +19 -63
  203. package/lib-esm/awsClients/pinpoint/putEvents.js +20 -64
  204. package/lib-esm/awsClients/pinpoint/updateEndpoint.js +23 -67
  205. package/lib-esm/clients/endpoints/getDnsSuffix.js +6 -28
  206. package/lib-esm/clients/endpoints/partitions.js +2 -2
  207. package/lib-esm/clients/handlers/authenticated.js +1 -1
  208. package/lib-esm/clients/handlers/fetch.js +40 -97
  209. package/lib-esm/clients/handlers/unauthenticated.js +1 -1
  210. package/lib-esm/clients/internal/composeServiceApi.js +17 -67
  211. package/lib-esm/clients/internal/composeTransferHandler.js +9 -11
  212. package/lib-esm/clients/middleware/retry/defaultRetryDecider.js +17 -74
  213. package/lib-esm/clients/middleware/retry/isClockSkewError.js +2 -4
  214. package/lib-esm/clients/middleware/retry/jitteredBackoff.js +4 -4
  215. package/lib-esm/clients/middleware/retry/middleware.js +61 -125
  216. package/lib-esm/clients/middleware/signing/middleware.js +21 -83
  217. package/lib-esm/clients/middleware/signing/signer/signatureV4/constants.js +17 -17
  218. package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +17 -52
  219. package/lib-esm/clients/middleware/signing/signer/signatureV4/signRequest.js +10 -21
  220. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/dataHashHelpers.js +5 -5
  221. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalHeaders.js +8 -30
  222. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalQueryString.js +11 -38
  223. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalRequest.js +8 -12
  224. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCanonicalUri.js +5 -8
  225. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getCredentialScope.js +1 -1
  226. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getFormattedDates.js +3 -3
  227. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getHashedPayload.js +5 -9
  228. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignature.js +5 -6
  229. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSignedHeaders.js +4 -6
  230. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningKey.js +6 -6
  231. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getSigningValues.js +13 -14
  232. package/lib-esm/clients/middleware/signing/signer/signatureV4/utils/getStringToSign.js +1 -3
  233. package/lib-esm/clients/middleware/signing/utils/extendedEncodeURIComponent.js +3 -5
  234. package/lib-esm/clients/middleware/signing/utils/getSkewCorrectedDate.js +1 -3
  235. package/lib-esm/clients/middleware/signing/utils/getUpdatedSystemClockOffset.js +1 -1
  236. package/lib-esm/clients/middleware/signing/utils/isClockSkewed.js +3 -5
  237. package/lib-esm/clients/middleware/userAgent/middleware.js +14 -63
  238. package/lib-esm/clients/serde/json.js +29 -95
  239. package/lib-esm/clients/serde/responseInfo.js +11 -17
  240. package/lib-esm/clients/utils/memoization.js +3 -3
  241. package/lib-esm/constants.js +5 -5
  242. package/lib-esm/errors/AmplifyError.js +9 -29
  243. package/lib-esm/errors/PlatformNotSupportedError.js +5 -23
  244. package/lib-esm/errors/createAssertionFunction.js +11 -14
  245. package/lib-esm/errors/errorHelpers.js +6 -7
  246. package/lib-esm/index.d.ts +1 -1
  247. package/lib-esm/libraryUtils.d.ts +1 -0
  248. package/lib-esm/libraryUtils.js +1 -0
  249. package/lib-esm/parseAWSExports.js +108 -102
  250. package/lib-esm/providers/pinpoint/apis/flushEvents.js +6 -6
  251. package/lib-esm/providers/pinpoint/apis/record.js +54 -89
  252. package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +61 -108
  253. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +2 -0
  254. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +102 -194
  255. package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +10 -47
  256. package/lib-esm/providers/pinpoint/utils/constants.js +4 -4
  257. package/lib-esm/providers/pinpoint/utils/getCacheKey.js +2 -2
  258. package/lib-esm/providers/pinpoint/utils/getEndpointId.js +5 -49
  259. package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +17 -19
  260. package/lib-esm/providers/pinpoint/utils/isAppInForeground.js +1 -1
  261. package/lib-esm/providers/pinpoint/utils/isAppInForeground.native.js +1 -1
  262. package/lib-esm/providers/pinpoint/utils/resolveEndpointId.js +16 -67
  263. package/lib-esm/singleton/API/types.d.ts +0 -92
  264. package/lib-esm/singleton/API/types.js +1 -9
  265. package/lib-esm/singleton/Amplify.js +26 -87
  266. package/lib-esm/singleton/Auth/index.js +48 -116
  267. package/lib-esm/singleton/Auth/types.d.ts +2 -2
  268. package/lib-esm/singleton/Auth/utils/errorHelpers.js +7 -8
  269. package/lib-esm/singleton/Auth/utils/index.js +16 -17
  270. package/lib-esm/singleton/Predictions/types.d.ts +49 -0
  271. package/lib-esm/singleton/Predictions/types.js +3 -0
  272. package/lib-esm/singleton/apis/fetchAuthSession.js +1 -1
  273. package/lib-esm/singleton/apis/internal/fetchAuthSession.js +1 -1
  274. package/lib-esm/singleton/apis/server/fetchAuthSession.js +1 -1
  275. package/lib-esm/singleton/types.d.ts +3 -1
  276. package/lib-esm/storage/CookieStorage.js +28 -99
  277. package/lib-esm/storage/CookieStorage.native.js +4 -22
  278. package/lib-esm/storage/DefaultStorage.js +4 -22
  279. package/lib-esm/storage/DefaultStorage.native.js +17 -64
  280. package/lib-esm/storage/InMemoryStorage.js +17 -24
  281. package/lib-esm/storage/KeyValueStorage.js +23 -80
  282. package/lib-esm/storage/SessionStorage.js +4 -22
  283. package/lib-esm/storage/index.js +3 -3
  284. package/lib-esm/storage/utils.js +6 -10
  285. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  286. package/lib-esm/utils/amplifyUrl/index.js +2 -2
  287. package/lib-esm/utils/amplifyUuid/index.js +1 -1
  288. package/lib-esm/utils/convert/base64/base64Decoder.js +2 -2
  289. package/lib-esm/utils/convert/base64/base64Encoder.js +4 -5
  290. package/lib-esm/utils/convert/base64/bytesToString.js +1 -1
  291. package/lib-esm/utils/deepFreeze.js +6 -28
  292. package/lib-esm/utils/generateRandomString.js +4 -4
  293. package/lib-esm/utils/getClientInfo/getClientInfo.android.js +5 -5
  294. package/lib-esm/utils/getClientInfo/getClientInfo.ios.js +10 -10
  295. package/lib-esm/utils/getClientInfo/getClientInfo.js +15 -15
  296. package/lib-esm/utils/globalHelpers/index.js +3 -3
  297. package/lib-esm/utils/globalHelpers/index.native.js +4 -4
  298. package/lib-esm/utils/isBrowser.js +1 -3
  299. package/lib-esm/utils/isWebWorker.js +2 -2
  300. package/lib-esm/utils/retry/NonRetryableError.js +5 -24
  301. package/lib-esm/utils/retry/constants.js +1 -1
  302. package/lib-esm/utils/retry/isNonRetryableError.js +2 -2
  303. package/lib-esm/utils/retry/jitteredBackoff.js +5 -6
  304. package/lib-esm/utils/retry/jitteredExponentialRetry.js +1 -4
  305. package/lib-esm/utils/retry/retry.js +48 -138
  306. package/lib-esm/utils/sessionListener/SessionListener.js +16 -19
  307. package/lib-esm/utils/sessionListener/SessionListener.native.js +17 -22
  308. package/lib-esm/utils/sessionListener/constants.d.ts +2 -0
  309. package/lib-esm/utils/sessionListener/constants.js +5 -0
  310. package/lib-esm/utils/sessionListener/index.d.ts +1 -0
  311. package/lib-esm/utils/sessionListener/index.js +2 -1
  312. package/lib-esm/utils/urlSafeDecode.js +2 -2
  313. package/lib-esm/utils/urlSafeEncode.js +1 -1
  314. package/package.json +10 -23
  315. package/src/Cache/types/index.ts +4 -4
  316. package/src/Platform/types.ts +1 -1
  317. package/src/Platform/version.ts +1 -1
  318. package/src/index.ts +1 -0
  319. package/src/libraryUtils.ts +4 -0
  320. package/src/parseAWSExports.ts +45 -10
  321. package/src/providers/pinpoint/apis/record.ts +22 -5
  322. package/src/providers/pinpoint/types/pinpoint.ts +2 -0
  323. package/src/singleton/API/types.ts +0 -113
  324. package/src/singleton/Auth/types.ts +2 -2
  325. package/src/singleton/Predictions/types.ts +61 -0
  326. package/src/singleton/types.ts +3 -1
  327. package/src/utils/sessionListener/constants.ts +6 -0
  328. package/src/utils/sessionListener/index.ts +1 -0
@@ -1,116 +1,56 @@
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 __extends = (this && this.__extends) || (function () {
5
- var extendStatics = function (d, b) {
6
- extendStatics = Object.setPrototypeOf ||
7
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
- return extendStatics(d, b);
10
- };
11
- return function (d, b) {
12
- if (typeof b !== "function" && b !== null)
13
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
- extendStatics(d, b);
15
- function __() { this.constructor = d; }
16
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
- };
18
- })();
19
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
20
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
- return new (P || (P = Promise))(function (resolve, reject) {
22
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
- step((generator = generator.apply(thisArg, _arguments || [])).next());
26
- });
27
- };
28
- var __generator = (this && this.__generator) || function (thisArg, body) {
29
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
30
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
31
- function verb(n) { return function (v) { return step([n, v]); }; }
32
- function step(op) {
33
- if (f) throw new TypeError("Generator is already executing.");
34
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
- 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;
36
- if (y = 0, t) op = [op[0] & 2, t.value];
37
- switch (op[0]) {
38
- case 0: case 1: t = op; break;
39
- case 4: _.label++; return { value: op[1], done: false };
40
- case 5: _.label++; y = op[1]; op = [0]; continue;
41
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
42
- default:
43
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
44
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
45
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
46
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
47
- if (t[2]) _.ops.pop();
48
- _.trys.pop(); continue;
49
- }
50
- op = body.call(thisArg, _);
51
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
52
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
53
- }
54
- };
55
4
  Object.defineProperty(exports, "__esModule", { value: true });
56
5
  exports.StorageCache = void 0;
57
- var Logger_1 = require("../Logger");
58
- var KeyValueStorage_1 = require("../storage/KeyValueStorage");
59
- var utils_1 = require("../storage/utils");
60
- var constants_1 = require("./constants");
61
- var StorageCacheCommon_1 = require("./StorageCacheCommon");
62
- var utils_2 = require("./utils");
63
- var logger = new Logger_1.ConsoleLogger('Cache');
6
+ const Logger_1 = require("../Logger");
7
+ const KeyValueStorage_1 = require("../storage/KeyValueStorage");
8
+ const utils_1 = require("../storage/utils");
9
+ const constants_1 = require("./constants");
10
+ const StorageCacheCommon_1 = require("./StorageCacheCommon");
11
+ const utils_2 = require("./utils");
12
+ const logger = new Logger_1.ConsoleLogger('Cache');
64
13
  /**
65
14
  * Customized storage based on the SessionStorage or LocalStorage with LRU implemented
66
15
  */
67
- var StorageCache = /** @class */ (function (_super) {
68
- __extends(StorageCache, _super);
16
+ class StorageCache extends StorageCacheCommon_1.StorageCacheCommon {
69
17
  /**
70
18
  * initialize the cache
71
19
  * @param config - the configuration of the cache
72
20
  */
73
- function StorageCache(config) {
74
- var _this = this;
75
- var storage = (0, utils_1.getLocalStorageWithFallback)();
76
- _this = _super.call(this, { config: config, keyValueStorage: new KeyValueStorage_1.KeyValueStorage(storage) }) || this;
77
- _this.storage = storage;
78
- _this.getItem = _this.getItem.bind(_this);
79
- _this.setItem = _this.setItem.bind(_this);
80
- _this.removeItem = _this.removeItem.bind(_this);
81
- return _this;
21
+ constructor(config) {
22
+ const storage = (0, utils_1.getLocalStorageWithFallback)();
23
+ super({ config, keyValueStorage: new KeyValueStorage_1.KeyValueStorage(storage) });
24
+ this.storage = storage;
25
+ this.getItem = this.getItem.bind(this);
26
+ this.setItem = this.setItem.bind(this);
27
+ this.removeItem = this.removeItem.bind(this);
28
+ }
29
+ async getAllCacheKeys(options) {
30
+ const { omitSizeKey } = options ?? {};
31
+ const keys = [];
32
+ for (let i = 0; i < this.storage.length; i++) {
33
+ const key = this.storage.key(i);
34
+ if (omitSizeKey && key === (0, utils_2.getCurrentSizeKey)(this.config.keyPrefix)) {
35
+ continue;
36
+ }
37
+ if (key?.startsWith(this.config.keyPrefix)) {
38
+ keys.push(key.substring(this.config.keyPrefix.length));
39
+ }
40
+ }
41
+ return keys;
82
42
  }
83
- StorageCache.prototype.getAllCacheKeys = function (options) {
84
- return __awaiter(this, void 0, void 0, function () {
85
- var omitSizeKey, keys, i, key;
86
- return __generator(this, function (_a) {
87
- omitSizeKey = (options !== null && options !== void 0 ? options : {}).omitSizeKey;
88
- keys = [];
89
- for (i = 0; i < this.storage.length; i++) {
90
- key = this.storage.key(i);
91
- if (omitSizeKey && key === (0, utils_2.getCurrentSizeKey)(this.config.keyPrefix)) {
92
- continue;
93
- }
94
- if (key === null || key === void 0 ? void 0 : key.startsWith(this.config.keyPrefix)) {
95
- keys.push(key.substring(this.config.keyPrefix.length));
96
- }
97
- }
98
- return [2 /*return*/, keys];
99
- });
100
- });
101
- };
102
43
  /**
103
44
  * Return a new instance of cache with customized configuration.
104
45
  * @param {Object} config - the customized configuration
105
46
  * @return {Object} - the new instance of Cache
106
47
  */
107
- StorageCache.prototype.createInstance = function (config) {
48
+ createInstance(config) {
108
49
  if (!config.keyPrefix || config.keyPrefix === constants_1.defaultConfig.keyPrefix) {
109
50
  logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
110
51
  config.keyPrefix = utils_2.getCurrentTime.toString();
111
52
  }
112
53
  return new StorageCache(config);
113
- };
114
- return StorageCache;
115
- }(StorageCacheCommon_1.StorageCacheCommon));
54
+ }
55
+ }
116
56
  exports.StorageCache = StorageCache;
@@ -1,164 +1,62 @@
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 __extends = (this && this.__extends) || (function () {
5
- var extendStatics = function (d, b) {
6
- extendStatics = Object.setPrototypeOf ||
7
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
- return extendStatics(d, b);
10
- };
11
- return function (d, b) {
12
- if (typeof b !== "function" && b !== null)
13
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
- extendStatics(d, b);
15
- function __() { this.constructor = d; }
16
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
- };
18
- })();
19
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
20
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
- return new (P || (P = Promise))(function (resolve, reject) {
22
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
- step((generator = generator.apply(thisArg, _arguments || [])).next());
26
- });
27
- };
28
- var __generator = (this && this.__generator) || function (thisArg, body) {
29
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
30
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
31
- function verb(n) { return function (v) { return step([n, v]); }; }
32
- function step(op) {
33
- if (f) throw new TypeError("Generator is already executing.");
34
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
- 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;
36
- if (y = 0, t) op = [op[0] & 2, t.value];
37
- switch (op[0]) {
38
- case 0: case 1: t = op; break;
39
- case 4: _.label++; return { value: op[1], done: false };
40
- case 5: _.label++; y = op[1]; op = [0]; continue;
41
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
42
- default:
43
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
44
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
45
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
46
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
47
- if (t[2]) _.ops.pop();
48
- _.trys.pop(); continue;
49
- }
50
- op = body.call(thisArg, _);
51
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
52
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
53
- }
54
- };
55
- var __values = (this && this.__values) || function(o) {
56
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
57
- if (m) return m.call(o);
58
- if (o && typeof o.length === "number") return {
59
- next: function () {
60
- if (o && i >= o.length) o = void 0;
61
- return { value: o && o[i++], done: !o };
62
- }
63
- };
64
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
65
- };
66
4
  Object.defineProperty(exports, "__esModule", { value: true });
67
5
  exports.StorageCache = void 0;
68
- var react_native_1 = require("@aws-amplify/react-native");
69
- var Logger_1 = require("../Logger");
70
- var constants_1 = require("./constants");
71
- var StorageCacheCommon_1 = require("./StorageCacheCommon");
72
- var utils_1 = require("./utils");
73
- var logger = new Logger_1.ConsoleLogger('StorageCache');
74
- var AsyncStorage = (0, react_native_1.loadAsyncStorage)();
6
+ const react_native_1 = require("@aws-amplify/react-native");
7
+ const Logger_1 = require("../Logger");
8
+ const constants_1 = require("./constants");
9
+ const StorageCacheCommon_1 = require("./StorageCacheCommon");
10
+ const utils_1 = require("./utils");
11
+ const logger = new Logger_1.ConsoleLogger('StorageCache');
12
+ const AsyncStorage = (0, react_native_1.loadAsyncStorage)();
75
13
  /*
76
14
  * Customized cache which based on the AsyncStorage with LRU implemented
77
15
  */
78
- var StorageCache = /** @class */ (function (_super) {
79
- __extends(StorageCache, _super);
16
+ class StorageCache extends StorageCacheCommon_1.StorageCacheCommon {
80
17
  /**
81
18
  * initialize the cache
82
19
  * @param config - the configuration of the cache
83
20
  */
84
- function StorageCache(config) {
85
- var _this = _super.call(this, { config: config, keyValueStorage: AsyncStorage }) || this;
86
- _this.getItem = _this.getItem.bind(_this);
87
- _this.setItem = _this.setItem.bind(_this);
88
- _this.removeItem = _this.removeItem.bind(_this);
89
- return _this;
21
+ constructor(config) {
22
+ super({ config, keyValueStorage: AsyncStorage });
23
+ this.getItem = this.getItem.bind(this);
24
+ this.setItem = this.setItem.bind(this);
25
+ this.removeItem = this.removeItem.bind(this);
26
+ }
27
+ async getAllCacheKeys(options) {
28
+ const { omitSizeKey } = options ?? {};
29
+ const keys = [];
30
+ for (const key of await AsyncStorage.getAllKeys()) {
31
+ if (omitSizeKey && key === (0, utils_1.getCurrentSizeKey)(this.config.keyPrefix)) {
32
+ continue;
33
+ }
34
+ if (key?.startsWith(this.config.keyPrefix)) {
35
+ keys.push(key.substring(this.config.keyPrefix.length));
36
+ }
37
+ }
38
+ return keys;
39
+ }
40
+ async getAllStorageKeys() {
41
+ try {
42
+ return AsyncStorage.getAllKeys();
43
+ }
44
+ catch (e) {
45
+ logger.warn(`getAllKeys failed! ${e}`);
46
+ return [];
47
+ }
90
48
  }
91
- StorageCache.prototype.getAllCacheKeys = function (options) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var omitSizeKey, keys, _a, _b, key, e_1_1;
94
- var e_1, _c;
95
- return __generator(this, function (_d) {
96
- switch (_d.label) {
97
- case 0:
98
- omitSizeKey = (options !== null && options !== void 0 ? options : {}).omitSizeKey;
99
- keys = [];
100
- _d.label = 1;
101
- case 1:
102
- _d.trys.push([1, 6, 7, 8]);
103
- return [4 /*yield*/, AsyncStorage.getAllKeys()];
104
- case 2:
105
- _a = __values.apply(void 0, [_d.sent()]), _b = _a.next();
106
- _d.label = 3;
107
- case 3:
108
- if (!!_b.done) return [3 /*break*/, 5];
109
- key = _b.value;
110
- if (omitSizeKey && key === (0, utils_1.getCurrentSizeKey)(this.config.keyPrefix)) {
111
- return [3 /*break*/, 4];
112
- }
113
- if (key === null || key === void 0 ? void 0 : key.startsWith(this.config.keyPrefix)) {
114
- keys.push(key.substring(this.config.keyPrefix.length));
115
- }
116
- _d.label = 4;
117
- case 4:
118
- _b = _a.next();
119
- return [3 /*break*/, 3];
120
- case 5: return [3 /*break*/, 8];
121
- case 6:
122
- e_1_1 = _d.sent();
123
- e_1 = { error: e_1_1 };
124
- return [3 /*break*/, 8];
125
- case 7:
126
- try {
127
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
128
- }
129
- finally { if (e_1) throw e_1.error; }
130
- return [7 /*endfinally*/];
131
- case 8: return [2 /*return*/, keys];
132
- }
133
- });
134
- });
135
- };
136
- StorageCache.prototype.getAllStorageKeys = function () {
137
- return __awaiter(this, void 0, void 0, function () {
138
- return __generator(this, function (_a) {
139
- try {
140
- return [2 /*return*/, AsyncStorage.getAllKeys()];
141
- }
142
- catch (e) {
143
- logger.warn("getAllKeys failed! ".concat(e));
144
- return [2 /*return*/, []];
145
- }
146
- return [2 /*return*/];
147
- });
148
- });
149
- };
150
49
  /**
151
50
  * Return a new instance of cache with customized configuration.
152
51
  * @param {Object} config - the customized configuration
153
52
  * @return {Object} - the new instance of Cache
154
53
  */
155
- StorageCache.prototype.createInstance = function (config) {
54
+ createInstance(config) {
156
55
  if (!config.keyPrefix || config.keyPrefix === constants_1.defaultConfig.keyPrefix) {
157
56
  logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
158
57
  config.keyPrefix = utils_1.getCurrentTime.toString();
159
58
  }
160
59
  return new StorageCache(config);
161
- };
162
- return StorageCache;
163
- }(StorageCacheCommon_1.StorageCacheCommon));
60
+ }
61
+ }
164
62
  exports.StorageCache = StorageCache;