@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
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Default cache config
5
5
  */
6
- export var defaultConfig = {
6
+ export const defaultConfig = {
7
7
  keyPrefix: 'aws-amplify-cache',
8
8
  capacityInBytes: 1048576,
9
9
  itemMaxSize: 210000,
@@ -11,4 +11,4 @@ export var defaultConfig = {
11
11
  defaultPriority: 5,
12
12
  warningThreshold: 0.8,
13
13
  };
14
- export var currentSizeKey = 'CurSize';
14
+ export const currentSizeKey = 'CurSize';
@@ -1,4 +1,4 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { StorageCache } from './StorageCache';
4
- export var Cache = new StorageCache();
4
+ export const Cache = new StorageCache();
@@ -1,25 +1,13 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- var __values = (this && this.__values) || function(o) {
4
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
5
- if (m) return m.call(o);
6
- if (o && typeof o.length === "number") return {
7
- next: function () {
8
- if (o && i >= o.length) o = void 0;
9
- return { value: o && o[i++], done: !o };
10
- }
11
- };
12
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
13
- };
14
3
  import { assert, CacheErrorCode } from './errorHelpers';
15
- var DoubleLinkedNode = /** @class */ (function () {
16
- function DoubleLinkedNode(keyVal) {
4
+ class DoubleLinkedNode {
5
+ constructor(keyVal) {
17
6
  this.key = keyVal ? keyVal : '';
18
7
  this.prevNode = null;
19
8
  this.nextNode = null;
20
9
  }
21
- return DoubleLinkedNode;
22
- }());
10
+ }
23
11
  /**
24
12
  * double linked list plus a hash table inside
25
13
  * each key in the cache stored as a node in the list
@@ -31,11 +19,11 @@ var DoubleLinkedNode = /** @class */ (function () {
31
19
  * @member hashtable - the hashtable which maps cache key to list node
32
20
  * @member length - length of the list
33
21
  */
34
- var CacheList = /** @class */ (function () {
22
+ export class CacheList {
35
23
  /**
36
24
  * initialization
37
25
  */
38
- function CacheList() {
26
+ constructor() {
39
27
  this.head = new DoubleLinkedNode();
40
28
  this.tail = new DoubleLinkedNode();
41
29
  this.hashtable = {};
@@ -48,21 +36,21 @@ var CacheList = /** @class */ (function () {
48
36
  *
49
37
  * @param node
50
38
  */
51
- CacheList.prototype.insertNodeToHead = function (node) {
52
- var tmp = this.head.nextNode;
39
+ insertNodeToHead(node) {
40
+ const tmp = this.head.nextNode;
53
41
  this.head.nextNode = node;
54
42
  node.nextNode = tmp;
55
43
  node.prevNode = this.head;
56
44
  assert(tmp !== null, CacheErrorCode.NullPreviousNode);
57
45
  tmp.prevNode = node;
58
46
  this.length = this.length + 1;
59
- };
47
+ }
60
48
  /**
61
49
  * remove node
62
50
  *
63
51
  * @param node
64
52
  */
65
- CacheList.prototype.removeNode = function (node) {
53
+ removeNode(node) {
66
54
  assert(node.prevNode !== null, CacheErrorCode.NullPreviousNode);
67
55
  assert(node.nextNode !== null, CacheErrorCode.NullNextNode);
68
56
  node.prevNode.nextNode = node.nextNode;
@@ -70,112 +58,99 @@ var CacheList = /** @class */ (function () {
70
58
  node.prevNode = null;
71
59
  node.nextNode = null;
72
60
  this.length = this.length - 1;
73
- };
61
+ }
74
62
  /**
75
63
  * @return true if list is empty
76
64
  */
77
- CacheList.prototype.isEmpty = function () {
65
+ isEmpty() {
78
66
  return this.length === 0;
79
- };
67
+ }
80
68
  /**
81
69
  * refresh node so it is rotated to the head
82
70
  *
83
71
  * @param key - key of the node
84
72
  */
85
- CacheList.prototype.refresh = function (key) {
86
- var node = this.hashtable[key];
73
+ refresh(key) {
74
+ const node = this.hashtable[key];
87
75
  this.removeNode(node);
88
76
  this.insertNodeToHead(node);
89
- };
77
+ }
90
78
  /**
91
79
  * insert new node to the head and add it in the hashtable
92
80
  *
93
81
  * @param key - the key of the node
94
82
  */
95
- CacheList.prototype.insertItem = function (key) {
96
- var node = new DoubleLinkedNode(key);
83
+ insertItem(key) {
84
+ const node = new DoubleLinkedNode(key);
97
85
  this.hashtable[key] = node;
98
86
  this.insertNodeToHead(node);
99
- };
87
+ }
100
88
  /**
101
89
  * @return the LAST Recently Visited key
102
90
  */
103
- CacheList.prototype.getLastItem = function () {
91
+ getLastItem() {
104
92
  assert(this.tail.prevNode !== null, CacheErrorCode.NullPreviousNode);
105
93
  return this.tail.prevNode.key;
106
- };
94
+ }
107
95
  /**
108
96
  * remove the cache key from the list and hashtable
109
97
  * @param key - the key of the node
110
98
  */
111
- CacheList.prototype.removeItem = function (key) {
112
- var removedItem = this.hashtable[key];
99
+ removeItem(key) {
100
+ const removedItem = this.hashtable[key];
113
101
  this.removeNode(removedItem);
114
102
  delete this.hashtable[key];
115
- };
103
+ }
116
104
  /**
117
105
  * @return length of the list
118
106
  */
119
- CacheList.prototype.getSize = function () {
107
+ getSize() {
120
108
  return this.length;
121
- };
109
+ }
122
110
  /**
123
111
  * @return true if the key is in the hashtable
124
112
  * @param key
125
113
  */
126
- CacheList.prototype.containsKey = function (key) {
114
+ containsKey(key) {
127
115
  return key in this.hashtable;
128
- };
116
+ }
129
117
  /**
130
118
  * clean up the list and hashtable
131
119
  */
132
- CacheList.prototype.clearList = function () {
133
- var e_1, _a;
134
- try {
135
- for (var _b = __values(Object.keys(this.hashtable)), _c = _b.next(); !_c.done; _c = _b.next()) {
136
- var key = _c.value;
137
- if (this.hashtable.hasOwnProperty(key)) {
138
- delete this.hashtable[key];
139
- }
140
- }
141
- }
142
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
143
- finally {
144
- try {
145
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
120
+ clearList() {
121
+ for (const key of Object.keys(this.hashtable)) {
122
+ if (this.hashtable.hasOwnProperty(key)) {
123
+ delete this.hashtable[key];
146
124
  }
147
- finally { if (e_1) throw e_1.error; }
148
125
  }
149
126
  this.head.nextNode = this.tail;
150
127
  this.tail.prevNode = this.head;
151
128
  this.length = 0;
152
- };
129
+ }
153
130
  /**
154
131
  * @return all keys in the hashtable
155
132
  */
156
- CacheList.prototype.getKeys = function () {
133
+ getKeys() {
157
134
  return Object.keys(this.hashtable);
158
- };
135
+ }
159
136
  /**
160
137
  * mainly for test
161
138
  *
162
139
  * @param key
163
140
  * @return true if key is the head node
164
141
  */
165
- CacheList.prototype.isHeadNode = function (key) {
166
- var node = this.hashtable[key];
142
+ isHeadNode(key) {
143
+ const node = this.hashtable[key];
167
144
  return node.prevNode === this.head;
168
- };
145
+ }
169
146
  /**
170
147
  * mainly for test
171
148
  *
172
149
  * @param key
173
150
  * @return true if key is the tail node
174
151
  */
175
- CacheList.prototype.isTailNode = function (key) {
176
- var node = this.hashtable[key];
152
+ isTailNode(key) {
153
+ const node = this.hashtable[key];
177
154
  return node.nextNode === this.tail;
178
- };
179
- return CacheList;
180
- }());
181
- export { CacheList };
155
+ }
156
+ }
@@ -6,10 +6,10 @@ import { currentSizeKey } from '../constants';
6
6
  * @param str
7
7
  */
8
8
  export function getByteLength(str) {
9
- var ret = 0;
9
+ let ret = 0;
10
10
  ret = str.length;
11
- for (var i = str.length; i >= 0; i -= 1) {
12
- var charCode = str.charCodeAt(i);
11
+ for (let i = str.length; i >= 0; i -= 1) {
12
+ const charCode = str.charCodeAt(i);
13
13
  if (charCode > 0x7f && charCode <= 0x7ff) {
14
14
  ret += 1;
15
15
  }
@@ -27,7 +27,7 @@ export function getByteLength(str) {
27
27
  * get current time
28
28
  */
29
29
  export function getCurrentTime() {
30
- var currentTime = new Date();
30
+ const currentTime = new Date();
31
31
  return currentTime.getTime();
32
32
  }
33
33
  /**
@@ -39,6 +39,4 @@ export function isInteger(value) {
39
39
  }
40
40
  return (typeof value === 'number' && isFinite(value) && Math.floor(value) === value);
41
41
  }
42
- export var getCurrentSizeKey = function (keyPrefix) {
43
- return "".concat(keyPrefix).concat(currentSizeKey);
44
- };
42
+ export const getCurrentSizeKey = (keyPrefix) => `${keyPrefix}${currentSizeKey}`;
@@ -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 CacheErrorCode;
6
5
  (function (CacheErrorCode) {
@@ -8,15 +7,15 @@ export var CacheErrorCode;
8
7
  CacheErrorCode["NullNextNode"] = "NullNextNode";
9
8
  CacheErrorCode["NullPreviousNode"] = "NullPreviousNode";
10
9
  })(CacheErrorCode || (CacheErrorCode = {}));
11
- var cacheErrorMap = (_a = {},
12
- _a[CacheErrorCode.NoCacheItem] = {
10
+ const cacheErrorMap = {
11
+ [CacheErrorCode.NoCacheItem]: {
13
12
  message: 'Item not found in the cache storage.',
14
13
  },
15
- _a[CacheErrorCode.NullNextNode] = {
14
+ [CacheErrorCode.NullNextNode]: {
16
15
  message: 'Next node is null.',
17
16
  },
18
- _a[CacheErrorCode.NullPreviousNode] = {
17
+ [CacheErrorCode.NullPreviousNode]: {
19
18
  message: 'Previous node is null.',
20
19
  },
21
- _a);
22
- export var assert = createAssertionFunction(cacheErrorMap);
20
+ };
21
+ export const assert = createAssertionFunction(cacheErrorMap);
@@ -1,50 +1,14 @@
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 __read = (this && this.__read) || function (o, n) {
15
- var m = typeof Symbol === "function" && o[Symbol.iterator];
16
- if (!m) return o;
17
- var i = m.call(o), r, ar = [], e;
18
- try {
19
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
20
- }
21
- catch (error) { e = { error: error }; }
22
- finally {
23
- try {
24
- if (r && !r.done && (m = i["return"])) m.call(i);
25
- }
26
- finally { if (e) throw e.error; }
27
- }
28
- return ar;
29
- };
30
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
32
- if (ar || !(i in from)) {
33
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
34
- ar[i] = from[i];
35
- }
36
- }
37
- return to.concat(ar || Array.prototype.slice.call(from));
38
- };
39
3
  import { ConsoleLogger as Logger } from '../Logger';
40
4
  import { NO_HUBCALLBACK_PROVIDED_EXCEPTION } from '../constants';
41
5
  import { AmplifyError } from '../errors';
42
- export var AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
6
+ export const AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
43
7
  ? Symbol.for('amplify_default')
44
8
  : '@@amplify_default');
45
- var logger = new Logger('Hub');
46
- var HubClass = /** @class */ (function () {
47
- function HubClass(name) {
9
+ const logger = new Logger('Hub');
10
+ export class HubClass {
11
+ constructor(name) {
48
12
  this.listeners = new Map();
49
13
  this.protectedChannels = [
50
14
  'core',
@@ -65,29 +29,28 @@ var HubClass = /** @class */ (function () {
65
29
  * @remarks
66
30
  * This private method is for internal use only. Instead of calling Hub.remove, call the result of Hub.listen.
67
31
  */
68
- HubClass.prototype._remove = function (channel, listener) {
69
- var holder = this.listeners.get(channel);
32
+ _remove(channel, listener) {
33
+ const holder = this.listeners.get(channel);
70
34
  if (!holder) {
71
- logger.warn("No listeners for ".concat(channel));
35
+ logger.warn(`No listeners for ${channel}`);
72
36
  return;
73
37
  }
74
- this.listeners.set(channel, __spreadArray([], __read(holder.filter(function (_a) {
75
- var callback = _a.callback;
76
- return callback !== listener;
77
- })), false));
78
- };
79
- HubClass.prototype.dispatch = function (channel, payload, source, ampSymbol) {
38
+ this.listeners.set(channel, [
39
+ ...holder.filter(({ callback }) => callback !== listener),
40
+ ]);
41
+ }
42
+ dispatch(channel, payload, source, ampSymbol) {
80
43
  if (typeof channel === 'string' &&
81
44
  this.protectedChannels.indexOf(channel) > -1) {
82
- var hasAccess = ampSymbol === AMPLIFY_SYMBOL;
45
+ const hasAccess = ampSymbol === AMPLIFY_SYMBOL;
83
46
  if (!hasAccess) {
84
- logger.warn("WARNING: ".concat(channel, " is protected and dispatching on it can have unintended consequences"));
47
+ logger.warn(`WARNING: ${channel} is protected and dispatching on it can have unintended consequences`);
85
48
  }
86
49
  }
87
- var capsule = {
88
- channel: channel,
89
- payload: __assign({}, payload),
90
- source: source,
50
+ const capsule = {
51
+ channel,
52
+ payload: { ...payload },
53
+ source,
91
54
  patternInfo: [],
92
55
  };
93
56
  try {
@@ -96,11 +59,9 @@ var HubClass = /** @class */ (function () {
96
59
  catch (e) {
97
60
  logger.error(e);
98
61
  }
99
- };
100
- HubClass.prototype.listen = function (channel, callback, listenerName) {
101
- var _this = this;
102
- if (listenerName === void 0) { listenerName = 'noname'; }
103
- var cb;
62
+ }
63
+ listen(channel, callback, listenerName = 'noname') {
64
+ let cb;
104
65
  if (typeof callback !== 'function') {
105
66
  throw new AmplifyError({
106
67
  name: NO_HUBCALLBACK_PROVIDED_EXCEPTION,
@@ -111,7 +72,7 @@ var HubClass = /** @class */ (function () {
111
72
  // Needs to be casted as a more generic type
112
73
  cb = callback;
113
74
  }
114
- var holder = this.listeners.get(channel);
75
+ let holder = this.listeners.get(channel);
115
76
  if (!holder) {
116
77
  holder = [];
117
78
  this.listeners.set(channel, holder);
@@ -120,16 +81,16 @@ var HubClass = /** @class */ (function () {
120
81
  name: listenerName,
121
82
  callback: cb,
122
83
  });
123
- return function () {
124
- _this._remove(channel, cb);
84
+ return () => {
85
+ this._remove(channel, cb);
125
86
  };
126
- };
127
- HubClass.prototype._toListeners = function (capsule) {
128
- var channel = capsule.channel, payload = capsule.payload;
129
- var holder = this.listeners.get(channel);
87
+ }
88
+ _toListeners(capsule) {
89
+ const { channel, payload } = capsule;
90
+ const holder = this.listeners.get(channel);
130
91
  if (holder) {
131
- holder.forEach(function (listener) {
132
- logger.debug("Dispatching to ".concat(channel, " with "), payload);
92
+ holder.forEach(listener => {
93
+ logger.debug(`Dispatching to ${channel} with `, payload);
133
94
  try {
134
95
  listener.callback(capsule);
135
96
  }
@@ -138,18 +99,16 @@ var HubClass = /** @class */ (function () {
138
99
  }
139
100
  });
140
101
  }
141
- };
142
- return HubClass;
143
- }());
144
- export { HubClass };
102
+ }
103
+ }
145
104
  /*We export a __default__ instance of HubClass to use it as a
146
105
  pseudo Singleton for the main messaging bus, however you can still create
147
106
  your own instance of HubClass() for a separate "private bus" of events.*/
148
- export var Hub = new HubClass('__default__');
107
+ export const Hub = new HubClass('__default__');
149
108
  /**
150
109
  * @internal
151
110
  *
152
111
  * Internal hub used for core Amplify functionality. Not intended for use outside of Amplify.
153
112
  *
154
113
  */
155
- export var HubInternal = new HubClass('internal-hub');
114
+ export const HubInternal = new HubClass('internal-hub');
@@ -1,28 +1,17 @@
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
3
  import { ConsoleLogger as Logger } from '../Logger';
15
- var logger = new Logger('I18n');
4
+ const logger = new Logger('I18n');
16
5
  /**
17
6
  * Language translation utility.
18
7
  */
19
- var I18n = /** @class */ (function () {
8
+ export class I18n {
20
9
  /**
21
10
  * @constructor
22
11
  * Initialize with configurations
23
12
  * @param {Object} options
24
13
  */
25
- function I18n() {
14
+ constructor() {
26
15
  /**
27
16
  * @private
28
17
  */
@@ -39,7 +28,7 @@ var I18n = /** @class */ (function () {
39
28
  /**
40
29
  * Sets the default language from the configuration when required.
41
30
  */
42
- I18n.prototype.setDefaultLanguage = function () {
31
+ setDefaultLanguage() {
43
32
  // Default to window language if not set in instance
44
33
  if (!this._lang &&
45
34
  typeof window !== 'undefined' &&
@@ -48,28 +37,27 @@ var I18n = /** @class */ (function () {
48
37
  this._lang = window.navigator.language;
49
38
  }
50
39
  logger.debug(this._lang);
51
- };
40
+ }
52
41
  /**
53
42
  * @method
54
43
  * Explicitly setting language
55
44
  * @param {String} lang
56
45
  */
57
- I18n.prototype.setLanguage = function (lang) {
46
+ setLanguage(lang) {
58
47
  this._lang = lang;
59
- };
48
+ }
60
49
  /**
61
50
  * @method
62
51
  * Get value
63
52
  * @param {String} key
64
53
  * @param {String} defVal - Default value
65
54
  */
66
- I18n.prototype.get = function (key, defVal) {
67
- if (defVal === void 0) { defVal = undefined; }
55
+ get(key, defVal = undefined) {
68
56
  if (!this._lang) {
69
57
  return typeof defVal !== 'undefined' ? defVal : key;
70
58
  }
71
- var lang = this._lang;
72
- var val = this.getByLanguage(key, lang);
59
+ const lang = this._lang;
60
+ let val = this.getByLanguage(key, lang);
73
61
  if (val) {
74
62
  return val;
75
63
  }
@@ -80,7 +68,7 @@ var I18n = /** @class */ (function () {
80
68
  return val;
81
69
  }
82
70
  return typeof defVal !== 'undefined' ? defVal : key;
83
- };
71
+ }
84
72
  /**
85
73
  * @method
86
74
  * Get value according to specified language
@@ -88,42 +76,38 @@ var I18n = /** @class */ (function () {
88
76
  * @param {String} language - Specified langurage to be used
89
77
  * @param {String} defVal - Default value
90
78
  */
91
- I18n.prototype.getByLanguage = function (key, language, defVal) {
92
- if (defVal === void 0) { defVal = null; }
79
+ getByLanguage(key, language, defVal = null) {
93
80
  if (!language) {
94
81
  return defVal;
95
82
  }
96
- var lang_dict = this._dict[language];
83
+ const lang_dict = this._dict[language];
97
84
  if (!lang_dict) {
98
85
  return defVal;
99
86
  }
100
87
  return lang_dict[key];
101
- };
88
+ }
102
89
  /**
103
90
  * @method
104
91
  * Add vocabularies for one language
105
92
  * @param {String} language - Language of the dictionary
106
93
  * @param {Object} vocabularies - Object that has key-value as dictionary entry
107
94
  */
108
- I18n.prototype.putVocabulariesForLanguage = function (language, vocabularies) {
109
- var lang_dict = this._dict[language];
95
+ putVocabulariesForLanguage(language, vocabularies) {
96
+ let lang_dict = this._dict[language];
110
97
  if (!lang_dict) {
111
98
  lang_dict = this._dict[language] = {};
112
99
  }
113
- this._dict[language] = __assign(__assign({}, lang_dict), vocabularies);
114
- };
100
+ this._dict[language] = { ...lang_dict, ...vocabularies };
101
+ }
115
102
  /**
116
103
  * @method
117
104
  * Add vocabularies for one language
118
105
  * @param {Object} vocabularies - Object that has language as key,
119
106
  * vocabularies of each language as value
120
107
  */
121
- I18n.prototype.putVocabularies = function (vocabularies) {
122
- var _this = this;
123
- Object.keys(vocabularies).map(function (key) {
124
- _this.putVocabulariesForLanguage(key, vocabularies[key]);
108
+ putVocabularies(vocabularies) {
109
+ Object.keys(vocabularies).map(key => {
110
+ this.putVocabulariesForLanguage(key, vocabularies[key]);
125
111
  });
126
- };
127
- return I18n;
128
- }());
129
- export { I18n };
112
+ }
113
+ }
@@ -1,14 +1,13 @@
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 I18nErrorCode;
6
5
  (function (I18nErrorCode) {
7
6
  I18nErrorCode["NotConfigured"] = "NotConfigured";
8
7
  })(I18nErrorCode || (I18nErrorCode = {}));
9
- var i18nErrorMap = (_a = {},
10
- _a[I18nErrorCode.NotConfigured] = {
8
+ const i18nErrorMap = {
9
+ [I18nErrorCode.NotConfigured]: {
11
10
  message: 'i18n is not configured.',
12
11
  },
13
- _a);
14
- export var assert = createAssertionFunction(i18nErrorMap);
12
+ };
13
+ export const assert = createAssertionFunction(i18nErrorMap);