@webiny/cognito 0.0.0-unstable.0d717d18dd

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 (369) hide show
  1. package/Cognito.d.ts +55 -0
  2. package/Cognito.js +102 -0
  3. package/Cognito.js.map +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +11 -0
  6. package/admin/Cognito.d.ts +8 -0
  7. package/admin/Cognito.js +50 -0
  8. package/admin/Cognito.js.map +1 -0
  9. package/admin/CognitoLogin.d.ts +7 -0
  10. package/admin/CognitoLogin.js +13 -0
  11. package/admin/CognitoLogin.js.map +1 -0
  12. package/admin/DefaultCognitoSignInConfig.d.ts +23 -0
  13. package/admin/DefaultCognitoSignInConfig.js +51 -0
  14. package/admin/DefaultCognitoSignInConfig.js.map +1 -0
  15. package/admin/Extension.d.ts +2 -0
  16. package/admin/Extension.js +45 -0
  17. package/admin/Extension.js.map +1 -0
  18. package/admin/SecurityPermission.d.ts +2 -0
  19. package/admin/SecurityPermission.js +15 -0
  20. package/admin/SecurityPermission.js.map +1 -0
  21. package/admin/SignInExtension.d.ts +2 -0
  22. package/admin/SignInExtension.js +9 -0
  23. package/admin/SignInExtension.js.map +1 -0
  24. package/admin/domain/permissionsSchema.d.ts +10 -0
  25. package/admin/domain/permissionsSchema.js +18 -0
  26. package/admin/domain/permissionsSchema.js.map +1 -0
  27. package/admin/features/account/getCurrentUser/GetCurrentUserGateway.d.ts +11 -0
  28. package/admin/features/account/getCurrentUser/GetCurrentUserGateway.js +44 -0
  29. package/admin/features/account/getCurrentUser/GetCurrentUserGateway.js.map +1 -0
  30. package/admin/features/account/getCurrentUser/GetCurrentUserUseCase.d.ts +10 -0
  31. package/admin/features/account/getCurrentUser/GetCurrentUserUseCase.js +19 -0
  32. package/admin/features/account/getCurrentUser/GetCurrentUserUseCase.js.map +1 -0
  33. package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserGateway.d.ts +16 -0
  34. package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserGateway.js +5 -0
  35. package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserGateway.js.map +1 -0
  36. package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserUseCase.d.ts +10 -0
  37. package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserUseCase.js +5 -0
  38. package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserUseCase.js.map +1 -0
  39. package/admin/features/account/getCurrentUser/abstractions/index.d.ts +6 -0
  40. package/admin/features/account/getCurrentUser/abstractions/index.js +2 -0
  41. package/admin/features/account/getCurrentUser/feature.d.ts +3 -0
  42. package/admin/features/account/getCurrentUser/feature.js +19 -0
  43. package/admin/features/account/getCurrentUser/feature.js.map +1 -0
  44. package/admin/features/account/getCurrentUser/index.d.ts +1 -0
  45. package/admin/features/account/getCurrentUser/index.js +1 -0
  46. package/admin/features/account/updateCurrentUser/UpdateCurrentUserGateway.d.ts +11 -0
  47. package/admin/features/account/updateCurrentUser/UpdateCurrentUserGateway.js +48 -0
  48. package/admin/features/account/updateCurrentUser/UpdateCurrentUserGateway.js.map +1 -0
  49. package/admin/features/account/updateCurrentUser/UpdateCurrentUserUseCase.d.ts +10 -0
  50. package/admin/features/account/updateCurrentUser/UpdateCurrentUserUseCase.js +19 -0
  51. package/admin/features/account/updateCurrentUser/UpdateCurrentUserUseCase.js.map +1 -0
  52. package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserGateway.d.ts +26 -0
  53. package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserGateway.js +5 -0
  54. package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserGateway.js.map +1 -0
  55. package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserUseCase.d.ts +13 -0
  56. package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserUseCase.js +5 -0
  57. package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserUseCase.js.map +1 -0
  58. package/admin/features/account/updateCurrentUser/abstractions/index.d.ts +8 -0
  59. package/admin/features/account/updateCurrentUser/abstractions/index.js +2 -0
  60. package/admin/features/account/updateCurrentUser/feature.d.ts +3 -0
  61. package/admin/features/account/updateCurrentUser/feature.js +19 -0
  62. package/admin/features/account/updateCurrentUser/feature.js.map +1 -0
  63. package/admin/features/account/updateCurrentUser/index.d.ts +1 -0
  64. package/admin/features/account/updateCurrentUser/index.js +1 -0
  65. package/admin/features/permissions/abstractions.d.ts +17 -0
  66. package/admin/features/permissions/abstractions.js +6 -0
  67. package/admin/features/permissions/abstractions.js.map +1 -0
  68. package/admin/features/permissions/feature.d.ts +14 -0
  69. package/admin/features/permissions/feature.js +7 -0
  70. package/admin/features/permissions/feature.js.map +1 -0
  71. package/admin/features/users/createUser/CreateUserGateway.d.ts +11 -0
  72. package/admin/features/users/createUser/CreateUserGateway.js +49 -0
  73. package/admin/features/users/createUser/CreateUserGateway.js.map +1 -0
  74. package/admin/features/users/createUser/CreateUserUseCase.d.ts +10 -0
  75. package/admin/features/users/createUser/CreateUserUseCase.js +18 -0
  76. package/admin/features/users/createUser/CreateUserUseCase.js.map +1 -0
  77. package/admin/features/users/createUser/abstractions/CreateUserGateway.d.ts +21 -0
  78. package/admin/features/users/createUser/abstractions/CreateUserGateway.js +5 -0
  79. package/admin/features/users/createUser/abstractions/CreateUserGateway.js.map +1 -0
  80. package/admin/features/users/createUser/abstractions/CreateUserUseCase.d.ts +14 -0
  81. package/admin/features/users/createUser/abstractions/CreateUserUseCase.js +5 -0
  82. package/admin/features/users/createUser/abstractions/CreateUserUseCase.js.map +1 -0
  83. package/admin/features/users/createUser/abstractions/index.d.ts +2 -0
  84. package/admin/features/users/createUser/abstractions/index.js +2 -0
  85. package/admin/features/users/createUser/feature.d.ts +3 -0
  86. package/admin/features/users/createUser/feature.js +19 -0
  87. package/admin/features/users/createUser/feature.js.map +1 -0
  88. package/admin/features/users/createUser/index.d.ts +2 -0
  89. package/admin/features/users/createUser/index.js +2 -0
  90. package/admin/features/users/deleteUser/DeleteUserGateway.d.ts +11 -0
  91. package/admin/features/users/deleteUser/DeleteUserGateway.js +40 -0
  92. package/admin/features/users/deleteUser/DeleteUserGateway.js.map +1 -0
  93. package/admin/features/users/deleteUser/DeleteUserUseCase.d.ts +10 -0
  94. package/admin/features/users/deleteUser/DeleteUserUseCase.js +18 -0
  95. package/admin/features/users/deleteUser/DeleteUserUseCase.js.map +1 -0
  96. package/admin/features/users/deleteUser/abstractions/DeleteUserGateway.d.ts +11 -0
  97. package/admin/features/users/deleteUser/abstractions/DeleteUserGateway.js +5 -0
  98. package/admin/features/users/deleteUser/abstractions/DeleteUserGateway.js.map +1 -0
  99. package/admin/features/users/deleteUser/abstractions/DeleteUserUseCase.d.ts +11 -0
  100. package/admin/features/users/deleteUser/abstractions/DeleteUserUseCase.js +5 -0
  101. package/admin/features/users/deleteUser/abstractions/DeleteUserUseCase.js.map +1 -0
  102. package/admin/features/users/deleteUser/abstractions/index.d.ts +2 -0
  103. package/admin/features/users/deleteUser/abstractions/index.js +2 -0
  104. package/admin/features/users/deleteUser/feature.d.ts +3 -0
  105. package/admin/features/users/deleteUser/feature.js +19 -0
  106. package/admin/features/users/deleteUser/feature.js.map +1 -0
  107. package/admin/features/users/deleteUser/index.d.ts +2 -0
  108. package/admin/features/users/deleteUser/index.js +2 -0
  109. package/admin/features/users/getUser/GetUserGateway.d.ts +11 -0
  110. package/admin/features/users/getUser/GetUserGateway.js +57 -0
  111. package/admin/features/users/getUser/GetUserGateway.js.map +1 -0
  112. package/admin/features/users/getUser/GetUserUseCase.d.ts +10 -0
  113. package/admin/features/users/getUser/GetUserUseCase.js +18 -0
  114. package/admin/features/users/getUser/GetUserUseCase.js.map +1 -0
  115. package/admin/features/users/getUser/abstractions/GetUserGateway.d.ts +32 -0
  116. package/admin/features/users/getUser/abstractions/GetUserGateway.js +5 -0
  117. package/admin/features/users/getUser/abstractions/GetUserGateway.js.map +1 -0
  118. package/admin/features/users/getUser/abstractions/GetUserUseCase.d.ts +14 -0
  119. package/admin/features/users/getUser/abstractions/GetUserUseCase.js +5 -0
  120. package/admin/features/users/getUser/abstractions/GetUserUseCase.js.map +1 -0
  121. package/admin/features/users/getUser/abstractions/index.d.ts +2 -0
  122. package/admin/features/users/getUser/abstractions/index.js +2 -0
  123. package/admin/features/users/getUser/feature.d.ts +3 -0
  124. package/admin/features/users/getUser/feature.js +19 -0
  125. package/admin/features/users/getUser/feature.js.map +1 -0
  126. package/admin/features/users/getUser/index.d.ts +2 -0
  127. package/admin/features/users/getUser/index.js +2 -0
  128. package/admin/features/users/listUsers/ListUsersGateway.d.ts +11 -0
  129. package/admin/features/users/listUsers/ListUsersGateway.js +39 -0
  130. package/admin/features/users/listUsers/ListUsersGateway.js.map +1 -0
  131. package/admin/features/users/listUsers/ListUsersUseCase.d.ts +10 -0
  132. package/admin/features/users/listUsers/ListUsersUseCase.js +18 -0
  133. package/admin/features/users/listUsers/ListUsersUseCase.js.map +1 -0
  134. package/admin/features/users/listUsers/abstractions/ListUsersGateway.d.ts +17 -0
  135. package/admin/features/users/listUsers/abstractions/ListUsersGateway.js +5 -0
  136. package/admin/features/users/listUsers/abstractions/ListUsersGateway.js.map +1 -0
  137. package/admin/features/users/listUsers/abstractions/ListUsersUseCase.d.ts +10 -0
  138. package/admin/features/users/listUsers/abstractions/ListUsersUseCase.js +5 -0
  139. package/admin/features/users/listUsers/abstractions/ListUsersUseCase.js.map +1 -0
  140. package/admin/features/users/listUsers/abstractions/index.d.ts +2 -0
  141. package/admin/features/users/listUsers/abstractions/index.js +2 -0
  142. package/admin/features/users/listUsers/feature.d.ts +3 -0
  143. package/admin/features/users/listUsers/feature.js +19 -0
  144. package/admin/features/users/listUsers/feature.js.map +1 -0
  145. package/admin/features/users/listUsers/index.d.ts +2 -0
  146. package/admin/features/users/listUsers/index.js +2 -0
  147. package/admin/features/users/updateUser/UpdateUserGateway.d.ts +11 -0
  148. package/admin/features/users/updateUser/UpdateUserGateway.js +59 -0
  149. package/admin/features/users/updateUser/UpdateUserGateway.js.map +1 -0
  150. package/admin/features/users/updateUser/UpdateUserUseCase.d.ts +10 -0
  151. package/admin/features/users/updateUser/UpdateUserUseCase.js +18 -0
  152. package/admin/features/users/updateUser/UpdateUserUseCase.js.map +1 -0
  153. package/admin/features/users/updateUser/abstractions/UpdateUserGateway.d.ts +33 -0
  154. package/admin/features/users/updateUser/abstractions/UpdateUserGateway.js +5 -0
  155. package/admin/features/users/updateUser/abstractions/UpdateUserGateway.js.map +1 -0
  156. package/admin/features/users/updateUser/abstractions/UpdateUserUseCase.d.ts +15 -0
  157. package/admin/features/users/updateUser/abstractions/UpdateUserUseCase.js +5 -0
  158. package/admin/features/users/updateUser/abstractions/UpdateUserUseCase.js.map +1 -0
  159. package/admin/features/users/updateUser/abstractions/index.d.ts +2 -0
  160. package/admin/features/users/updateUser/abstractions/index.js +2 -0
  161. package/admin/features/users/updateUser/feature.d.ts +3 -0
  162. package/admin/features/users/updateUser/feature.js +19 -0
  163. package/admin/features/users/updateUser/feature.js.map +1 -0
  164. package/admin/features/users/updateUser/index.d.ts +2 -0
  165. package/admin/features/users/updateUser/index.js +2 -0
  166. package/admin/federatedIdentityProviders.d.ts +9 -0
  167. package/admin/federatedIdentityProviders.js +10 -0
  168. package/admin/federatedIdentityProviders.js.map +1 -0
  169. package/admin/index.d.ts +2 -0
  170. package/admin/index.js +2 -0
  171. package/admin/presentation/Cognito/CognitoLoginScreen.d.ts +10 -0
  172. package/admin/presentation/Cognito/CognitoLoginScreen.js +60 -0
  173. package/admin/presentation/Cognito/CognitoLoginScreen.js.map +1 -0
  174. package/admin/presentation/Cognito/CognitoPresenter.d.ts +81 -0
  175. package/admin/presentation/Cognito/CognitoPresenter.js +386 -0
  176. package/admin/presentation/Cognito/CognitoPresenter.js.map +1 -0
  177. package/admin/presentation/Cognito/CognitoSignInConfig.d.ts +31 -0
  178. package/admin/presentation/Cognito/CognitoSignInConfig.js +5 -0
  179. package/admin/presentation/Cognito/CognitoSignInConfig.js.map +1 -0
  180. package/admin/presentation/Cognito/abstractions.d.ts +91 -0
  181. package/admin/presentation/Cognito/abstractions.js +5 -0
  182. package/admin/presentation/Cognito/abstractions.js.map +1 -0
  183. package/admin/presentation/Cognito/components/ConfirmTotpCode.d.ts +26 -0
  184. package/admin/presentation/Cognito/components/ConfirmTotpCode.js +45 -0
  185. package/admin/presentation/Cognito/components/ConfirmTotpCode.js.map +1 -0
  186. package/admin/presentation/Cognito/components/Divider.d.ts +20 -0
  187. package/admin/presentation/Cognito/components/Divider.js +16 -0
  188. package/admin/presentation/Cognito/components/Divider.js.map +1 -0
  189. package/admin/presentation/Cognito/components/FederatedLogin.d.ts +24 -0
  190. package/admin/presentation/Cognito/components/FederatedLogin.js +43 -0
  191. package/admin/presentation/Cognito/components/FederatedLogin.js.map +1 -0
  192. package/admin/presentation/Cognito/components/FederatedProviders.d.ts +44 -0
  193. package/admin/presentation/Cognito/components/FederatedProviders.js +11 -0
  194. package/admin/presentation/Cognito/components/FederatedProviders.js.map +1 -0
  195. package/admin/presentation/Cognito/components/FooterSignIn.d.ts +23 -0
  196. package/admin/presentation/Cognito/components/FooterSignIn.js +13 -0
  197. package/admin/presentation/Cognito/components/FooterSignIn.js.map +1 -0
  198. package/admin/presentation/Cognito/components/PasswordResetCodeSent.d.ts +27 -0
  199. package/admin/presentation/Cognito/components/PasswordResetCodeSent.js +40 -0
  200. package/admin/presentation/Cognito/components/PasswordResetCodeSent.js.map +1 -0
  201. package/admin/presentation/Cognito/components/RequestPasswordResetCode.d.ts +26 -0
  202. package/admin/presentation/Cognito/components/RequestPasswordResetCode.js +42 -0
  203. package/admin/presentation/Cognito/components/RequestPasswordResetCode.js.map +1 -0
  204. package/admin/presentation/Cognito/components/RequireNewPassword.d.ts +26 -0
  205. package/admin/presentation/Cognito/components/RequireNewPassword.js +52 -0
  206. package/admin/presentation/Cognito/components/RequireNewPassword.js.map +1 -0
  207. package/admin/presentation/Cognito/components/SetNewPassword.d.ts +26 -0
  208. package/admin/presentation/Cognito/components/SetNewPassword.js +79 -0
  209. package/admin/presentation/Cognito/components/SetNewPassword.js.map +1 -0
  210. package/admin/presentation/Cognito/components/SetupTotp.d.ts +25 -0
  211. package/admin/presentation/Cognito/components/SetupTotp.js +60 -0
  212. package/admin/presentation/Cognito/components/SetupTotp.js.map +1 -0
  213. package/admin/presentation/Cognito/components/SignIn.d.ts +26 -0
  214. package/admin/presentation/Cognito/components/SignIn.js +64 -0
  215. package/admin/presentation/Cognito/components/SignIn.js.map +1 -0
  216. package/admin/presentation/Cognito/components/View.d.ts +98 -0
  217. package/admin/presentation/Cognito/components/View.js +48 -0
  218. package/admin/presentation/Cognito/components/View.js.map +1 -0
  219. package/admin/presentation/Cognito/components/index.d.ts +292 -0
  220. package/admin/presentation/Cognito/components/index.js +29 -0
  221. package/admin/presentation/Cognito/components/index.js.map +1 -0
  222. package/admin/presentation/Cognito/feature.d.ts +3 -0
  223. package/admin/presentation/Cognito/feature.js +17 -0
  224. package/admin/presentation/Cognito/feature.js.map +1 -0
  225. package/admin/presentation/Cognito/signInFeature.d.ts +1 -0
  226. package/admin/presentation/Cognito/signInFeature.js +11 -0
  227. package/admin/presentation/Cognito/signInFeature.js.map +1 -0
  228. package/admin/presentation/shared/createPasswordValidator.d.ts +8 -0
  229. package/admin/presentation/shared/createPasswordValidator.js +16 -0
  230. package/admin/presentation/shared/createPasswordValidator.js.map +1 -0
  231. package/admin/presentation/shared/usePasswordValidator.d.ts +1 -0
  232. package/admin/presentation/shared/usePasswordValidator.js +16 -0
  233. package/admin/presentation/shared/usePasswordValidator.js.map +1 -0
  234. package/admin/presentation/userMenu/AccountDetails.d.ts +6 -0
  235. package/admin/presentation/userMenu/AccountDetails.js +20 -0
  236. package/admin/presentation/userMenu/AccountDetails.js.map +1 -0
  237. package/admin/presentation/userMenu/useIsDefaultTenant.d.ts +1 -0
  238. package/admin/presentation/userMenu/useIsDefaultTenant.js +9 -0
  239. package/admin/presentation/userMenu/useIsDefaultTenant.js.map +1 -0
  240. package/admin/routes.d.ts +10 -0
  241. package/admin/routes.js +20 -0
  242. package/admin/routes.js.map +1 -0
  243. package/admin/ui/UserItem.d.ts +10 -0
  244. package/admin/ui/UserItem.js +0 -0
  245. package/admin/ui/components/AvatarImage/AvatarImage.d.ts +3 -0
  246. package/admin/ui/components/AvatarImage/AvatarImage.js +31 -0
  247. package/admin/ui/components/AvatarImage/AvatarImage.js.map +1 -0
  248. package/admin/ui/components/AvatarImage/AvatarImagePreview.d.ts +10 -0
  249. package/admin/ui/components/AvatarImage/AvatarImagePreview.js +53 -0
  250. package/admin/ui/components/AvatarImage/AvatarImagePreview.js.map +1 -0
  251. package/admin/ui/components/AvatarImage/AvatarImageTrigger.d.ts +7 -0
  252. package/admin/ui/components/AvatarImage/AvatarImageTrigger.js +28 -0
  253. package/admin/ui/components/AvatarImage/AvatarImageTrigger.js.map +1 -0
  254. package/admin/ui/components/AvatarImage/index.d.ts +1 -0
  255. package/admin/ui/components/AvatarImage/index.js +1 -0
  256. package/admin/ui/views/Account/Account.d.ts +2 -0
  257. package/admin/ui/views/Account/Account.js +137 -0
  258. package/admin/ui/views/Account/Account.js.map +1 -0
  259. package/admin/ui/views/Account/index.d.ts +1 -0
  260. package/admin/ui/views/Account/index.js +1 -0
  261. package/admin/ui/views/Users/UsersDataList.d.ts +3 -0
  262. package/admin/ui/views/Users/UsersDataList.js +177 -0
  263. package/admin/ui/views/Users/UsersDataList.js.map +1 -0
  264. package/admin/ui/views/Users/UsersForm.d.ts +5 -0
  265. package/admin/ui/views/Users/UsersForm.js +169 -0
  266. package/admin/ui/views/Users/UsersForm.js.map +1 -0
  267. package/admin/ui/views/Users/UsersView.d.ts +2 -0
  268. package/admin/ui/views/Users/UsersView.js +14 -0
  269. package/admin/ui/views/Users/UsersView.js.map +1 -0
  270. package/admin/ui/views/Users/components/DeleteAction.d.ts +7 -0
  271. package/admin/ui/views/Users/components/DeleteAction.js +29 -0
  272. package/admin/ui/views/Users/components/DeleteAction.js.map +1 -0
  273. package/admin/ui/views/Users/hooks/useUserForm.d.ts +27 -0
  274. package/admin/ui/views/Users/hooks/useUserForm.js +101 -0
  275. package/admin/ui/views/Users/hooks/useUserForm.js.map +1 -0
  276. package/admin/ui/views/Users/search.js +21 -0
  277. package/admin/ui/views/Users/search.js.map +1 -0
  278. package/admin/ui/views/Users/search.svg +20 -0
  279. package/admin/ui/views/utils.d.ts +3 -0
  280. package/admin/ui/views/utils.js +12 -0
  281. package/admin/ui/views/utils.js.map +1 -0
  282. package/api/CognitoApiFeature.d.ts +4 -0
  283. package/api/CognitoApiFeature.js +26 -0
  284. package/api/CognitoApiFeature.js.map +1 -0
  285. package/api/domain/Username.d.ts +4 -0
  286. package/api/domain/Username.js +8 -0
  287. package/api/domain/Username.js.map +1 -0
  288. package/api/domain/errors.d.ts +37 -0
  289. package/api/domain/errors.js +44 -0
  290. package/api/domain/errors.js.map +1 -0
  291. package/api/features/CognitoIdp/CognitoIdentityProvider.d.ts +15 -0
  292. package/api/features/CognitoIdp/CognitoIdentityProvider.js +63 -0
  293. package/api/features/CognitoIdp/CognitoIdentityProvider.js.map +1 -0
  294. package/api/features/CognitoIdp/abstractions.d.ts +15 -0
  295. package/api/features/CognitoIdp/abstractions.js +5 -0
  296. package/api/features/CognitoIdp/abstractions.js.map +1 -0
  297. package/api/features/CognitoIdp/feature.d.ts +4 -0
  298. package/api/features/CognitoIdp/feature.js +11 -0
  299. package/api/features/CognitoIdp/feature.js.map +1 -0
  300. package/api/features/CognitoIdp/index.d.ts +2 -0
  301. package/api/features/CognitoIdp/index.js +2 -0
  302. package/api/features/CognitoService/CognitoService.d.ts +20 -0
  303. package/api/features/CognitoService/CognitoService.js +100 -0
  304. package/api/features/CognitoService/CognitoService.js.map +1 -0
  305. package/api/features/CognitoService/abstractions.d.ts +54 -0
  306. package/api/features/CognitoService/abstractions.js +6 -0
  307. package/api/features/CognitoService/abstractions.js.map +1 -0
  308. package/api/features/CognitoService/feature.d.ts +8 -0
  309. package/api/features/CognitoService/feature.js +13 -0
  310. package/api/features/CognitoService/feature.js.map +1 -0
  311. package/api/features/CognitoService/index.d.ts +1 -0
  312. package/api/features/CognitoService/index.js +1 -0
  313. package/api/features/CreateUser/CreateUserUseCase.d.ts +22 -0
  314. package/api/features/CreateUser/CreateUserUseCase.js +80 -0
  315. package/api/features/CreateUser/CreateUserUseCase.js.map +1 -0
  316. package/api/features/CreateUser/abstractions.d.ts +35 -0
  317. package/api/features/CreateUser/abstractions.js +5 -0
  318. package/api/features/CreateUser/abstractions.js.map +1 -0
  319. package/api/features/CreateUser/feature.d.ts +4 -0
  320. package/api/features/CreateUser/feature.js +11 -0
  321. package/api/features/CreateUser/feature.js.map +1 -0
  322. package/api/features/CreateUser/index.d.ts +2 -0
  323. package/api/features/CreateUser/index.js +2 -0
  324. package/api/features/CreateUser/schema.d.ts +15 -0
  325. package/api/features/CreateUser/schema.js +18 -0
  326. package/api/features/CreateUser/schema.js.map +1 -0
  327. package/api/features/DeleteUser/DeleteUserUseCase.d.ts +16 -0
  328. package/api/features/DeleteUser/DeleteUserUseCase.js +47 -0
  329. package/api/features/DeleteUser/DeleteUserUseCase.js.map +1 -0
  330. package/api/features/DeleteUser/abstractions.d.ts +19 -0
  331. package/api/features/DeleteUser/abstractions.js +5 -0
  332. package/api/features/DeleteUser/abstractions.js.map +1 -0
  333. package/api/features/DeleteUser/feature.d.ts +4 -0
  334. package/api/features/DeleteUser/feature.js +11 -0
  335. package/api/features/DeleteUser/feature.js.map +1 -0
  336. package/api/features/DeleteUser/index.d.ts +2 -0
  337. package/api/features/DeleteUser/index.js +2 -0
  338. package/api/features/UpdateUser/UpdateUserUseCase.d.ts +21 -0
  339. package/api/features/UpdateUser/UpdateUserUseCase.js +66 -0
  340. package/api/features/UpdateUser/UpdateUserUseCase.js.map +1 -0
  341. package/api/features/UpdateUser/abstractions.d.ts +33 -0
  342. package/api/features/UpdateUser/abstractions.js +5 -0
  343. package/api/features/UpdateUser/abstractions.js.map +1 -0
  344. package/api/features/UpdateUser/feature.d.ts +4 -0
  345. package/api/features/UpdateUser/feature.js +11 -0
  346. package/api/features/UpdateUser/feature.js.map +1 -0
  347. package/api/features/UpdateUser/index.d.ts +2 -0
  348. package/api/features/UpdateUser/index.js +2 -0
  349. package/api/features/UpdateUser/schema.d.ts +14 -0
  350. package/api/features/UpdateUser/schema.js +17 -0
  351. package/api/features/UpdateUser/schema.js.map +1 -0
  352. package/api/features/UserInstaller/UserInstaller.d.ts +27 -0
  353. package/api/features/UserInstaller/UserInstaller.js +48 -0
  354. package/api/features/UserInstaller/UserInstaller.js.map +1 -0
  355. package/api/features/UserInstaller/feature.d.ts +4 -0
  356. package/api/features/UserInstaller/feature.js +11 -0
  357. package/api/features/UserInstaller/feature.js.map +1 -0
  358. package/api/graphql/user.gql.d.ts +8 -0
  359. package/api/graphql/user.gql.js +143 -0
  360. package/api/graphql/user.gql.js.map +1 -0
  361. package/api/index.d.ts +1 -0
  362. package/api/index.js +1 -0
  363. package/index.d.ts +1 -0
  364. package/index.js +1 -0
  365. package/infra/CognitoFederationPulumi.d.ts +8 -0
  366. package/infra/CognitoFederationPulumi.js +17 -0
  367. package/infra/CognitoFederationPulumi.js.map +1 -0
  368. package/package.json +51 -0
  369. package/static/svg/search.43fa797c.svg +20 -0
