@aws-amplify/core 6.0.1-console-preview.7919075.0 → 6.0.1-console-preview.5dc0b68.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 (354) hide show
  1. package/internals/adapter-core/package.json +8 -0
  2. package/internals/providers/pinpoint/package.json +8 -0
  3. package/internals/utils/package.json +7 -0
  4. package/lib/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
  5. package/lib/AwsClients/CognitoIdentity/getId.d.ts +1 -1
  6. package/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
  7. package/lib/AwsClients/Pinpoint/index.d.ts +1 -1
  8. package/lib/AwsClients/Pinpoint/putEvents.d.ts +1 -1
  9. package/lib/AwsClients/Pinpoint/putEvents.js +2 -2
  10. package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
  11. package/lib/Cache/AsyncStorageCache.js +3 -3
  12. package/lib/Cache/BrowserStorageCache.js +5 -5
  13. package/lib/Cache/InMemoryCache.js +3 -3
  14. package/lib/Cache/StorageCache.js +1 -1
  15. package/lib/Cache/Utils/CacheList.js +5 -5
  16. package/lib/Credentials.js +2 -5
  17. package/lib/{Hub.d.ts → Hub/index.d.ts} +5 -21
  18. package/lib/Hub/index.js +151 -0
  19. package/lib/Hub/types/AuthTypes.d.ts +11 -0
  20. package/lib/Hub/types/HubTypes.d.ts +28 -0
  21. package/lib/Hub/types/HubTypes.js +4 -0
  22. package/lib/Hub/types/index.d.ts +2 -0
  23. package/lib/Hub/types/index.js +20 -0
  24. package/lib/I18n/I18n.js +1 -1
  25. package/lib/I18n/index.js +5 -5
  26. package/lib/OAuthHelper/FacebookOAuth.js +1 -1
  27. package/lib/OAuthHelper/GoogleOAuth.js +1 -1
  28. package/lib/Platform/version.d.ts +1 -1
  29. package/lib/Platform/version.js +1 -1
  30. package/lib/RNComponents/index.d.ts +1 -0
  31. package/lib/RNComponents/index.js +2 -1
  32. package/lib/RNComponents/isAppInForeground.d.ts +1 -0
  33. package/lib/RNComponents/isAppInForeground.js +10 -0
  34. package/lib/ServiceWorker/ServiceWorker.js +9 -9
  35. package/lib/StorageHelper/localStorage.js +1 -1
  36. package/lib/StorageHelper/sessionStorage.js +1 -1
  37. package/lib/UniversalStorage/index.js +1 -1
  38. package/lib/Util/Constants.d.ts +12 -8
  39. package/lib/Util/Constants.js +21 -15
  40. package/lib/{Errors.d.ts → Util/Errors.d.ts} +1 -1
  41. package/lib/Util/Reachability.js +1 -1
  42. package/lib/Util/errors/AssertError.js +1 -1
  43. package/lib/Util/index.d.ts +1 -1
  44. package/lib/Util/index.js +1 -5
  45. package/lib/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
  46. package/lib/adapterCore/error/AmplifyServerContextError.js +35 -0
  47. package/lib/adapterCore/error/index.d.ts +1 -0
  48. package/lib/adapterCore/error/index.js +7 -0
  49. package/lib/adapterCore/index.d.ts +2 -0
  50. package/lib/adapterCore/index.js +11 -0
  51. package/lib/adapterCore/serverContext/index.d.ts +2 -0
  52. package/lib/adapterCore/serverContext/index.js +9 -0
  53. package/lib/adapterCore/serverContext/serverContext.d.ts +20 -0
  54. package/lib/adapterCore/serverContext/serverContext.js +42 -0
  55. package/lib/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
  56. package/lib/adapterCore/serverContext/serverContextRegistry.js +24 -0
  57. package/lib/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
  58. package/lib/adapterCore/serverContext/types/amplifyServer.js +4 -0
  59. package/lib/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
  60. package/lib/adapterCore/serverContext/types/cookieStorage.js +4 -0
  61. package/lib/adapterCore/serverContext/types/index.d.ts +4 -0
  62. package/lib/adapterCore/serverContext/types/index.js +4 -0
  63. package/lib/clients/handlers/fetch.js +1 -0
  64. package/lib/clients/internal/composeServiceApi.d.ts +5 -2
  65. package/lib/index.d.ts +11 -32
  66. package/lib/index.js +19 -100
  67. package/lib/libraryUtils.d.ts +21 -0
  68. package/lib/libraryUtils.js +105 -0
  69. package/lib/providers/pinpoint/apis/index.d.ts +2 -0
  70. package/lib/providers/pinpoint/apis/index.js +9 -0
  71. package/lib/providers/pinpoint/apis/record.d.ts +5 -0
  72. package/lib/providers/pinpoint/apis/record.js +120 -0
  73. package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
  74. package/lib/providers/pinpoint/apis/updateEndpoint.js +120 -0
  75. package/lib/providers/pinpoint/index.d.ts +2 -0
  76. package/lib/providers/pinpoint/index.js +19 -0
  77. package/lib/providers/pinpoint/types/buffer.d.ts +25 -0
  78. package/lib/providers/pinpoint/types/buffer.js +4 -0
  79. package/lib/providers/pinpoint/types/index.d.ts +1 -0
  80. package/lib/providers/pinpoint/types/index.js +19 -0
  81. package/lib/providers/pinpoint/types/pinpoint.d.ts +40 -0
  82. package/lib/providers/pinpoint/types/pinpoint.js +4 -0
  83. package/lib/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
  84. package/lib/providers/pinpoint/utils/PinpointEventBuffer.js +278 -0
  85. package/lib/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
  86. package/lib/providers/pinpoint/utils/cacheEndpointId.js +61 -0
  87. package/lib/providers/pinpoint/utils/constants.d.ts +4 -0
  88. package/lib/providers/pinpoint/utils/constants.js +10 -0
  89. package/lib/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
  90. package/lib/providers/pinpoint/utils/getCacheKey.js +13 -0
  91. package/lib/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
  92. package/lib/providers/pinpoint/utils/getEndpointId.js +62 -0
  93. package/lib/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
  94. package/lib/providers/pinpoint/utils/getEventBuffer.js +48 -0
  95. package/lib/providers/pinpoint/utils/index.d.ts +3 -0
  96. package/lib/providers/pinpoint/utils/index.js +11 -0
  97. package/lib/server.d.ts +1 -0
  98. package/lib/server.js +7 -0
  99. package/lib/singleton/Amplify.d.ts +36 -0
  100. package/lib/singleton/Amplify.js +138 -0
  101. package/lib/singleton/Analytics/types.d.ts +2 -0
  102. package/lib/singleton/Analytics/types.js +4 -0
  103. package/lib/singleton/Auth/index.js +15 -12
  104. package/lib/singleton/Auth/types.d.ts +28 -3
  105. package/lib/singleton/Auth/utils/index.d.ts +3 -2
  106. package/lib/singleton/Auth/utils/index.js +15 -1
  107. package/lib/singleton/Storage/types.d.ts +6 -2
  108. package/lib/singleton/apis/fetchAuthSession.d.ts +2 -0
  109. package/lib/singleton/apis/fetchAuthSession.js +11 -0
  110. package/lib/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
  111. package/lib/singleton/apis/internal/fetchAuthSession.js +9 -0
  112. package/lib/singleton/apis/server/fetchAuthSession.d.ts +3 -0
  113. package/lib/singleton/apis/server/fetchAuthSession.js +11 -0
  114. package/lib/singleton/index.d.ts +2 -46
  115. package/lib/singleton/index.js +7 -157
  116. package/lib/singleton/types.d.ts +3 -1
  117. package/lib/tsconfig.tsbuildinfo +1 -1
  118. package/lib/types/core.d.ts +47 -0
  119. package/lib/types/core.js +4 -0
  120. package/lib/types/errors.d.ts +16 -0
  121. package/lib/types/errors.js +4 -0
  122. package/lib/types/index.d.ts +4 -1
  123. package/lib/types/index.js +6 -3
  124. package/lib/types/logging.d.ts +13 -0
  125. package/lib/types/logging.js +4 -0
  126. package/lib/types/storage.d.ts +14 -0
  127. package/lib/types/storage.js +4 -0
  128. package/lib-esm/AwsClients/CognitoIdentity/getCredentialsForIdentity.d.ts +1 -1
  129. package/lib-esm/AwsClients/CognitoIdentity/getId.d.ts +1 -1
  130. package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
  131. package/lib-esm/AwsClients/Pinpoint/index.d.ts +1 -1
  132. package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +1 -1
  133. package/lib-esm/AwsClients/Pinpoint/putEvents.js +1 -1
  134. package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
  135. package/lib-esm/Cache/AsyncStorageCache.js +1 -1
  136. package/lib-esm/Cache/BrowserStorageCache.js +1 -1
  137. package/lib-esm/Cache/InMemoryCache.js +1 -1
  138. package/lib-esm/Cache/StorageCache.js +2 -2
  139. package/lib-esm/Cache/Utils/CacheList.js +1 -1
  140. package/lib-esm/Credentials.js +2 -5
  141. package/lib-esm/{Hub.d.ts → Hub/index.d.ts} +5 -21
  142. package/lib-esm/Hub/index.js +148 -0
  143. package/lib-esm/Hub/types/AuthTypes.d.ts +11 -0
  144. package/lib-esm/Hub/types/HubTypes.d.ts +28 -0
  145. package/lib-esm/Hub/types/HubTypes.js +3 -0
  146. package/lib-esm/Hub/types/index.d.ts +2 -0
  147. package/lib-esm/Hub/types/index.js +4 -0
  148. package/lib-esm/I18n/I18n.js +2 -2
  149. package/lib-esm/I18n/index.js +1 -1
  150. package/lib-esm/OAuthHelper/FacebookOAuth.js +1 -1
  151. package/lib-esm/OAuthHelper/GoogleOAuth.js +1 -1
  152. package/lib-esm/Platform/version.d.ts +1 -1
  153. package/lib-esm/Platform/version.js +1 -1
  154. package/lib-esm/RNComponents/index.d.ts +1 -0
  155. package/lib-esm/RNComponents/index.js +2 -1
  156. package/lib-esm/RNComponents/isAppInForeground.d.ts +1 -0
  157. package/lib-esm/RNComponents/isAppInForeground.js +6 -0
  158. package/lib-esm/ServiceWorker/ServiceWorker.js +3 -3
  159. package/lib-esm/StorageHelper/localStorage.js +1 -1
  160. package/lib-esm/StorageHelper/sessionStorage.js +1 -1
  161. package/lib-esm/UniversalStorage/index.js +1 -1
  162. package/lib-esm/Util/Constants.d.ts +12 -8
  163. package/lib-esm/Util/Constants.js +20 -8
  164. package/lib-esm/{Errors.d.ts → Util/Errors.d.ts} +1 -1
  165. package/lib-esm/Util/Reachability.js +1 -1
  166. package/lib-esm/Util/errors/AssertError.js +1 -1
  167. package/lib-esm/Util/index.d.ts +1 -1
  168. package/lib-esm/Util/index.js +1 -1
  169. package/lib-esm/adapterCore/error/AmplifyServerContextError.d.ts +8 -0
  170. package/lib-esm/adapterCore/error/AmplifyServerContextError.js +32 -0
  171. package/lib-esm/adapterCore/error/index.d.ts +1 -0
  172. package/lib-esm/adapterCore/error/index.js +3 -0
  173. package/lib-esm/adapterCore/index.d.ts +2 -0
  174. package/lib-esm/adapterCore/index.js +4 -0
  175. package/lib-esm/adapterCore/serverContext/index.d.ts +2 -0
  176. package/lib-esm/adapterCore/serverContext/index.js +3 -0
  177. package/lib-esm/adapterCore/serverContext/serverContext.d.ts +20 -0
  178. package/lib-esm/adapterCore/serverContext/serverContext.js +36 -0
  179. package/lib-esm/adapterCore/serverContext/serverContextRegistry.d.ts +6 -0
  180. package/lib-esm/adapterCore/serverContext/serverContextRegistry.js +21 -0
  181. package/lib-esm/adapterCore/serverContext/types/amplifyServer.d.ts +16 -0
  182. package/lib-esm/adapterCore/serverContext/types/amplifyServer.js +3 -0
  183. package/lib-esm/adapterCore/serverContext/types/cookieStorage.d.ts +31 -0
  184. package/lib-esm/adapterCore/serverContext/types/cookieStorage.js +3 -0
  185. package/lib-esm/adapterCore/serverContext/types/index.d.ts +4 -0
  186. package/lib-esm/adapterCore/serverContext/types/index.js +3 -0
  187. package/lib-esm/clients/handlers/fetch.js +1 -0
  188. package/lib-esm/clients/internal/composeServiceApi.d.ts +5 -2
  189. package/lib-esm/index.d.ts +11 -32
  190. package/lib-esm/index.js +11 -29
  191. package/lib-esm/libraryUtils.d.ts +21 -0
  192. package/lib-esm/libraryUtils.js +33 -0
  193. package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
  194. package/lib-esm/providers/pinpoint/apis/index.js +4 -0
  195. package/lib-esm/providers/pinpoint/apis/record.d.ts +5 -0
  196. package/lib-esm/providers/pinpoint/apis/record.js +116 -0
  197. package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +5 -0
  198. package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +116 -0
  199. package/lib-esm/providers/pinpoint/index.d.ts +2 -0
  200. package/lib-esm/providers/pinpoint/index.js +3 -0
  201. package/lib-esm/providers/pinpoint/types/buffer.d.ts +25 -0
  202. package/lib-esm/providers/pinpoint/types/buffer.js +3 -0
  203. package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
  204. package/lib-esm/providers/pinpoint/types/index.js +3 -0
  205. package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +40 -0
  206. package/lib-esm/providers/pinpoint/types/pinpoint.js +3 -0
  207. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.d.ts +23 -0
  208. package/lib-esm/providers/pinpoint/utils/PinpointEventBuffer.js +275 -0
  209. package/lib-esm/providers/pinpoint/utils/cacheEndpointId.d.ts +7 -0
  210. package/lib-esm/providers/pinpoint/utils/cacheEndpointId.js +57 -0
  211. package/lib-esm/providers/pinpoint/utils/constants.d.ts +4 -0
  212. package/lib-esm/providers/pinpoint/utils/constants.js +7 -0
  213. package/lib-esm/providers/pinpoint/utils/getCacheKey.d.ts +7 -0
  214. package/lib-esm/providers/pinpoint/utils/getCacheKey.js +9 -0
  215. package/lib-esm/providers/pinpoint/utils/getEndpointId.d.ts +7 -0
  216. package/lib-esm/providers/pinpoint/utils/getEndpointId.js +58 -0
  217. package/lib-esm/providers/pinpoint/utils/getEventBuffer.d.ts +8 -0
  218. package/lib-esm/providers/pinpoint/utils/getEventBuffer.js +44 -0
  219. package/lib-esm/providers/pinpoint/utils/index.d.ts +3 -0
  220. package/lib-esm/providers/pinpoint/utils/index.js +5 -0
  221. package/lib-esm/server.d.ts +1 -0
  222. package/lib-esm/server.js +3 -0
  223. package/lib-esm/singleton/Amplify.d.ts +36 -0
  224. package/lib-esm/singleton/Amplify.js +135 -0
  225. package/lib-esm/singleton/Analytics/types.d.ts +2 -0
  226. package/lib-esm/singleton/Analytics/types.js +3 -0
  227. package/lib-esm/singleton/Auth/index.js +14 -11
  228. package/lib-esm/singleton/Auth/types.d.ts +28 -3
  229. package/lib-esm/singleton/Auth/utils/index.d.ts +3 -2
  230. package/lib-esm/singleton/Auth/utils/index.js +13 -0
  231. package/lib-esm/singleton/Storage/types.d.ts +6 -2
  232. package/lib-esm/singleton/apis/fetchAuthSession.d.ts +2 -0
  233. package/lib-esm/singleton/apis/fetchAuthSession.js +7 -0
  234. package/lib-esm/singleton/apis/internal/fetchAuthSession.d.ts +3 -0
  235. package/lib-esm/singleton/apis/internal/fetchAuthSession.js +5 -0
  236. package/lib-esm/singleton/apis/server/fetchAuthSession.d.ts +3 -0
  237. package/lib-esm/singleton/apis/server/fetchAuthSession.js +7 -0
  238. package/lib-esm/singleton/index.d.ts +2 -46
  239. package/lib-esm/singleton/index.js +2 -154
  240. package/lib-esm/singleton/types.d.ts +3 -1
  241. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  242. package/lib-esm/types/core.d.ts +47 -0
  243. package/lib-esm/types/core.js +3 -0
  244. package/lib-esm/types/errors.d.ts +16 -0
  245. package/lib-esm/types/errors.js +3 -0
  246. package/lib-esm/types/index.d.ts +4 -1
  247. package/lib-esm/types/index.js +4 -1
  248. package/lib-esm/types/logging.d.ts +13 -0
  249. package/lib-esm/types/logging.js +3 -0
  250. package/lib-esm/types/storage.d.ts +14 -0
  251. package/lib-esm/types/storage.js +3 -0
  252. package/package.json +15 -12
  253. package/server/package.json +8 -0
  254. package/src/AwsClients/Pinpoint/index.ts +1 -1
  255. package/src/AwsClients/Pinpoint/putEvents.ts +1 -1
  256. package/src/Cache/AsyncStorageCache.ts +1 -1
  257. package/src/Cache/BrowserStorageCache.ts +1 -1
  258. package/src/Cache/InMemoryCache.ts +1 -1
  259. package/src/Cache/StorageCache.ts +2 -2
  260. package/src/Cache/Utils/CacheList.ts +1 -1
  261. package/src/Credentials.ts +2 -8
  262. package/src/Hub/index.ts +204 -0
  263. package/src/Hub/types/AuthTypes.ts +10 -0
  264. package/src/Hub/types/HubTypes.ts +46 -0
  265. package/src/{Providers → Hub/types}/index.ts +3 -1
  266. package/src/I18n/I18n.ts +2 -2
  267. package/src/I18n/index.ts +1 -1
  268. package/src/Logger/ConsoleLogger.ts +1 -2
  269. package/src/OAuthHelper/FacebookOAuth.ts +1 -1
  270. package/src/OAuthHelper/GoogleOAuth.ts +1 -1
  271. package/src/Platform/version.ts +1 -1
  272. package/src/RNComponents/index.ts +2 -1
  273. package/src/RNComponents/isAppInForeground.ts +8 -0
  274. package/src/ServiceWorker/ServiceWorker.ts +3 -3
  275. package/src/StorageHelper/localStorage.ts +1 -1
  276. package/src/StorageHelper/sessionStorage.ts +1 -1
  277. package/src/UniversalStorage/index.ts +1 -1
  278. package/src/Util/Constants.ts +25 -16
  279. package/src/{Errors.ts → Util/Errors.ts} +1 -1
  280. package/src/Util/Reachability.ts +1 -1
  281. package/src/Util/errors/AssertError.ts +1 -1
  282. package/src/Util/index.ts +0 -4
  283. package/src/adapterCore/error/AmplifyServerContextError.ts +23 -0
  284. package/src/adapterCore/error/index.ts +4 -0
  285. package/src/adapterCore/index.ts +11 -0
  286. package/src/adapterCore/serverContext/index.ts +10 -0
  287. package/src/adapterCore/serverContext/serverContext.ts +54 -0
  288. package/src/adapterCore/serverContext/serverContextRegistry.ts +31 -0
  289. package/src/adapterCore/serverContext/types/amplifyServer.ts +29 -0
  290. package/src/adapterCore/serverContext/types/cookieStorage.ts +43 -0
  291. package/src/adapterCore/serverContext/types/index.ts +9 -0
  292. package/src/clients/handlers/fetch.ts +1 -0
  293. package/src/clients/internal/composeServiceApi.ts +13 -4
  294. package/src/index.ts +40 -120
  295. package/src/libraryUtils.ts +102 -0
  296. package/src/providers/pinpoint/apis/index.ts +5 -0
  297. package/src/providers/pinpoint/apis/record.ts +90 -0
  298. package/src/providers/pinpoint/apis/updateEndpoint.ts +82 -0
  299. package/src/providers/pinpoint/index.ts +5 -0
  300. package/src/providers/pinpoint/types/buffer.ts +32 -0
  301. package/{lib-esm/Providers/index.js → src/providers/pinpoint/types/index.ts} +2 -1
  302. package/src/providers/pinpoint/types/pinpoint.ts +55 -0
  303. package/src/providers/pinpoint/utils/PinpointEventBuffer.ts +248 -0
  304. package/src/providers/pinpoint/utils/cacheEndpointId.ts +27 -0
  305. package/src/providers/pinpoint/utils/constants.ts +8 -0
  306. package/src/providers/pinpoint/utils/getCacheKey.ts +16 -0
  307. package/src/providers/pinpoint/utils/getEndpointId.ts +20 -0
  308. package/src/providers/pinpoint/utils/getEventBuffer.ts +60 -0
  309. package/src/providers/pinpoint/utils/index.ts +6 -0
  310. package/src/server.ts +4 -0
  311. package/src/singleton/Amplify.ts +121 -0
  312. package/src/singleton/Analytics/types.ts +6 -0
  313. package/src/singleton/Auth/index.ts +7 -5
  314. package/src/singleton/Auth/types.ts +38 -6
  315. package/src/singleton/Auth/utils/index.ts +27 -1
  316. package/src/singleton/Storage/types.ts +6 -3
  317. package/src/singleton/apis/fetchAuthSession.ts +12 -0
  318. package/src/singleton/apis/internal/fetchAuthSession.ts +12 -0
  319. package/src/singleton/apis/server/fetchAuthSession.ts +16 -0
  320. package/src/singleton/index.ts +2 -141
  321. package/src/singleton/types.ts +4 -4
  322. package/src/types/core.ts +58 -0
  323. package/src/types/errors.ts +21 -0
  324. package/src/types/index.ts +5 -1
  325. package/src/types/logging.ts +24 -0
  326. package/src/types/storage.ts +19 -0
  327. package/lib/Hub.js +0 -220
  328. package/lib/Providers/AWSCloudWatchProvider.d.ts +0 -34
  329. package/lib/Providers/AWSCloudWatchProvider.js +0 -619
  330. package/lib/Providers/index.d.ts +0 -1
  331. package/lib/Providers/index.js +0 -7
  332. package/lib/constants.d.ts +0 -9
  333. package/lib/constants.js +0 -22
  334. package/lib/types/types.d.ts +0 -76
  335. package/lib-esm/Hub.js +0 -217
  336. package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +0 -34
  337. package/lib-esm/Providers/AWSCloudWatchProvider.js +0 -616
  338. package/lib-esm/Providers/index.d.ts +0 -1
  339. package/lib-esm/constants.d.ts +0 -9
  340. package/lib-esm/constants.js +0 -19
  341. package/lib-esm/types/types.d.ts +0 -76
  342. package/src/Hub.ts +0 -236
  343. package/src/Providers/AWSCloudWatchProvider.ts +0 -540
  344. package/src/constants.ts +0 -31
  345. package/src/types/types.ts +0 -104
  346. /package/lib/{types/types.js → Hub/types/AuthTypes.js} +0 -0
  347. /package/lib/{Errors.js → Util/Errors.js} +0 -0
  348. /package/lib/{JS.d.ts → Util/JS.d.ts} +0 -0
  349. /package/lib/{JS.js → Util/JS.js} +0 -0
  350. /package/lib-esm/{types/types.js → Hub/types/AuthTypes.js} +0 -0
  351. /package/lib-esm/{Errors.js → Util/Errors.js} +0 -0
  352. /package/lib-esm/{JS.d.ts → Util/JS.d.ts} +0 -0
  353. /package/lib-esm/{JS.js → Util/JS.js} +0 -0
  354. /package/src/{JS.ts → Util/JS.ts} +0 -0
@@ -0,0 +1,36 @@
1
+ import { AuthClass } from './Auth';
2
+ import { LibraryOptions, ResourcesConfig } from './types';
3
+ export declare class AmplifyClass {
4
+ resourcesConfig: ResourcesConfig;
5
+ libraryOptions: LibraryOptions;
6
+ /**
7
+ * Cross-category Auth utilities.
8
+ *
9
+ * @internal
10
+ */
11
+ readonly Auth: AuthClass;
12
+ constructor();
13
+ /**
14
+ * Configures Amplify for use with your back-end resources.
15
+ *
16
+ * @remarks
17
+ * `configure` can be used to specify additional library options where available for supported categories.
18
+ *
19
+ * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
20
+ * @param libraryOptions - Additional options for customizing the behavior of the library.
21
+ */
22
+ configure(resourcesConfig: ResourcesConfig, libraryOptions?: LibraryOptions): void;
23
+ /**
24
+ * Provides access to the current back-end resource configuration for the Library.
25
+ *
26
+ * @returns Returns the current back-end resource configuration.
27
+ */
28
+ getConfig(): ResourcesConfig;
29
+ }
30
+ /**
31
+ * The `Amplify` utility is used to configure the library.
32
+ *
33
+ * @remarks
34
+ * `Amplify` is responsible for orchestrating cross-category communication within the library.
35
+ */
36
+ export declare const Amplify: AmplifyClass;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __values = (this && this.__values) || function(o) {
14
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
+ if (m) return m.call(o);
16
+ if (o && typeof o.length === "number") return {
17
+ next: function () {
18
+ if (o && i >= o.length) o = void 0;
19
+ return { value: o && o[i++], done: !o };
20
+ }
21
+ };
22
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Amplify = exports.AmplifyClass = void 0;
26
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
+ // SPDX-License-Identifier: Apache-2.0
28
+ var Auth_1 = require("./Auth");
29
+ var Hub_1 = require("../Hub");
30
+ // TODO(v6): add default AuthTokenStore for each platform
31
+ var AmplifyClass = /** @class */ (function () {
32
+ function AmplifyClass() {
33
+ this.resourcesConfig = {};
34
+ this.Auth = new Auth_1.AuthClass();
35
+ // TODO(v6): add default providers for getting started
36
+ this.libraryOptions = {};
37
+ }
38
+ /**
39
+ * Configures Amplify for use with your back-end resources.
40
+ *
41
+ * @remarks
42
+ * `configure` can be used to specify additional library options where available for supported categories.
43
+ *
44
+ * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
45
+ * @param libraryOptions - Additional options for customizing the behavior of the library.
46
+ */
47
+ AmplifyClass.prototype.configure = function (resourcesConfig, libraryOptions) {
48
+ if (libraryOptions === void 0) { libraryOptions = {}; }
49
+ this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resourcesConfig);
50
+ this.libraryOptions = mergeLibraryOptions(this.libraryOptions, libraryOptions);
51
+ this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
52
+ Hub_1.Hub.dispatch('core', {
53
+ event: 'configure',
54
+ data: resourcesConfig,
55
+ }, 'Configure', Hub_1.AMPLIFY_SYMBOL);
56
+ };
57
+ /**
58
+ * Provides access to the current back-end resource configuration for the Library.
59
+ *
60
+ * @returns Returns the current back-end resource configuration.
61
+ */
62
+ AmplifyClass.prototype.getConfig = function () {
63
+ return JSON.parse(JSON.stringify(this.resourcesConfig));
64
+ };
65
+ return AmplifyClass;
66
+ }());
67
+ exports.AmplifyClass = AmplifyClass;
68
+ /**
69
+ * The `Amplify` utility is used to configure the library.
70
+ *
71
+ * @remarks
72
+ * `Amplify` is responsible for orchestrating cross-category communication within the library.
73
+ */
74
+ exports.Amplify = new AmplifyClass();
75
+ // TODO(v6): validate until which level this will nested, during Amplify.configure API review.
76
+ function mergeResourceConfig(existingConfig, newConfig) {
77
+ var e_1, _a, e_2, _b;
78
+ var resultConfig = {};
79
+ try {
80
+ for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
81
+ var category = _d.value;
82
+ resultConfig[category] = existingConfig[category];
83
+ }
84
+ }
85
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
86
+ finally {
87
+ try {
88
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
89
+ }
90
+ finally { if (e_1) throw e_1.error; }
91
+ }
92
+ try {
93
+ for (var _e = __values(Object.keys(newConfig).filter(function (key) { return key !== 'ssr'; })), _f = _e.next(); !_f.done; _f = _e.next()) {
94
+ var key = _f.value;
95
+ resultConfig[key] = __assign(__assign({}, resultConfig[key]), newConfig[key]);
96
+ }
97
+ }
98
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
99
+ finally {
100
+ try {
101
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
102
+ }
103
+ finally { if (e_2) throw e_2.error; }
104
+ }
105
+ resultConfig.ssr = newConfig.ssr;
106
+ return resultConfig;
107
+ }
108
+ function mergeLibraryOptions(existingConfig, newConfig) {
109
+ var e_3, _a, e_4, _b;
110
+ var resultConfig = {};
111
+ try {
112
+ for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
113
+ var category = _d.value;
114
+ resultConfig[category] = existingConfig[category];
115
+ }
116
+ }
117
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
118
+ finally {
119
+ try {
120
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
121
+ }
122
+ finally { if (e_3) throw e_3.error; }
123
+ }
124
+ try {
125
+ for (var _e = __values(Object.keys(newConfig)), _f = _e.next(); !_f.done; _f = _e.next()) {
126
+ var category = _f.value;
127
+ resultConfig[category] = __assign(__assign({}, resultConfig[category]), newConfig[category]);
128
+ }
129
+ }
130
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
131
+ finally {
132
+ try {
133
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
134
+ }
135
+ finally { if (e_4) throw e_4.error; }
136
+ }
137
+ return resultConfig;
138
+ }
@@ -0,0 +1,2 @@
1
+ import { PinpointProviderConfig } from '../../providers/pinpoint/types';
2
+ export type AnalyticsConfig = PinpointProviderConfig;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -41,7 +41,7 @@ exports.AuthClass = exports.isTokenExpired = void 0;
41
41
  // SPDX-License-Identifier: Apache-2.0