@@ -0,0 +1,386 @@
1
+ import { makeAutoObservable, runInAction } from "mobx";
2
+ import { Amplify } from "aws-amplify";
3
+ import { confirmResetPassword, confirmSignIn, fetchAuthSession, resetPassword, signIn, signOut } from "aws-amplify/auth";
4
+ import { CognitoPresenter } from "./abstractions.js";
5
+ import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn/index.js";
6
+ import { IdentityContext } from "@webiny/app-admin/features/security/IdentityContext/index.js";
7
+ import { CognitoSignInConfig } from "./CognitoSignInConfig.js";
8
+ const federatedDescription = "You will be taken to an external service to complete the sign-in process.";
9
+ class CognitoPresenterImpl {
10
+ constructor(identity, logInUseCase, signInConfig){
11
+ this.identity = identity;
12
+ this.logInUseCase = logInUseCase;
13
+ this.signInConfig = signInConfig;
14
+ this.authState = "signIn";
15
+ this.authData = null;
16
+ this.message = null;
17
+ this.checkingSession = false;
18
+ this.isLoggingIn = false;
19
+ this.formLoading = false;
20
+ this.initialized = false;
21
+ this.signInTitle = "Sign in";
22
+ this.signInDescription = void 0;
23
+ this.allowCredentialsLogin = true;
24
+ this.federatedProviders = [];
25
+ this.totpSharedSecret = "";
26
+ this.totpQrCodeUri = "";
27
+ makeAutoObservable(this);
28
+ }
29
+ get vm() {
30
+ const identity = this.identity.getIdentity();
31
+ return {
32
+ authState: this.authState,
33
+ checkingSession: this.checkingSession,
34
+ isLoggingIn: this.isLoggingIn,
35
+ isAuthenticated: identity.isAuthenticated,
36
+ signIn: {
37
+ isLoading: this.formLoading,
38
+ message: this.message,
39
+ title: this.signInTitle,
40
+ description: this.signInDescription,
41
+ allowCredentialsLogin: this.allowCredentialsLogin,
42
+ federatedProviders: this.federatedProviders
43
+ },
44
+ requestPasswordResetCode: {
45
+ isLoading: this.formLoading,
46
+ message: this.message
47
+ },
48
+ passwordResetCodeSent: {
49
+ isLoading: this.formLoading,
50
+ message: this.message
51
+ },
52
+ setNewPassword: {
53
+ isLoading: this.formLoading,
54
+ message: this.message
55
+ },
56
+ requireNewPassword: {
57
+ isLoading: this.formLoading,
58
+ requiredAttributes: this.authData && this.authData.requiredAttributes || []
59
+ },
60
+ confirmTotpCode: {
61
+ isLoading: this.formLoading,
62
+ message: this.message
63
+ },
64
+ setupTotp: {
65
+ isLoading: this.formLoading,
66
+ sharedSecret: this.totpSharedSecret,
67
+ qrCodeUri: this.totpQrCodeUri,
68
+ message: this.message
69
+ }
70
+ };
71
+ }
72
+ async init(params) {
73
+ if (this.initialized) return;
74
+ let oauthConfig;
75
+ if (this.signInConfig) {
76
+ const config = await this.signInConfig.getConfig();
77
+ runInAction(()=>{
78
+ this.signInTitle = config.title ?? "Sign in";
79
+ this.signInDescription = config.description;
80
+ if (!config.description && !config.allowCredentialsLogin) this.signInDescription = federatedDescription;
81
+ this.allowCredentialsLogin = config.allowCredentialsLogin;
82
+ this.federatedProviders = config.providers;
83
+ });
84
+ const domain = process.env.REACT_APP_USER_POOL_DOMAIN;
85
+ if (domain) oauthConfig = {
86
+ Cognito: {
87
+ userPoolId: params.userPoolId,
88
+ userPoolClientId: params.clientId,
89
+ loginWith: {
90
+ oauth: {
91
+ domain,
92
+ redirectSignIn: config.oauth.redirectSignIn,
93
+ redirectSignOut: config.oauth.redirectSignOut,
94
+ scopes: config.oauth.scopes,
95
+ responseType: config.oauth.responseType
96
+ }
97
+ }
98
+ }
99
+ };
100
+ }
101
+ Amplify.configure({
102
+ Auth: oauthConfig ?? {
103
+ Cognito: {
104
+ userPoolId: params.userPoolId,
105
+ userPoolClientId: params.clientId
106
+ }
107
+ }
108
+ });
109
+ this.initialized = true;
110
+ await this.checkUrl();
111
+ }
112
+ async signIn(username, password) {
113
+ runInAction(()=>{
114
+ this.formLoading = true;
115
+ this.message = null;
116
+ });
117
+ const usernameOrPassword = [
118
+ "UserNotFoundException",
119
+ "NotAuthorizedException"
120
+ ];
121
+ try {
122
+ const result = await signIn({
123
+ username,
124
+ password
125
+ });
126
+ const { nextStep } = result;
127
+ if ("CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED" === nextStep.signInStep) runInAction(()=>{
128
+ this.authState = "requireNewPassword";
129
+ this.authData = {
130
+ requiredAttributes: nextStep.missingAttributes || []
131
+ };
132
+ this.formLoading = false;
133
+ });
134
+ else if ("CONFIRM_SIGN_IN_WITH_TOTP_CODE" === nextStep.signInStep) runInAction(()=>{
135
+ this.authState = "confirmTotpCode";
136
+ this.formLoading = false;
137
+ });
138
+ else if ("CONTINUE_SIGN_IN_WITH_TOTP_SETUP" === nextStep.signInStep) {
139
+ const totpSetup = nextStep.totpSetupDetails;
140
+ const uri = totpSetup.getSetupUri("Webiny").toString();
141
+ runInAction(()=>{
142
+ this.totpSharedSecret = totpSetup.sharedSecret;
143
+ this.totpQrCodeUri = uri;
144
+ this.authState = "setupTotp";
145
+ this.formLoading = false;
146
+ });
147
+ } else {
148
+ await this.handleSignedIn();
149
+ runInAction(()=>{
150
+ this.formLoading = false;
151
+ });
152
+ }
153
+ } catch (error) {
154
+ let message = error.message;
155
+ if (usernameOrPassword.includes(error.name)) message = "Incorrect username or password.";
156
+ runInAction(()=>{
157
+ this.message = {
158
+ title: "Login Failed",
159
+ text: message,
160
+ type: "danger"
161
+ };
162
+ this.formLoading = false;
163
+ });
164
+ }
165
+ }
166
+ async confirmNewPassword(password, requiredAttributes) {
167
+ runInAction(()=>{
168
+ this.formLoading = true;
169
+ this.message = null;
170
+ });
171
+ try {
172
+ await confirmSignIn({
173
+ challengeResponse: password,
174
+ options: {
175
+ userAttributes: requiredAttributes
176
+ }
177
+ });
178
+ await this.handleSignedIn();
179
+ } catch (error) {
180
+ runInAction(()=>{
181
+ this.message = {
182
+ title: "Error",
183
+ text: error.message,
184
+ type: "danger"
185
+ };
186
+ });
187
+ } finally{
188
+ runInAction(()=>{
189
+ this.formLoading = false;
190
+ });
191
+ }
192
+ }
193
+ async requestPasswordReset(username) {
194
+ runInAction(()=>{
195
+ this.formLoading = true;
196
+ this.message = null;
197
+ });
198
+ try {
199
+ await resetPassword({
200
+ username
201
+ });
202
+ } catch {} finally{
203
+ runInAction(()=>{
204
+ this.authState = "passwordResetCodeSent";
205
+ this.authData = {
206
+ username
207
+ };
208
+ this.formLoading = false;
209
+ });
210
+ }
211
+ }
212
+ async resendPasswordResetCode() {
213
+ const username = this.authData?.username;
214
+ if ("passwordResetCodeSent" !== this.authState || !username) return;
215
+ await this.requestPasswordReset(username);
216
+ runInAction(()=>{
217
+ this.message = {
218
+ title: "Code Resent",
219
+ text: "Password reset code has been resent to your email address. Please check your inbox!",
220
+ type: "success"
221
+ };
222
+ });
223
+ }
224
+ async confirmPasswordReset(code, password) {
225
+ const username = this.authData?.username;
226
+ if (!username) return;
227
+ runInAction(()=>{
228
+ this.formLoading = true;
229
+ this.message = null;
230
+ });
231
+ try {
232
+ await confirmResetPassword({
233
+ username,
234
+ confirmationCode: code,
235
+ newPassword: password
236
+ });
237
+ runInAction(()=>{
238
+ this.authState = "signIn";
239
+ this.message = {
240
+ title: "Password Reset",
241
+ text: "You can now sign in with your new password",
242
+ type: "success"
243
+ };
244
+ });
245
+ } catch (error) {
246
+ runInAction(()=>{
247
+ this.message = {
248
+ title: "Error",
249
+ text: error.message,
250
+ type: "danger"
251
+ };
252
+ });
253
+ } finally{
254
+ runInAction(()=>{
255
+ this.formLoading = false;
256
+ });
257
+ }
258
+ }
259
+ async confirmTotpCode(code) {
260
+ runInAction(()=>{
261
+ this.formLoading = true;
262
+ this.message = null;
263
+ });
264
+ try {
265
+ await confirmSignIn({
266
+ challengeResponse: code
267
+ });
268
+ await this.handleSignedIn();
269
+ } catch (error) {
270
+ runInAction(()=>{
271
+ this.message = {
272
+ title: "Verification Failed",
273
+ text: error.message,
274
+ type: "danger"
275
+ };
276
+ });
277
+ } finally{
278
+ runInAction(()=>{
279
+ this.formLoading = false;
280
+ });
281
+ }
282
+ }
283
+ async verifyTotpSetup(code) {
284
+ runInAction(()=>{
285
+ this.formLoading = true;
286
+ this.message = null;
287
+ });
288
+ try {
289
+ await confirmSignIn({
290
+ challengeResponse: code
291
+ });
292
+ await this.handleSignedIn();
293
+ } catch (error) {
294
+ runInAction(()=>{
295
+ this.message = {
296
+ title: "Setup Failed",
297
+ text: error.message,
298
+ type: "danger"
299
+ };
300
+ });
301
+ } finally{
302
+ runInAction(()=>{
303
+ this.formLoading = false;
304
+ });
305
+ }
306
+ }
307
+ showSignIn() {
308
+ this.authState = "signIn";
309
+ this.authData = null;
310
+ this.message = null;
311
+ }
312
+ showRequestPasswordResetCode() {
313
+ this.authState = "requestPasswordResetCode";
314
+ this.message = null;
315
+ }
316
+ showSetNewPassword() {
317
+ this.authState = "setNewPassword";
318
+ this.message = null;
319
+ }
320
+ async handleSignedIn() {
321
+ runInAction(()=>{
322
+ this.isLoggingIn = true;
323
+ });
324
+ try {
325
+ await this.logInUseCase.execute({
326
+ idTokenProvider: async ()=>{
327
+ const session = await fetchAuthSession();
328
+ const idToken = session.tokens?.idToken;
329
+ if (!idToken) throw new Error("No ID token available.");
330
+ return idToken.toString();
331
+ },
332
+ logoutCallback: ()=>{
333
+ signOut();
334
+ runInAction(()=>{
335
+ this.authState = "signIn";
336
+ this.authData = null;
337
+ });
338
+ }
339
+ });
340
+ runInAction(()=>{
341
+ this.authState = "signedIn";
342
+ });
343
+ } catch (error) {
344
+ console.error("Error during sign in:", error);
345
+ runInAction(()=>{
346
+ this.authState = "signIn";
347
+ });
348
+ } finally{
349
+ runInAction(()=>{
350
+ this.isLoggingIn = false;
351
+ });
352
+ }
353
+ }
354
+ async checkUrl() {
355
+ return this.checkSession();
356
+ }
357
+ async checkSession() {
358
+ runInAction(()=>{
359
+ this.checkingSession = true;
360
+ });
361
+ try {
362
+ const session = await fetchAuthSession();
363
+ if (session.tokens) this.handleSignedIn();
364
+ } catch {} finally{
365
+ runInAction(()=>{
366
+ this.checkingSession = false;
367
+ });
368
+ }
369
+ }
370
+ }
371
+ const CognitoPresenter_CognitoPresenter = CognitoPresenter.createImplementation({
372
+ implementation: CognitoPresenterImpl,
373
+ dependencies: [
374
+ IdentityContext,
375
+ LogInUseCase,
376
+ [
377
+ CognitoSignInConfig,
378
+ {
379
+ optional: true
380
+ }
381
+ ]
382
+ ]
383
+ });
384
+ export { CognitoPresenter_CognitoPresenter as CognitoPresenter };
385
+
386
+ //# sourceMappingURL=CognitoPresenter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/presentation/Cognito/CognitoPresenter.js","sources":["../../../../src/admin/presentation/Cognito/CognitoPresenter.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport { Amplify } from \"aws-amplify\";\nimport {\n signIn,\n signOut,\n confirmSignIn,\n resetPassword,\n confirmResetPassword,\n fetchAuthSession\n} from \"aws-amplify/auth\";\nimport {\n CognitoPresenter as CognitoPresenterAbstraction,\n AuthState,\n AuthData,\n AuthMessage,\n ICognitoInitParams\n} from \"./abstractions.js\";\nimport { LogInUseCase } from \"@webiny/app-admin/features/security/LogIn/index.js\";\nimport { IdentityContext } from \"@webiny/app-admin/features/security/IdentityContext/index.js\";\nimport { CognitoSignInConfig } from \"./CognitoSignInConfig.js\";\n\nconst federatedDescription =\n \"You will be taken to an external service to complete the sign-in process.\";\n\nclass CognitoPresenterImpl implements CognitoPresenterAbstraction.Interface {\n private authState: AuthState = \"signIn\";\n private authData: AuthData | null = null;\n private message: AuthMessage | null = null;\n private checkingSession = false;\n private isLoggingIn = false;\n private formLoading = false;\n private initialized = false;\n\n private signInTitle = \"Sign in\";\n private signInDescription: string | undefined = undefined;\n private allowCredentialsLogin = true;\n private federatedProviders: CognitoSignInConfig.FederatedProvider[] = [];\n\n private totpSharedSecret = \"\";\n private totpQrCodeUri = \"\";\n\n constructor(\n private identity: IdentityContext.Interface,\n private logInUseCase: LogInUseCase.Interface,\n private signInConfig: CognitoSignInConfig.Interface | undefined\n ) {\n makeAutoObservable(this);\n }\n\n get vm() {\n const identity = this.identity.getIdentity();\n\n return {\n authState: this.authState,\n checkingSession: this.checkingSession,\n isLoggingIn: this.isLoggingIn,\n isAuthenticated: identity.isAuthenticated,\n\n // View-specific VMs\n signIn: {\n isLoading: this.formLoading,\n message: this.message,\n title: this.signInTitle,\n description: this.signInDescription,\n allowCredentialsLogin: this.allowCredentialsLogin,\n federatedProviders: this.federatedProviders\n },\n requestPasswordResetCode: {\n isLoading: this.formLoading,\n message: this.message\n },\n passwordResetCodeSent: {\n isLoading: this.formLoading,\n message: this.message\n },\n setNewPassword: {\n isLoading: this.formLoading,\n message: this.message\n },\n requireNewPassword: {\n isLoading: this.formLoading,\n requiredAttributes: (this.authData && this.authData.requiredAttributes) || []\n },\n confirmTotpCode: {\n isLoading: this.formLoading,\n message: this.message\n },\n setupTotp: {\n isLoading: this.formLoading,\n sharedSecret: this.totpSharedSecret,\n qrCodeUri: this.totpQrCodeUri,\n message: this.message\n }\n };\n }\n\n async init(params: ICognitoInitParams): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n let oauthConfig:\n | { Cognito: { userPoolId: string; userPoolClientId: string; loginWith: any } }\n | undefined;\n\n if (this.signInConfig) {\n const config = await this.signInConfig.getConfig();\n\n runInAction(() => {\n this.signInTitle = config.title ?? \"Sign in\";\n this.signInDescription = config.description;\n\n if (!config.description && !config.allowCredentialsLogin) {\n this.signInDescription = federatedDescription;\n }\n\n this.allowCredentialsLogin = config.allowCredentialsLogin;\n this.federatedProviders = config.providers;\n });\n\n const domain = process.env.REACT_APP_USER_POOL_DOMAIN;\n if (domain) {\n oauthConfig = {\n Cognito: {\n userPoolId: params.userPoolId,\n userPoolClientId: params.clientId,\n loginWith: {\n oauth: {\n domain,\n redirectSignIn: config.oauth.redirectSignIn,\n redirectSignOut: config.oauth.redirectSignOut,\n scopes: config.oauth.scopes,\n responseType: config.oauth.responseType\n }\n }\n }\n };\n }\n }\n\n Amplify.configure({\n Auth: oauthConfig ?? {\n Cognito: {\n userPoolId: params.userPoolId,\n userPoolClientId: params.clientId\n }\n }\n });\n this.initialized = true;\n\n await this.checkUrl();\n }\n\n // Public API\n async signIn(username: string, password: string): Promise<void> {\n runInAction(() => {\n this.formLoading = true;\n this.message = null;\n });\n\n const usernameOrPassword = [\"UserNotFoundException\", \"NotAuthorizedException\"];\n\n try {\n const result = await signIn({ username, password });\n const { nextStep } = result;\n\n if (nextStep.signInStep === \"CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED\") {\n runInAction(() => {\n this.authState = \"requireNewPassword\";\n this.authData = {\n requiredAttributes: nextStep.missingAttributes || []\n };\n this.formLoading = false;\n });\n } else if (nextStep.signInStep === \"CONFIRM_SIGN_IN_WITH_TOTP_CODE\") {\n runInAction(() => {\n this.authState = \"confirmTotpCode\";\n this.formLoading = false;\n });\n } else if (nextStep.signInStep === \"CONTINUE_SIGN_IN_WITH_TOTP_SETUP\") {\n const totpSetup = nextStep.totpSetupDetails;\n const uri = totpSetup.getSetupUri(\"Webiny\").toString();\n runInAction(() => {\n this.totpSharedSecret = totpSetup.sharedSecret;\n this.totpQrCodeUri = uri;\n this.authState = \"setupTotp\";\n this.formLoading = false;\n });\n } else {\n await this.handleSignedIn();\n runInAction(() => {\n this.formLoading = false;\n });\n }\n } catch (error) {\n let message = error.message;\n\n if (usernameOrPassword.includes(error.name)) {\n message = \"Incorrect username or password.\";\n }\n runInAction(() => {\n this.message = {\n title: \"Login Failed\",\n text: message,\n type: \"danger\"\n };\n this.formLoading = false;\n });\n }\n }\n\n async confirmNewPassword(password: string, requiredAttributes: any): Promise<void> {\n runInAction(() => {\n this.formLoading = true;\n this.message = null;\n });\n\n try {\n await confirmSignIn({\n challengeResponse: password,\n options: { userAttributes: requiredAttributes }\n });\n await this.handleSignedIn();\n } catch (error) {\n runInAction(() => {\n this.message = {\n title: \"Error\",\n text: error.message,\n type: \"danger\"\n };\n });\n } finally {\n runInAction(() => {\n this.formLoading = false;\n });\n }\n }\n\n async requestPasswordReset(username: string): Promise<void> {\n runInAction(() => {\n this.formLoading = true;\n this.message = null;\n });\n\n try {\n await resetPassword({ username });\n } catch {\n // We ignore errors and pretend that everything went fine.\n // Showing an error would give a potential attacker information about which usernames exist (or not).\n // This way it's more difficult to exploit the process.\n } finally {\n runInAction(() => {\n this.authState = \"passwordResetCodeSent\";\n this.authData = { username };\n this.formLoading = false;\n });\n }\n }\n\n async resendPasswordResetCode(): Promise<void> {\n const username = this.authData?.username;\n if (this.authState !== \"passwordResetCodeSent\" || !username) {\n return;\n }\n\n await this.requestPasswordReset(username!);\n runInAction(() => {\n this.message = {\n title: \"Code Resent\",\n text: \"Password reset code has been resent to your email address. Please check your inbox!\",\n type: \"success\"\n };\n });\n }\n\n async confirmPasswordReset(code: string, password: string): Promise<void> {\n const username = this.authData?.username;\n if (!username) {\n return;\n }\n\n runInAction(() => {\n this.formLoading = true;\n this.message = null;\n });\n\n try {\n await confirmResetPassword({\n username,\n confirmationCode: code,\n newPassword: password\n });\n runInAction(() => {\n this.authState = \"signIn\";\n this.message = {\n title: \"Password Reset\",\n text: \"You can now sign in with your new password\",\n type: \"success\"\n };\n });\n } catch (error) {\n runInAction(() => {\n this.message = {\n title: \"Error\",\n text: error.message,\n type: \"danger\"\n };\n });\n } finally {\n runInAction(() => {\n this.formLoading = false;\n });\n }\n }\n\n async confirmTotpCode(code: string): Promise<void> {\n runInAction(() => {\n this.formLoading = true;\n this.message = null;\n });\n\n try {\n await confirmSignIn({ challengeResponse: code });\n await this.handleSignedIn();\n } catch (error) {\n runInAction(() => {\n this.message = {\n title: \"Verification Failed\",\n text: error.message,\n type: \"danger\"\n };\n });\n } finally {\n runInAction(() => {\n this.formLoading = false;\n });\n }\n }\n\n async verifyTotpSetup(code: string): Promise<void> {\n runInAction(() => {\n this.formLoading = true;\n this.message = null;\n });\n\n try {\n await confirmSignIn({ challengeResponse: code });\n await this.handleSignedIn();\n } catch (error) {\n runInAction(() => {\n this.message = {\n title: \"Setup Failed\",\n text: error.message,\n type: \"danger\"\n };\n });\n } finally {\n runInAction(() => {\n this.formLoading = false;\n });\n }\n }\n\n showSignIn(): void {\n this.authState = \"signIn\";\n this.authData = null;\n this.message = null;\n }\n\n showRequestPasswordResetCode(): void {\n this.authState = \"requestPasswordResetCode\";\n this.message = null;\n }\n\n showSetNewPassword(): void {\n this.authState = \"setNewPassword\";\n this.message = null;\n }\n\n // Private/internal methods\n private async handleSignedIn(): Promise<void> {\n runInAction(() => {\n this.isLoggingIn = true;\n });\n\n try {\n await this.logInUseCase.execute({\n idTokenProvider: async () => {\n const session = await fetchAuthSession();\n const idToken = session.tokens?.idToken;\n if (!idToken) {\n throw new Error(\"No ID token available.\");\n }\n return idToken.toString();\n },\n logoutCallback: () => {\n signOut();\n runInAction(() => {\n this.authState = \"signIn\";\n this.authData = null;\n });\n }\n });\n\n runInAction(() => {\n this.authState = \"signedIn\";\n });\n } catch (error) {\n console.error(\"Error during sign in:\", error);\n runInAction(() => {\n this.authState = \"signIn\";\n });\n } finally {\n runInAction(() => {\n this.isLoggingIn = false;\n });\n }\n }\n\n private async checkUrl(): Promise<void> {\n return this.checkSession();\n }\n\n private async checkSession(): Promise<void> {\n runInAction(() => {\n this.checkingSession = true;\n });\n\n try {\n const session = await fetchAuthSession();\n if (session.tokens) {\n // We don't need to `await`, we simply start a separate \"branch\" of execution.\n this.handleSignedIn();\n }\n } catch {\n // Not authenticated, stay on signIn\n } finally {\n runInAction(() => {\n this.checkingSession = false;\n });\n }\n }\n}\n\nexport const CognitoPresenter = CognitoPresenterAbstraction.createImplementation({\n implementation: CognitoPresenterImpl,\n dependencies: [IdentityContext, LogInUseCase, [CognitoSignInConfig, { optional: true }]]\n});\n"],"names":["federatedDescription","CognitoPresenterImpl","identity","logInUseCase","signInConfig","undefined","makeAutoObservable","params","oauthConfig","config","runInAction","domain","process","Amplify","username","password","usernameOrPassword","result","signIn","nextStep","totpSetup","uri","error","message","requiredAttributes","confirmSignIn","resetPassword","code","confirmResetPassword","session","fetchAuthSession","idToken","Error","signOut","console","CognitoPresenter","CognitoPresenterAbstraction","IdentityContext","LogInUseCase","CognitoSignInConfig"],"mappings":";;;;;;;AAqBA,MAAMA,uBACF;AAEJ,MAAMC;IAiBF,YACYC,QAAmC,EACnCC,YAAoC,EACpCC,YAAuD,CACjE;aAHUF,QAAQ,GAARA;aACAC,YAAY,GAAZA;aACAC,YAAY,GAAZA;aAnBJ,SAAS,GAAc;aACvB,QAAQ,GAAoB;aAC5B,OAAO,GAAuB;aAC9B,eAAe,GAAG;aAClB,WAAW,GAAG;aACd,WAAW,GAAG;aACd,WAAW,GAAG;aAEd,WAAW,GAAG;aACd,iBAAiB,GAAuBC;aACxC,qBAAqB,GAAG;aACxB,kBAAkB,GAA4C,EAAE;aAEhE,gBAAgB,GAAG;aACnB,aAAa,GAAG;QAOpBC,mBAAmB,IAAI;IAC3B;IAEA,IAAI,KAAK;QAC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;QAEA,IAAI;YACA,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;gBAC5B,iBAAiB;oBACb,MAAMmB,UAAU,MAAMC;oBACtB,MAAMC,UAAUF,QAAQ,MAAM,EAAE;oBAChC,IAAI,CAACE,SACD,MAAM,IAAIC,MAAM;oBAEpB,OAAOD,QAAQ,QAAQ;gBAC3B;gBACA,gBAAgB;oBACZE;oBACAvB,YAAY;wBACR,IAAI,CAAC,SAAS,GAAG;wBACjB,IAAI,CAAC,QAAQ,GAAG;oBACpB;gBACJ;YACJ;YAEAA,YAAY;gBACR,IAAI,CAAC,SAAS,GAAG;YACrB;QACJ,EAAE,OAAOY,OAAO;YACZY,QAAQ,KAAK,CAAC,yBAAyBZ;YACvCZ,YAAY;gBACR,IAAI,CAAC,SAAS,GAAG;YACrB;QACJ,SAAU;YACNA,YAAY;gBACR,IAAI,CAAC,WAAW,GAAG;YACvB;QACJ;IACJ;IAEA,MAAc,WAA0B;QACpC,OAAO,IAAI,CAAC,YAAY;IAC5B;IAEA,MAAc,eAA8B;QACxCA,YAAY;YACR,IAAI,CAAC,eAAe,GAAG;QAC3B;QAEA,IAAI;YACA,MAAMmB,UAAU,MAAMC;YACtB,IAAID,QAAQ,MAAM,EAEd,IAAI,CAAC,cAAc;QAE3B,EAAE,OAAM,CAER,SAAU;YACNnB,YAAY;gBACR,IAAI,CAAC,eAAe,GAAG;YAC3B;QACJ;IACJ;AACJ;AAEO,MAAMyB,oCAAmBC,iBAAAA,oBAAgD,CAAC;IAC7E,gBAAgBnC;IAChB,cAAc;QAACoC;QAAiBC;QAAc;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC5F"}
@@ -0,0 +1,31 @@
1
+ import type React from "react";
2
+ export interface SignInProps {
3
+ signIn: () => void;
4
+ }
5
+ export type IFederatedProvider = {
6
+ name: string;
7
+ label: string;
8
+ } | {
9
+ name: string;
10
+ component: React.FC<SignInProps>;
11
+ };
12
+ export interface ICognitoSignInConfig {
13
+ getConfig(): Promise<{
14
+ oauth: {
15
+ scopes: string[];
16
+ redirectSignIn: string[];
17
+ redirectSignOut: string[];
18
+ responseType: "code" | "token";
19
+ };
20
+ allowCredentialsLogin: boolean;
21
+ providers: IFederatedProvider[];
22
+ title?: string;
23
+ description?: string;
24
+ }>;
25
+ }
26
+ export declare const CognitoSignInConfig: import("@webiny/di").Abstraction<ICognitoSignInConfig>;
27
+ export declare namespace CognitoSignInConfig {
28
+ type Interface = ICognitoSignInConfig;
29
+ type Config = Awaited<ReturnType<ICognitoSignInConfig["getConfig"]>>;
30
+ type FederatedProvider = IFederatedProvider;
31
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const CognitoSignInConfig = createAbstraction("CognitoSignInConfig");
3
+ export { CognitoSignInConfig };
4
+
5
+ //# sourceMappingURL=CognitoSignInConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/presentation/Cognito/CognitoSignInConfig.js","sources":["../../../../src/admin/presentation/Cognito/CognitoSignInConfig.ts"],"sourcesContent":["import type React from \"react\";\nimport { createAbstraction } from \"@webiny/feature/admin\";\n\nexport interface SignInProps {\n signIn: () => void;\n}\n\nexport type IFederatedProvider =\n | { name: string; label: string }\n | { name: string; component: React.FC<SignInProps> };\n\nexport interface ICognitoSignInConfig {\n getConfig(): Promise<{\n oauth: {\n scopes: string[];\n redirectSignIn: string[];\n redirectSignOut: string[];\n responseType: \"code\" | \"token\";\n };\n allowCredentialsLogin: boolean;\n providers: IFederatedProvider[];\n title?: string;\n description?: string;\n }>;\n}\n\nexport const CognitoSignInConfig = createAbstraction<ICognitoSignInConfig>(\"CognitoSignInConfig\");\n\nexport namespace CognitoSignInConfig {\n export type Interface = ICognitoSignInConfig;\n export type Config = Awaited<ReturnType<ICognitoSignInConfig[\"getConfig\"]>>;\n export type FederatedProvider = IFederatedProvider;\n}\n"],"names":["CognitoSignInConfig","createAbstraction"],"mappings":";AA0BO,MAAMA,sBAAsBC,kBAAwC"}
@@ -0,0 +1,91 @@
1
+ import type { IFederatedProvider } from "./CognitoSignInConfig.js";
2
+ export type AuthState = "signIn" | "signedIn" | "signedOut" | "requestPasswordResetCode" | "passwordResetCodeSent" | "setNewPassword" | "requireNewPassword" | "confirmTotpCode" | "setupTotp";
3
+ export interface AuthDataVerified {
4
+ email?: string;
5
+ phone_number?: string;
6
+ }
7
+ export interface AuthDataUnverified {
8
+ email?: string;
9
+ phone_number?: string;
10
+ }
11
+ export interface AuthData {
12
+ username?: string;
13
+ verified?: AuthDataVerified;
14
+ unverified?: AuthDataUnverified;
15
+ requiredAttributes?: string[];
16
+ [key: string]: string | null | boolean | undefined | string[] | AuthDataVerified | AuthDataUnverified;
17
+ }
18
+ export interface AuthMessage {
19
+ title: string;
20
+ text: string;
21
+ type: "success" | "info" | "warning" | "danger";
22
+ }
23
+ export interface ICognitoInitParams {
24
+ region: string;
25
+ userPoolId: string;
26
+ clientId: string;
27
+ }
28
+ export interface SignInVM {
29
+ isLoading: boolean;
30
+ message: AuthMessage | null;
31
+ title: string;
32
+ description: string | undefined;
33
+ allowCredentialsLogin: boolean;
34
+ federatedProviders: IFederatedProvider[];
35
+ }
36
+ export interface RequireNewPasswordVM {
37
+ isLoading: boolean;
38
+ requiredAttributes: string[];
39
+ }
40
+ export interface RequestPasswordResetCodeVM {
41
+ isLoading: boolean;
42
+ message: AuthMessage | null;
43
+ }
44
+ export interface PasswordResetCodeSentVM {
45
+ isLoading: boolean;
46
+ message: AuthMessage | null;
47
+ }
48
+ export interface SetNewPasswordVM {
49
+ isLoading: boolean;
50
+ message: AuthMessage | null;
51
+ }
52
+ export interface ConfirmTotpCodeVM {
53
+ isLoading: boolean;
54
+ message: AuthMessage | null;
55
+ }
56
+ export interface SetupTotpVM {
57
+ isLoading: boolean;
58
+ sharedSecret: string;
59
+ qrCodeUri: string;
60
+ message: AuthMessage | null;
61
+ }
62
+ export interface ICognitoPresenter {
63
+ vm: {
64
+ authState: AuthState;
65
+ checkingSession: boolean;
66
+ isLoggingIn: boolean;
67
+ isAuthenticated: boolean;
68
+ signIn: SignInVM;
69
+ requireNewPassword: RequireNewPasswordVM;
70
+ requestPasswordResetCode: RequestPasswordResetCodeVM;
71
+ passwordResetCodeSent: PasswordResetCodeSentVM;
72
+ setNewPassword: SetNewPasswordVM;
73
+ confirmTotpCode: ConfirmTotpCodeVM;
74
+ setupTotp: SetupTotpVM;
75
+ };
76
+ init(params: ICognitoInitParams): Promise<void>;
77
+ signIn(username: string, password: string): Promise<void>;
78
+ confirmNewPassword(password: string, requiredAttributes: any): Promise<void>;
79
+ requestPasswordReset(username: string): Promise<void>;
80
+ resendPasswordResetCode(): Promise<void>;
81
+ confirmPasswordReset(code: string, password: string): Promise<void>;
82
+ confirmTotpCode(code: string): Promise<void>;
83
+ verifyTotpSetup(code: string): Promise<void>;
84
+ showSignIn(): void;
85
+ showRequestPasswordResetCode(): void;
86
+ showSetNewPassword(): void;
87
+ }
88
+ export declare const CognitoPresenter: import("@webiny/di").Abstraction<ICognitoPresenter>;
89
+ export declare namespace CognitoPresenter {
90
+ type Interface = ICognitoPresenter;
91
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const CognitoPresenter = createAbstraction("CognitoPresenter");
3
+ export { CognitoPresenter };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/presentation/Cognito/abstractions.js","sources":["../../../../src/admin/presentation/Cognito/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IFederatedProvider } from \"./CognitoSignInConfig.js\";\n\nexport type AuthState =\n | \"signIn\"\n | \"signedIn\"\n | \"signedOut\"\n | \"requestPasswordResetCode\"\n | \"passwordResetCodeSent\"\n | \"setNewPassword\"\n | \"requireNewPassword\"\n | \"confirmTotpCode\"\n | \"setupTotp\";\n\nexport interface AuthDataVerified {\n email?: string;\n phone_number?: string;\n}\n\nexport interface AuthDataUnverified {\n email?: string;\n phone_number?: string;\n}\n\nexport interface AuthData {\n username?: string;\n verified?: AuthDataVerified;\n unverified?: AuthDataUnverified;\n requiredAttributes?: string[];\n [key: string]:\n | string\n | null\n | boolean\n | undefined\n | string[]\n | AuthDataVerified\n | AuthDataUnverified;\n}\n\nexport interface AuthMessage {\n title: string;\n text: string;\n type: \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nexport interface ICognitoInitParams {\n region: string;\n userPoolId: string;\n clientId: string;\n}\n\nexport interface SignInVM {\n isLoading: boolean;\n message: AuthMessage | null;\n title: string;\n description: string | undefined;\n allowCredentialsLogin: boolean;\n federatedProviders: IFederatedProvider[];\n}\n\nexport interface RequireNewPasswordVM {\n isLoading: boolean;\n requiredAttributes: string[];\n}\n\nexport interface RequestPasswordResetCodeVM {\n isLoading: boolean;\n message: AuthMessage | null;\n}\n\nexport interface PasswordResetCodeSentVM {\n isLoading: boolean;\n message: AuthMessage | null;\n}\n\nexport interface SetNewPasswordVM {\n isLoading: boolean;\n message: AuthMessage | null;\n}\n\nexport interface ConfirmTotpCodeVM {\n isLoading: boolean;\n message: AuthMessage | null;\n}\n\nexport interface SetupTotpVM {\n isLoading: boolean;\n sharedSecret: string;\n qrCodeUri: string;\n message: AuthMessage | null;\n}\n\nexport interface ICognitoPresenter {\n vm: {\n authState: AuthState;\n checkingSession: boolean;\n isLoggingIn: boolean;\n isAuthenticated: boolean;\n signIn: SignInVM;\n requireNewPassword: RequireNewPasswordVM;\n requestPasswordResetCode: RequestPasswordResetCodeVM;\n passwordResetCodeSent: PasswordResetCodeSentVM;\n setNewPassword: SetNewPasswordVM;\n confirmTotpCode: ConfirmTotpCodeVM;\n setupTotp: SetupTotpVM;\n };\n\n // Lifecycle\n init(params: ICognitoInitParams): Promise<void>;\n\n // Authentication actions\n signIn(username: string, password: string): Promise<void>;\n confirmNewPassword(password: string, requiredAttributes: any): Promise<void>;\n requestPasswordReset(username: string): Promise<void>;\n resendPasswordResetCode(): Promise<void>;\n confirmPasswordReset(code: string, password: string): Promise<void>;\n confirmTotpCode(code: string): Promise<void>;\n verifyTotpSetup(code: string): Promise<void>;\n\n // Navigation actions\n showSignIn(): void;\n showRequestPasswordResetCode(): void;\n showSetNewPassword(): void;\n}\n\nexport const CognitoPresenter = createAbstraction<ICognitoPresenter>(\"CognitoPresenter\");\n\nexport namespace CognitoPresenter {\n export type Interface = ICognitoPresenter;\n}\n"],"names":["CognitoPresenter","createAbstraction"],"mappings":";AA6HO,MAAMA,mBAAmBC,kBAAqC"}
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import type { ConfirmTotpCodeVM } from "../../../../admin/presentation/Cognito/abstractions.js";
3
+ export interface ConfirmTotpCodeProps {
4
+ vm: ConfirmTotpCodeVM;
5
+ onSubmit: (code: string) => void;
6
+ onCancel: () => void;
7
+ }
8
+ export declare const ConfirmTotpCode: ((props: ConfirmTotpCodeProps) => React.JSX.Element) & {
9
+ original: (props: ConfirmTotpCodeProps) => React.JSX.Element;
10
+ originalName: string;
11
+ displayName: string;
12
+ } & {
13
+ original: ((props: ConfirmTotpCodeProps) => React.JSX.Element) & {
14
+ original: (props: ConfirmTotpCodeProps) => React.JSX.Element;
15
+ originalName: string;
16
+ displayName: string;
17
+ };
18
+ originalName: string;
19
+ displayName: string;
20
+ } & {
21
+ createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<((props: ConfirmTotpCodeProps) => React.JSX.Element) & {
22
+ original: (props: ConfirmTotpCodeProps) => React.JSX.Element;
23
+ originalName: string;
24
+ displayName: string;
25
+ }>) => (props: unknown) => React.JSX.Element;
26
+ };
@@ -0,0 +1,45 @@
1
+ import react from "react";
2
+ import { Alert, Button, Grid, Input } from "@webiny/admin-ui";
3
+ import { makeDecoratable } from "@webiny/app-admin";
4
+ import { Bind, Form } from "@webiny/form";
5
+ import { validation } from "@webiny/validation";
6
+ import { View } from "./View.js";
7
+ import { FooterSignIn } from "./FooterSignIn.js";
8
+ const ConfirmTotpCode = makeDecoratable("CognitoConfirmTotpCode", (props)=>{
9
+ const { vm, onSubmit, onCancel } = props;
10
+ return /*#__PURE__*/ react.createElement(View.Container, null, /*#__PURE__*/ react.createElement(Form, {
11
+ onSubmit: (data)=>onSubmit(data.code),
12
+ submitOnEnter: true
13
+ }, ({ submit })=>/*#__PURE__*/ react.createElement(View.Content, null, /*#__PURE__*/ react.createElement(View.Title, {
14
+ title: "Two-factor authentication",
15
+ description: "Enter the 6-digit code from your authenticator app."
16
+ }), vm.message && /*#__PURE__*/ react.createElement("div", {
17
+ className: "mb-lg"
18
+ }, /*#__PURE__*/ react.createElement(Alert, {
19
+ title: vm.message.title,
20
+ type: vm.message.type
21
+ }, vm.message.text)), /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
22
+ span: 12
23
+ }, /*#__PURE__*/ react.createElement(Bind, {
24
+ name: "code",
25
+ validators: validation.create("required")
26
+ }, /*#__PURE__*/ react.createElement(Input, {
27
+ label: "Verification Code",
28
+ autoComplete: "one-time-code",
29
+ inputMode: "numeric"
30
+ }))), /*#__PURE__*/ react.createElement(Grid.Column, {
31
+ span: 12
32
+ }, /*#__PURE__*/ react.createElement("div", {
33
+ className: "flex items-center justify-between"
34
+ }, /*#__PURE__*/ react.createElement(FooterSignIn, {
35
+ onSignIn: onCancel
36
+ }), /*#__PURE__*/ react.createElement(Button, {
37
+ text: "Verify",
38
+ onClick: submit,
39
+ containerClassName: "ml-auto",
40
+ disabled: vm.isLoading
41
+ })))))));
42
+ });
43
+ export { ConfirmTotpCode };
44
+
45
+ //# sourceMappingURL=ConfirmTotpCode.js.map