42
42
  var rxjs_1 = require("rxjs");
43
43
  var AssertError_1 = require("../../Util/errors/AssertError");
44
- var constants_1 = require("../../constants");
44
+ var Constants_1 = require("../../Util/Constants");
45
45
  function isTokenExpired(_a) {
46
46
  var expiresAt = _a.expiresAt, clockDrift = _a.clockDrift;
47
47
  var currentTime = Date.now();
@@ -73,16 +73,17 @@ var AuthClass = /** @class */ (function () {
73
73
  var tokens, credentialsAndIdentityId;
74
74
  return __generator(this, function (_h) {
75
75
  switch (_h.label) {
76
- case 0: return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
77
- case 1:
78
- // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
79
- tokens =
80
- (_c = (_h.sent())) !== null && _c !== void 0 ? _c : undefined;
76
+ case 0:
81
77
  (0, AssertError_1.asserts)(!!this.authConfig, {
82
- name: constants_1.AUTH_CONFING_EXCEPTION,
78
+ name: Constants_1.AUTH_CONFING_EXCEPTION,
83
79
  message: 'AuthConfig is required',
84
80
  recoverySuggestion: 'call Amplify.configure in your app with a valid AuthConfig',
85
81
  });
82
+ return [4 /*yield*/, ((_b = (_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.tokenProvider) === null || _b === void 0 ? void 0 : _b.getTokens(options))];
83
+ case 1:
84
+ // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available
85
+ tokens =
86
+ (_c = (_h.sent())) !== null && _c !== void 0 ? _c : undefined;
86
87
  if (!tokens) return [3 /*break*/, 3];
87
88
  return [4 /*yield*/, ((_e = (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.credentialsProvider) === null || _e === void 0 ? void 0 : _e.getCredentialsAndIdentityId({
88
89
  authConfig: this.authConfig,
@@ -95,11 +96,13 @@ var AuthClass = /** @class */ (function () {
95
96
  credentialsAndIdentityId =
96
97
  _h.sent();
97
98
  return [3 /*break*/, 5];
98
- case 3: return [4 /*yield*/, ((_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.credentialsProvider) === null || _g === void 0 ? void 0 : _g.getCredentialsAndIdentityId({
99
- authConfig: this.authConfig,
100
- authenticated: false,
101
- forceRefresh: options.forceRefresh,
102
- }))];
99
+ case 3:
100
+ if (!!this.authConfig.isMandatorySignInEnabled) return [3 /*break*/, 5];
101
+ return [4 /*yield*/, ((_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.credentialsProvider) === null || _g === void 0 ? void 0 : _g.getCredentialsAndIdentityId({
102
+ authConfig: this.authConfig,
103
+ authenticated: false,
104
+ forceRefresh: options.forceRefresh,
105
+ }))];
103
106
  case 4:
104
107
  // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)
105
108
  credentialsAndIdentityId =
@@ -37,7 +37,7 @@ export interface AWSCredentialsAndIdentityIdProvider {
37
37
  clearCredentials: () => void;
38
38
  }
39
39
  export type TokenProvider = {
40
- getTokens: ({ forceRefresh, }: {
40
+ getTokens: ({ forceRefresh, }?: {
41
41
  forceRefresh?: boolean;
42
42
  }) => Promise<AuthTokens | null>;
43
43
  };
@@ -48,7 +48,10 @@ export type AuthTokens = {
48
48
  idToken?: JWT;
49
49
  accessToken: JWT;
50
50
  };
51
- export type AuthConfig = IdentityPoolConfig | UserPoolConfig | UserPoolConfigAndIdentityPoolConfig;
51
+ export type AuthConfig = StrictUnion<IdentityPoolConfig | UserPoolConfig | UserPoolConfigWithOAuth | UserPoolConfigAndIdentityPoolConfig | UserPoolConfigAndIdentityPoolConfigWithOAuth>;
52
+ type UnionKeys<T> = T extends T ? keyof T : never;
53
+ type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
54
+ type StrictUnion<T> = StrictUnionHelper<T, T>;
52
55
  export type IdentityPoolConfig = {
53
56
  identityPoolId: string;
54
57
  userPoolWebClientId?: never;
@@ -62,6 +65,20 @@ export type UserPoolConfig = {
62
65
  identityPoolId?: never;
63
66
  clientMetadata?: Record<string, string>;
64
67
  };
68
+ export type UserPoolConfigWithOAuth = {
69
+ userPoolWebClientId: string;
70
+ userPoolId: string;
71
+ identityPoolId?: never;
72
+ clientMetadata?: Record<string, string>;
73
+ oauth: OAuthConfig;
74
+ };
75
+ export type OAuthConfig = {
76
+ domain: string;
77
+ scopes: Array<string>;
78
+ redirectSignIn: string;
79
+ redirectSignOut: string;
80
+ responseType: string;
81
+ };
65
82
  export type UserPoolConfigAndIdentityPoolConfig = {
66
83
  userPoolWebClientId: string;
67
84
  userPoolId: string;
@@ -69,12 +86,20 @@ export type UserPoolConfigAndIdentityPoolConfig = {
69
86
  clientMetadata?: Record<string, string>;
70
87
  isMandatorySignInEnabled?: boolean;
71
88
  };
89
+ export type UserPoolConfigAndIdentityPoolConfigWithOAuth = {
90
+ userPoolWebClientId: string;
91
+ userPoolId: string;
92
+ identityPoolId: string;
93
+ clientMetadata?: Record<string, string>;
94
+ isMandatorySignInEnabled?: boolean;
95
+ oauth: OAuthConfig;
96
+ };
72
97
  export type GetCredentialsOptions = GetCredentialsAuthenticatedUser | GetCredentialsUnauthenticatedUser;
73
98
  type GetCredentialsAuthenticatedUser = {
74
99
  authenticated: true;
75
100
  forceRefresh?: boolean;
76
101
  authConfig: AuthConfig;
77
- tokens?: AuthTokens;
102
+ tokens: AuthTokens;
78
103
  };
79
104
  type GetCredentialsUnauthenticatedUser = {
80
105
  authenticated: false;
@@ -1,5 +1,6 @@
1
- import { AuthConfig, IdentityPoolConfig, JWT, UserPoolConfig, UserPoolConfigAndIdentityPoolConfig } from '../types';
2
- export declare function assertTokenProviderConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfig;
1
+ import { AuthConfig, IdentityPoolConfig, JWT, UserPoolConfig, UserPoolConfigAndIdentityPoolConfig, UserPoolConfigAndIdentityPoolConfigWithOAuth, UserPoolConfigWithOAuth } from '../types';
2
+ export declare function assertTokenProviderConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfigWithOAuth | UserPoolConfigWithOAuth | UserPoolConfigAndIdentityPoolConfig | UserPoolConfig;
3
+ export declare function assertOAuthConfig(authConfig?: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfigWithOAuth | UserPoolConfigWithOAuth;
3
4
  export declare function assertIdentityPooIdConfig(authConfig: AuthConfig): asserts authConfig is IdentityPoolConfig;
4
5
  export declare function assertUserPoolAndIdentityPooConfig(authConfig: AuthConfig): asserts authConfig is UserPoolConfigAndIdentityPoolConfig;
5
6
  export declare function decodeJWT(token: string): JWT;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeJWT = exports.assertUserPoolAndIdentityPooConfig = exports.assertIdentityPooIdConfig = exports.assertTokenProviderConfig = void 0;
3
+ exports.decodeJWT = exports.assertUserPoolAndIdentityPooConfig = exports.assertIdentityPooIdConfig = exports.assertOAuthConfig = exports.assertTokenProviderConfig = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  var buffer_1 = require("buffer");
@@ -14,6 +14,20 @@ function assertTokenProviderConfig(authConfig) {
14
14
  });
15
15
  }
16
16
  exports.assertTokenProviderConfig = assertTokenProviderConfig;
17
+ function assertOAuthConfig(authConfig) {
18
+ var _a, _b, _c, _d;
19
+ assertTokenProviderConfig(authConfig);
20
+ var validOAuthConfig = !!((_a = authConfig.oauth) === null || _a === void 0 ? void 0 : _a.domain) &&
21
+ !!((_b = authConfig.oauth) === null || _b === void 0 ? void 0 : _b.redirectSignOut) &&
22
+ !!((_c = authConfig.oauth) === null || _c === void 0 ? void 0 : _c.redirectSignIn) &&
23
+ !!((_d = authConfig.oauth) === null || _d === void 0 ? void 0 : _d.responseType);
24
+ return (0, AssertError_1.asserts)(validOAuthConfig, {
25
+ name: 'OAuthNotConfigureException',
26
+ message: 'oauth param not configured',
27
+ recoverySuggestion: 'Make sure to call Amplify.configure with oauth parameter in your app',
28
+ });
29
+ }
30
+ exports.assertOAuthConfig = assertOAuthConfig;
17
31
  function assertIdentityPooIdConfig(authConfig) {
18
32
  var validConfig = !!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.identityPoolId);
19
33
  return (0, AssertError_1.asserts)(validConfig, {
@@ -2,13 +2,17 @@ export type StorageAccessLevel = 'guest' | 'protected' | 'private';
2
2
  export interface StorageConfig {
3
3
  bucket?: string;
4
4
  region?: string;
5
+ dangerouslyConnectToHttpEndpointForTesting?: string;
5
6
  }
6
7
  type StoragePrefixResolver = (params: {
7
8
  accessLevel: StorageAccessLevel;
8
9
  targetIdentityId?: string;
9
10
  }) => Promise<string>;
10
11
  export interface LibraryStorageOptions {
11
- prefixResolver?: StoragePrefixResolver;
12
- defaultAccessLevel?: StorageAccessLevel;
12
+ AWSS3: {
13
+ prefixResolver?: StoragePrefixResolver;
14
+ defaultAccessLevel?: StorageAccessLevel;
15
+ isObjectLockEnabled?: boolean;
16
+ };
13
17
  }
14
18
  export {};
@@ -0,0 +1,2 @@
1
+ import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';
2
+ export declare const fetchAuthSession: (options?: FetchAuthSessionOptions) => Promise<AuthSession>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.fetchAuthSession = void 0;
6
+ var fetchAuthSession_1 = require("./internal/fetchAuthSession");
7
+ var Amplify_1 = require("../Amplify");
8
+ var fetchAuthSession = function (options) {
9
+ return (0, fetchAuthSession_1.fetchAuthSession)(Amplify_1.Amplify, options);
10
+ };
11
+ exports.fetchAuthSession = fetchAuthSession;
@@ -0,0 +1,3 @@
1
+ import { AmplifyClass } from '../../Amplify';
2
+ import { AuthSession, FetchAuthSessionOptions } from '../../Auth/types';
3
+ export declare const fetchAuthSession: (amplify: AmplifyClass, options?: FetchAuthSessionOptions) => Promise<AuthSession>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.fetchAuthSession = void 0;
6
+ var fetchAuthSession = function (amplify, options) {
7
+ return amplify.Auth.fetchAuthSession(options);
8
+ };
9
+ exports.fetchAuthSession = fetchAuthSession;
@@ -0,0 +1,3 @@
1
+ import { AmplifyServer } from '../../../adapterCore';
2
+ import { AuthSession, FetchAuthSessionOptions } from '../../Auth/types';
3
+ export declare const fetchAuthSession: (contextSpec: AmplifyServer.ContextSpec, options?: FetchAuthSessionOptions) => Promise<AuthSession>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.fetchAuthSession = void 0;
6
+ var adapterCore_1 = require("../../../adapterCore");
7
+ var fetchAuthSession_1 = require("../internal/fetchAuthSession");
8
+ var fetchAuthSession = function (contextSpec, options) {
9
+ return (0, fetchAuthSession_1.fetchAuthSession)((0, adapterCore_1.getAmplifyServerContext)(contextSpec).amplify, options);
10
+ };
11
+ exports.fetchAuthSession = fetchAuthSession;
@@ -1,46 +1,2 @@
1
- import { AuthClass } from './Auth';
2
- import { LibraryOptions, ResourcesConfig } from './types';
3
- import { FetchAuthSessionOptions } from './Auth/types';
4
- declare class AmplifyClass {
5
- resourcesConfig: ResourcesConfig;
6
- libraryOptions: LibraryOptions;
7
- /**
8
- * Cross-category Auth utilities.
9
- *
10
- * @internal
11
- */
12
- readonly Auth: AuthClass;
13
- constructor();
14
- /**
15
- * Configures Amplify for use with your back-end resources.
16
- *
17
- * @remarks
18
- * `configure` can be used to specify additional library options where available for supported categories.
19
- *
20
- * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
21
- * @param libraryOptions - Additional options for customizing the behavior of the library.
22
- */
23
- configure(resourcesConfig: ResourcesConfig, libraryOptions?: LibraryOptions): void;
24
- /**
25
- * Provides access to the current back-end resource configuration for the Library.
26
- *
27
- * @returns Returns the current back-end resource configuration.
28
- */
29
- getConfig(): ResourcesConfig;
30
- }
31
- /**
32
- * The `Amplify` utility is used to configure the library.
33
- *
34
- * @remarks
35
- * `Amplify` is responsible for orchestrating cross-category communication within the library.
36
- */
37
- export declare const AmplifyV6: AmplifyClass;
38
- /**
39
- * Returns current session tokens and credentials
40
- *
41
- * @param options{FetchAuthSessionOptions} - Options for fetching session.
42
- *
43
- * @returns Returns a promise that will resolve with fresh authentication tokens.
44
- */
45
- export declare const fetchAuthSession: (options: FetchAuthSessionOptions) => Promise<import("./Auth/types").AuthSession>;
46
- export {};
1
+ export { AmplifyClass, Amplify } from './Amplify';
2
+ export { fetchAuthSession } from './apis/fetchAuthSession';
@@ -1,160 +1,10 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __values = (this && this.__values) || function(o) {
14
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
- if (m) return m.call(o);
16
- if (o && typeof o.length === "number") return {
17
- next: function () {
18
- if (o && i >= o.length) o = void 0;
19
- return { value: o && o[i++], done: !o };
20
- }
21
- };
22
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.fetchAuthSession = exports.AmplifyV6 = void 0;
26
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
3
  // SPDX-License-Identifier: Apache-2.0
28
- var Auth_1 = require("./Auth");
29
- var Hub_1 = require("../Hub");
30
- var Errors_1 = require("../Errors");
31
- // TODO(v6): add default AuthTokenStore for each platform
32
- var AmplifyClass = /** @class */ (function () {
33
- function AmplifyClass() {
34
- this.resourcesConfig = {};
35
- this.Auth = new Auth_1.AuthClass();
36
- // TODO(v6): add default providers for getting started
37
- this.libraryOptions = {
38
- Auth: {
39
- tokenProvider: {
40
- getTokens: function () {
41
- throw new Errors_1.AmplifyError({
42
- message: 'No tokenProvider provided',
43
- name: 'MissingTokenProvider',
44
- recoverySuggestion: 'Make sure to call Amplify.configure in your app with a tokenProvider',
45
- });
46
- },
47
- },
48
- },
49
- };
50
- }
51
- /**
52
- * Configures Amplify for use with your back-end resources.
53
- *
54
- * @remarks
55
- * `configure` can be used to specify additional library options where available for supported categories.
56
- *
57
- * @param resourceConfig - Back-end resource configuration. Typically provided via the `aws-exports.js` file.
58
- * @param libraryOptions - Additional options for customizing the behavior of the library.
59
- */
60
- AmplifyClass.prototype.configure = function (resourcesConfig, libraryOptions) {
61
- if (libraryOptions === void 0) { libraryOptions = {}; }
62
- this.resourcesConfig = mergeResourceConfig(this.resourcesConfig, resourcesConfig);
63
- this.libraryOptions = mergeLibraryOptions(this.libraryOptions, libraryOptions);
64
- this.Auth.configure(this.resourcesConfig.Auth, this.libraryOptions.Auth);
65
- Hub_1.Hub.dispatch('core', {
66
- event: 'configure',
67
- data: resourcesConfig,
68
- }, 'Configure');
69
- };
70
- /**
71
- * Provides access to the current back-end resource configuration for the Library.
72
- *
73
- * @returns Returns the current back-end resource configuration.
74
- */
75
- AmplifyClass.prototype.getConfig = function () {
76
- return JSON.parse(JSON.stringify(this.resourcesConfig));
77
- };
78
- return AmplifyClass;
79
- }());
80
- /**
81
- * The `Amplify` utility is used to configure the library.
82
- *
83
- * @remarks
84
- * `Amplify` is responsible for orchestrating cross-category communication within the library.
85
- */
86
- exports.AmplifyV6 = new AmplifyClass();
87
- /**
88
- * Returns current session tokens and credentials
89
- *
90
- * @param options{FetchAuthSessionOptions} - Options for fetching session.
91
- *
92
- * @returns Returns a promise that will resolve with fresh authentication tokens.
93
- */
94
- var fetchAuthSession = function (options) {
95
- return exports.AmplifyV6.Auth.fetchAuthSession(options);
96
- };
97
- exports.fetchAuthSession = fetchAuthSession;
98
- // TODO(v6): validate until which level this will nested, during Amplify.configure API review.
99
- function mergeResourceConfig(existingConfig, newConfig) {
100
- var e_1, _a, e_2, _b;
101
- var resultConfig = {};
102
- try {
103
- for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
104
- var category = _d.value;
105
- resultConfig[category] = existingConfig[category];
106
- }
107
- }
108
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
109
- finally {
110
- try {
111
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
112
- }
113
- finally { if (e_1) throw e_1.error; }
114
- }
115
- try {
116
- for (var _e = __values(Object.keys(newConfig)), _f = _e.next(); !_f.done; _f = _e.next()) {
117
- var category = _f.value;
118
- resultConfig[category] = __assign(__assign({}, resultConfig[category]), newConfig[category]);
119
- }
120
- }
121
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
122
- finally {
123
- try {
124
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
125
- }
126
- finally { if (e_2) throw e_2.error; }
127
- }
128
- return resultConfig;
129
- }
130
- function mergeLibraryOptions(existingConfig, newConfig) {
131
- var e_3, _a, e_4, _b;
132
- var resultConfig = {};
133
- try {
134
- for (var _c = __values(Object.keys(existingConfig)), _d = _c.next(); !_d.done; _d = _c.next()) {
135
- var category = _d.value;
136
- resultConfig[category] = existingConfig[category];
137
- }
138
- }
139
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
140
- finally {
141
- try {
142
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
143
- }
144
- finally { if (e_3) throw e_3.error; }
145
- }
146
- try {
147
- for (var _e = __values(Object.keys(newConfig)), _f = _e.next(); !_f.done; _f = _e.next()) {
148
- var category = _f.value;
149
- resultConfig[category] = __assign(__assign({}, resultConfig[category]), newConfig[category]);
150
- }
151
- }
152
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
153
- finally {
154
- try {
155
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
156
- }
157
- finally { if (e_4) throw e_4.error; }
158
- }
159
- return resultConfig;
160
- }
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.fetchAuthSession = exports.Amplify = exports.AmplifyClass = void 0;
6
+ var Amplify_1 = require("./Amplify");
7
+ Object.defineProperty(exports, "AmplifyClass", { enumerable: true, get: function () { return Amplify_1.AmplifyClass; } });
8
+ Object.defineProperty(exports, "Amplify", { enumerable: true, get: function () { return Amplify_1.Amplify; } });
9
+ var fetchAuthSession_1 = require("./apis/fetchAuthSession");
10
+ Object.defineProperty(exports, "fetchAuthSession", { enumerable: true, get: function () { return fetchAuthSession_1.fetchAuthSession; } });
@@ -1,10 +1,11 @@
1
+ import { AnalyticsConfig } from './Analytics/types';
1
2
  import { AuthConfig, LibraryAuthOptions, UserPoolConfig, IdentityPoolConfig, UserPoolConfigAndIdentityPoolConfig, GetCredentialsOptions } from './Auth/types';
2
3
  import { LibraryStorageOptions, StorageAccessLevel, StorageConfig } from './Storage/types';
3
4
  import { CacheConfig } from '../Cache/types';
4
5
  import { I18nOptions } from '../I18n/types';
5
6
  export type ResourcesConfig = {
6
7
  API?: {};
7
- Analytics?: {};
8
+ Analytics?: AnalyticsConfig;
8
9
  Auth?: AuthConfig;
9
10
  Cache?: CacheConfig;
10
11
  DataStore?: {};
@@ -13,6 +14,7 @@ export type ResourcesConfig = {
13
14
  Notifications?: {};
14
15
  Predictions?: {};
15
16
  Storage?: StorageConfig;
17
+ ssr?: boolean;
16
18
  };
17
19
  export type LibraryOptions = {
18
20
  Auth?: LibraryAuthOptions;