@webiny/cognito 6.4.5-beta.0 → 6.6.0-alpha.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.
- package/Cognito.d.ts +0 -51
- package/Cognito.js +4 -78
- package/Cognito.js.map +1 -1
- package/admin/Cognito.d.ts +3 -1
- package/admin/Extension.js +21 -0
- package/admin/Extension.js.map +1 -1
- package/admin/features/account/getCurrentUser/GetCurrentUserGateway.d.ts +11 -0
- package/admin/features/account/getCurrentUser/GetCurrentUserGateway.js +44 -0
- package/admin/features/account/getCurrentUser/GetCurrentUserGateway.js.map +1 -0
- package/admin/features/account/getCurrentUser/GetCurrentUserUseCase.d.ts +10 -0
- package/admin/features/account/getCurrentUser/GetCurrentUserUseCase.js +19 -0
- package/admin/features/account/getCurrentUser/GetCurrentUserUseCase.js.map +1 -0
- package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserGateway.d.ts +16 -0
- package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserGateway.js +5 -0
- package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserGateway.js.map +1 -0
- package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserUseCase.d.ts +10 -0
- package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserUseCase.js +5 -0
- package/admin/features/account/getCurrentUser/abstractions/GetCurrentUserUseCase.js.map +1 -0
- package/admin/features/account/getCurrentUser/abstractions/index.d.ts +6 -0
- package/admin/features/account/getCurrentUser/abstractions/index.js +2 -0
- package/admin/features/account/getCurrentUser/feature.d.ts +3 -0
- package/admin/features/account/getCurrentUser/feature.js +19 -0
- package/admin/features/account/getCurrentUser/feature.js.map +1 -0
- package/admin/features/account/getCurrentUser/index.d.ts +1 -0
- package/admin/features/account/getCurrentUser/index.js +1 -0
- package/admin/features/account/updateCurrentUser/UpdateCurrentUserGateway.d.ts +11 -0
- package/admin/features/account/updateCurrentUser/UpdateCurrentUserGateway.js +48 -0
- package/admin/features/account/updateCurrentUser/UpdateCurrentUserGateway.js.map +1 -0
- package/admin/features/account/updateCurrentUser/UpdateCurrentUserUseCase.d.ts +10 -0
- package/admin/features/account/updateCurrentUser/UpdateCurrentUserUseCase.js +19 -0
- package/admin/features/account/updateCurrentUser/UpdateCurrentUserUseCase.js.map +1 -0
- package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserGateway.d.ts +26 -0
- package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserGateway.js +5 -0
- package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserGateway.js.map +1 -0
- package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserUseCase.d.ts +13 -0
- package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserUseCase.js +5 -0
- package/admin/features/account/updateCurrentUser/abstractions/UpdateCurrentUserUseCase.js.map +1 -0
- package/admin/features/account/updateCurrentUser/abstractions/index.d.ts +8 -0
- package/admin/features/account/updateCurrentUser/abstractions/index.js +2 -0
- package/admin/features/account/updateCurrentUser/feature.d.ts +3 -0
- package/admin/features/account/updateCurrentUser/feature.js +19 -0
- package/admin/features/account/updateCurrentUser/feature.js.map +1 -0
- package/admin/features/account/updateCurrentUser/index.d.ts +1 -0
- package/admin/features/account/updateCurrentUser/index.js +1 -0
- package/admin/features/permissions/feature.d.ts +1 -1
- package/admin/features/users/createUser/CreateUserGateway.d.ts +11 -0
- package/admin/features/users/createUser/CreateUserGateway.js +49 -0
- package/admin/features/users/createUser/CreateUserGateway.js.map +1 -0
- package/admin/features/users/createUser/CreateUserUseCase.d.ts +10 -0
- package/admin/features/users/createUser/CreateUserUseCase.js +18 -0
- package/admin/features/users/createUser/CreateUserUseCase.js.map +1 -0
- package/admin/features/users/createUser/abstractions/CreateUserGateway.d.ts +21 -0
- package/admin/features/users/createUser/abstractions/CreateUserGateway.js +5 -0
- package/admin/features/users/createUser/abstractions/CreateUserGateway.js.map +1 -0
- package/admin/features/users/createUser/abstractions/CreateUserUseCase.d.ts +14 -0
- package/admin/features/users/createUser/abstractions/CreateUserUseCase.js +5 -0
- package/admin/features/users/createUser/abstractions/CreateUserUseCase.js.map +1 -0
- package/admin/features/users/createUser/abstractions/index.d.ts +2 -0
- package/admin/features/users/createUser/abstractions/index.js +2 -0
- package/admin/features/users/createUser/feature.d.ts +3 -0
- package/admin/features/users/createUser/feature.js +19 -0
- package/admin/features/users/createUser/feature.js.map +1 -0
- package/admin/features/users/createUser/index.d.ts +2 -0
- package/admin/features/users/createUser/index.js +2 -0
- package/admin/features/users/deleteUser/DeleteUserGateway.d.ts +11 -0
- package/admin/features/users/deleteUser/DeleteUserGateway.js +40 -0
- package/admin/features/users/deleteUser/DeleteUserGateway.js.map +1 -0
- package/admin/features/users/deleteUser/DeleteUserUseCase.d.ts +10 -0
- package/admin/features/users/deleteUser/DeleteUserUseCase.js +18 -0
- package/admin/features/users/deleteUser/DeleteUserUseCase.js.map +1 -0
- package/admin/features/users/deleteUser/abstractions/DeleteUserGateway.d.ts +11 -0
- package/admin/features/users/deleteUser/abstractions/DeleteUserGateway.js +5 -0
- package/admin/features/users/deleteUser/abstractions/DeleteUserGateway.js.map +1 -0
- package/admin/features/users/deleteUser/abstractions/DeleteUserUseCase.d.ts +11 -0
- package/admin/features/users/deleteUser/abstractions/DeleteUserUseCase.js +5 -0
- package/admin/features/users/deleteUser/abstractions/DeleteUserUseCase.js.map +1 -0
- package/admin/features/users/deleteUser/abstractions/index.d.ts +2 -0
- package/admin/features/users/deleteUser/abstractions/index.js +2 -0
- package/admin/features/users/deleteUser/feature.d.ts +3 -0
- package/admin/features/users/deleteUser/feature.js +19 -0
- package/admin/features/users/deleteUser/feature.js.map +1 -0
- package/admin/features/users/deleteUser/index.d.ts +2 -0
- package/admin/features/users/deleteUser/index.js +2 -0
- package/admin/features/users/getUser/GetUserGateway.d.ts +11 -0
- package/admin/features/users/getUser/GetUserGateway.js +57 -0
- package/admin/features/users/getUser/GetUserGateway.js.map +1 -0
- package/admin/features/users/getUser/GetUserUseCase.d.ts +10 -0
- package/admin/features/users/getUser/GetUserUseCase.js +18 -0
- package/admin/features/users/getUser/GetUserUseCase.js.map +1 -0
- package/admin/features/users/getUser/abstractions/GetUserGateway.d.ts +32 -0
- package/admin/features/users/getUser/abstractions/GetUserGateway.js +5 -0
- package/admin/features/users/getUser/abstractions/GetUserGateway.js.map +1 -0
- package/admin/features/users/getUser/abstractions/GetUserUseCase.d.ts +14 -0
- package/admin/features/users/getUser/abstractions/GetUserUseCase.js +5 -0
- package/admin/features/users/getUser/abstractions/GetUserUseCase.js.map +1 -0
- package/admin/features/users/getUser/abstractions/index.d.ts +2 -0
- package/admin/features/users/getUser/abstractions/index.js +2 -0
- package/admin/features/users/getUser/feature.d.ts +3 -0
- package/admin/features/users/getUser/feature.js +19 -0
- package/admin/features/users/getUser/feature.js.map +1 -0
- package/admin/features/users/getUser/index.d.ts +2 -0
- package/admin/features/users/getUser/index.js +2 -0
- package/admin/features/users/listUsers/ListUsersGateway.d.ts +11 -0
- package/admin/features/users/listUsers/ListUsersGateway.js +39 -0
- package/admin/features/users/listUsers/ListUsersGateway.js.map +1 -0
- package/admin/features/users/listUsers/ListUsersUseCase.d.ts +10 -0
- package/admin/features/users/listUsers/ListUsersUseCase.js +18 -0
- package/admin/features/users/listUsers/ListUsersUseCase.js.map +1 -0
- package/admin/features/users/listUsers/abstractions/ListUsersGateway.d.ts +17 -0
- package/admin/features/users/listUsers/abstractions/ListUsersGateway.js +5 -0
- package/admin/features/users/listUsers/abstractions/ListUsersGateway.js.map +1 -0
- package/admin/features/users/listUsers/abstractions/ListUsersUseCase.d.ts +10 -0
- package/admin/features/users/listUsers/abstractions/ListUsersUseCase.js +5 -0
- package/admin/features/users/listUsers/abstractions/ListUsersUseCase.js.map +1 -0
- package/admin/features/users/listUsers/abstractions/index.d.ts +2 -0
- package/admin/features/users/listUsers/abstractions/index.js +2 -0
- package/admin/features/users/listUsers/feature.d.ts +3 -0
- package/admin/features/users/listUsers/feature.js +19 -0
- package/admin/features/users/listUsers/feature.js.map +1 -0
- package/admin/features/users/listUsers/index.d.ts +2 -0
- package/admin/features/users/listUsers/index.js +2 -0
- package/admin/features/users/updateUser/UpdateUserGateway.d.ts +11 -0
- package/admin/features/users/updateUser/UpdateUserGateway.js +59 -0
- package/admin/features/users/updateUser/UpdateUserGateway.js.map +1 -0
- package/admin/features/users/updateUser/UpdateUserUseCase.d.ts +10 -0
- package/admin/features/users/updateUser/UpdateUserUseCase.js +18 -0
- package/admin/features/users/updateUser/UpdateUserUseCase.js.map +1 -0
- package/admin/features/users/updateUser/abstractions/UpdateUserGateway.d.ts +33 -0
- package/admin/features/users/updateUser/abstractions/UpdateUserGateway.js +5 -0
- package/admin/features/users/updateUser/abstractions/UpdateUserGateway.js.map +1 -0
- package/admin/features/users/updateUser/abstractions/UpdateUserUseCase.d.ts +15 -0
- package/admin/features/users/updateUser/abstractions/UpdateUserUseCase.js +5 -0
- package/admin/features/users/updateUser/abstractions/UpdateUserUseCase.js.map +1 -0
- package/admin/features/users/updateUser/abstractions/index.d.ts +2 -0
- package/admin/features/users/updateUser/abstractions/index.js +2 -0
- package/admin/features/users/updateUser/feature.d.ts +3 -0
- package/admin/features/users/updateUser/feature.js +19 -0
- package/admin/features/users/updateUser/feature.js.map +1 -0
- package/admin/features/users/updateUser/index.d.ts +2 -0
- package/admin/features/users/updateUser/index.js +2 -0
- package/admin/presentation/Cognito/CognitoLoginScreen.js +0 -9
- package/admin/presentation/Cognito/CognitoLoginScreen.js.map +1 -1
- package/admin/presentation/Cognito/CognitoPresenter.d.ts +1 -25
- package/admin/presentation/Cognito/CognitoPresenter.js +10 -122
- package/admin/presentation/Cognito/CognitoPresenter.js.map +1 -1
- package/admin/presentation/Cognito/abstractions.d.ts +1 -20
- package/admin/presentation/Cognito/abstractions.js.map +1 -1
- package/admin/presentation/Cognito/components/Divider.d.ts +1 -19
- package/admin/presentation/Cognito/components/Divider.js +2 -3
- package/admin/presentation/Cognito/components/Divider.js.map +1 -1
- package/admin/presentation/Cognito/components/FederatedLogin.d.ts +5 -22
- package/admin/presentation/Cognito/components/FederatedLogin.js +6 -19
- package/admin/presentation/Cognito/components/FederatedLogin.js.map +1 -1
- package/admin/presentation/Cognito/components/FooterSignIn.d.ts +3 -20
- package/admin/presentation/Cognito/components/FooterSignIn.js +2 -3
- package/admin/presentation/Cognito/components/FooterSignIn.js.map +1 -1
- package/admin/presentation/Cognito/components/PasswordResetCodeSent.d.ts +1 -19
- package/admin/presentation/Cognito/components/PasswordResetCodeSent.js +2 -3
- package/admin/presentation/Cognito/components/PasswordResetCodeSent.js.map +1 -1
- package/admin/presentation/Cognito/components/RequestPasswordResetCode.d.ts +1 -19
- package/admin/presentation/Cognito/components/RequestPasswordResetCode.js +2 -3
- package/admin/presentation/Cognito/components/RequestPasswordResetCode.js.map +1 -1
- package/admin/presentation/Cognito/components/RequireNewPassword.d.ts +1 -19
- package/admin/presentation/Cognito/components/RequireNewPassword.js +2 -3
- package/admin/presentation/Cognito/components/RequireNewPassword.js.map +1 -1
- package/admin/presentation/Cognito/components/SetNewPassword.d.ts +1 -19
- package/admin/presentation/Cognito/components/SetNewPassword.js +2 -3
- package/admin/presentation/Cognito/components/SetNewPassword.js.map +1 -1
- package/admin/presentation/Cognito/components/SignIn.d.ts +3 -19
- package/admin/presentation/Cognito/components/SignIn.js +7 -14
- package/admin/presentation/Cognito/components/SignIn.js.map +1 -1
- package/admin/presentation/Cognito/components/View.d.ts +1 -1
- package/admin/ui/views/Account/Account.js +42 -34
- package/admin/ui/views/Account/Account.js.map +1 -1
- package/admin/ui/views/Users/UsersDataList.js +44 -26
- package/admin/ui/views/Users/UsersDataList.js.map +1 -1
- package/admin/ui/views/Users/UsersForm.js +16 -22
- package/admin/ui/views/Users/UsersForm.js.map +1 -1
- package/admin/ui/views/Users/hooks/useUserForm.d.ts +2 -2
- package/admin/ui/views/Users/hooks/useUserForm.js +60 -78
- package/admin/ui/views/Users/hooks/useUserForm.js.map +1 -1
- package/api/features/CognitoIdp/CognitoIdentityProvider.js +11 -15
- package/api/features/CognitoIdp/CognitoIdentityProvider.js.map +1 -1
- package/api/features/CognitoIdp/abstractions.d.ts +1 -1
- package/api/features/CognitoIdp/abstractions.js.map +1 -1
- package/api/graphql/user.gql.d.ts +2 -2
- package/api/graphql/user.gql.js +2 -2
- package/api/graphql/user.gql.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +18 -23
- package/admin/DefaultCognitoSignInConfig.d.ts +0 -23
- package/admin/DefaultCognitoSignInConfig.js +0 -51
- package/admin/DefaultCognitoSignInConfig.js.map +0 -1
- package/admin/SignInExtension.d.ts +0 -2
- package/admin/SignInExtension.js +0 -9
- package/admin/SignInExtension.js.map +0 -1
- package/admin/index.d.ts +0 -2
- package/admin/index.js +0 -2
- package/admin/presentation/Cognito/CognitoSignInConfig.d.ts +0 -31
- package/admin/presentation/Cognito/CognitoSignInConfig.js +0 -5
- package/admin/presentation/Cognito/CognitoSignInConfig.js.map +0 -1
- package/admin/presentation/Cognito/components/ConfirmTotpCode.d.ts +0 -26
- package/admin/presentation/Cognito/components/ConfirmTotpCode.js +0 -45
- package/admin/presentation/Cognito/components/ConfirmTotpCode.js.map +0 -1
- package/admin/presentation/Cognito/components/SetupTotp.d.ts +0 -25
- package/admin/presentation/Cognito/components/SetupTotp.js +0 -60
- package/admin/presentation/Cognito/components/SetupTotp.js.map +0 -1
- package/admin/presentation/Cognito/components/index.d.ts +0 -292
- package/admin/presentation/Cognito/components/index.js +0 -29
- package/admin/presentation/Cognito/components/index.js.map +0 -1
- package/admin/presentation/Cognito/signInFeature.d.ts +0 -1
- package/admin/presentation/Cognito/signInFeature.js +0 -11
- package/admin/presentation/Cognito/signInFeature.js.map +0 -1
- package/admin/ui/views/Account/graphql.d.ts +0 -2
- package/admin/ui/views/Account/graphql.js +0 -41
- package/admin/ui/views/Account/graphql.js.map +0 -1
- package/admin/ui/views/Users/graphql.d.ts +0 -5
- package/admin/ui/views/Users/graphql.js +0 -98
- package/admin/ui/views/Users/graphql.js.map +0 -1
- package/api/index.d.ts +0 -1
- package/api/index.js +0 -1
- package/infra/CognitoFederationPulumi.d.ts +0 -8
- package/infra/CognitoFederationPulumi.js +0 -17
- package/infra/CognitoFederationPulumi.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/Cognito/CognitoLoginScreen.js","sources":["../../../../src/admin/presentation/Cognito/CognitoLoginScreen.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { CognitoFeature } from \"./feature.js\";\nimport { SignIn } from \"./components/SignIn.js\";\nimport { RequireNewPassword } from \"./components/RequireNewPassword.js\";\nimport { RequestPasswordResetCode } from \"./components/RequestPasswordResetCode.js\";\nimport { SetNewPassword } from \"./components/SetNewPassword.js\";\nimport { PasswordResetCodeSent } from \"~/admin/presentation/Cognito/components/PasswordResetCodeSent.js\";\
|
|
1
|
+
{"version":3,"file":"admin/presentation/Cognito/CognitoLoginScreen.js","sources":["../../../../src/admin/presentation/Cognito/CognitoLoginScreen.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { CognitoFeature } from \"./feature.js\";\nimport { SignIn } from \"./components/SignIn.js\";\nimport { RequireNewPassword } from \"./components/RequireNewPassword.js\";\nimport { RequestPasswordResetCode } from \"./components/RequestPasswordResetCode.js\";\nimport { SetNewPassword } from \"./components/SetNewPassword.js\";\nimport { PasswordResetCodeSent } from \"~/admin/presentation/Cognito/components/PasswordResetCodeSent.js\";\n\nexport interface CognitoLoginScreenProps {\n region: string;\n userPoolId: string;\n clientId: string;\n children: React.ReactNode;\n}\n\nexport const CognitoLoginScreen = observer((props: CognitoLoginScreenProps) => {\n const { presenter } = useFeature(CognitoFeature);\n\n useEffect(() => {\n presenter.init({\n region: props.region,\n userPoolId: props.userPoolId,\n clientId: props.clientId\n });\n }, []);\n\n const vm = presenter.vm;\n\n if (vm.isAuthenticated) {\n return <>{props.children}</>;\n }\n\n return (\n <>\n {vm.isLoggingIn ? <OverlayLoader text={\"Signing in...\"} /> : null}\n {vm.checkingSession ? <OverlayLoader text={\"Checking session...\"} /> : null}\n\n {!vm.isLoggingIn && !vm.checkingSession ? (\n <>\n {vm.authState === \"requireNewPassword\" && (\n <RequireNewPassword\n vm={vm.requireNewPassword}\n onSubmit={(password, attributes) =>\n presenter.confirmNewPassword(password, attributes)\n }\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"requestPasswordResetCode\" && (\n <RequestPasswordResetCode\n vm={vm.requestPasswordResetCode}\n onRequestCode={username => presenter.requestPasswordReset(username)}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"passwordResetCodeSent\" && (\n <PasswordResetCodeSent\n vm={vm.passwordResetCodeSent}\n onResendCode={() => presenter.resendPasswordResetCode()}\n onCodeAcquired={() => presenter.showSetNewPassword()}\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {vm.authState === \"setNewPassword\" && (\n <SetNewPassword\n vm={vm.setNewPassword}\n onSetNewPassword={(code, password) =>\n presenter.confirmPasswordReset(code, password)\n }\n onCancel={() => presenter.showSignIn()}\n />\n )}\n\n {(vm.authState === \"signIn\" || vm.authState === \"signedOut\") && (\n <SignIn\n vm={vm.signIn}\n onSubmit={(username, password) => presenter.signIn(username, password)}\n onForgotPassword={() => presenter.showRequestPasswordResetCode()}\n />\n )}\n </>\n ) : null}\n </>\n );\n});\n"],"names":["CognitoLoginScreen","observer","props","presenter","useFeature","CognitoFeature","useEffect","vm","OverlayLoader","RequireNewPassword","password","attributes","RequestPasswordResetCode","username","PasswordResetCodeSent","SetNewPassword","code","SignIn"],"mappings":";;;;;;;;;;AAkBO,MAAMA,qBAAqBC,SAAS,CAACC;IACx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ACrBP,UAAU,oBAAoB,CAACa,MAAMN;QAEzC,UAAU,IAAMP,UAAU,UAAU;QAI1CI,AAAAA,CAAAA,AAAiB,aAAjBA,GAAG,SAAS,IAAiBA,AAAiB,gBAAjBA,GAAG,SAAS,AAAe,mBACtD,oBAACU,QAAMA;QACH,IAAIV,GAAG,MAAM;QACb,UAAU,CAACM,UAAUH,WAAaP,UAAU,MAAM,CAACU,UAAUH;QAC7D,kBAAkB,IAAMP,UAAU,4BAA4B;;AAO1F"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { CognitoPresenter as CognitoPresenterAbstraction, AuthState, AuthMessage, ICognitoInitParams } from "./abstractions.js";
|
|
2
2
|
import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn/index.js";
|
|
3
3
|
import { IdentityContext } from "@webiny/app-admin/features/security/IdentityContext/index.js";
|
|
4
|
-
import { CognitoSignInConfig } from "./CognitoSignInConfig.js";
|
|
5
4
|
declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interface {
|
|
6
5
|
private identity;
|
|
7
6
|
private logInUseCase;
|
|
8
|
-
private signInConfig;
|
|
9
7
|
private authState;
|
|
10
8
|
private authData;
|
|
11
9
|
private message;
|
|
@@ -13,13 +11,7 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
13
11
|
private isLoggingIn;
|
|
14
12
|
private formLoading;
|
|
15
13
|
private initialized;
|
|
16
|
-
|
|
17
|
-
private signInDescription;
|
|
18
|
-
private allowCredentialsLogin;
|
|
19
|
-
private federatedProviders;
|
|
20
|
-
private totpSharedSecret;
|
|
21
|
-
private totpQrCodeUri;
|
|
22
|
-
constructor(identity: IdentityContext.Interface, logInUseCase: LogInUseCase.Interface, signInConfig: CognitoSignInConfig.Interface | undefined);
|
|
14
|
+
constructor(identity: IdentityContext.Interface, logInUseCase: LogInUseCase.Interface);
|
|
23
15
|
get vm(): {
|
|
24
16
|
authState: AuthState;
|
|
25
17
|
checkingSession: boolean;
|
|
@@ -28,10 +20,6 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
28
20
|
signIn: {
|
|
29
21
|
isLoading: boolean;
|
|
30
22
|
message: AuthMessage | null;
|
|
31
|
-
title: string;
|
|
32
|
-
description: string | undefined;
|
|
33
|
-
allowCredentialsLogin: boolean;
|
|
34
|
-
federatedProviders: import("./CognitoSignInConfig.js").IFederatedProvider[];
|
|
35
23
|
};
|
|
36
24
|
requestPasswordResetCode: {
|
|
37
25
|
isLoading: boolean;
|
|
@@ -49,16 +37,6 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
49
37
|
isLoading: boolean;
|
|
50
38
|
requiredAttributes: string[];
|
|
51
39
|
};
|
|
52
|
-
confirmTotpCode: {
|
|
53
|
-
isLoading: boolean;
|
|
54
|
-
message: AuthMessage | null;
|
|
55
|
-
};
|
|
56
|
-
setupTotp: {
|
|
57
|
-
isLoading: boolean;
|
|
58
|
-
sharedSecret: string;
|
|
59
|
-
qrCodeUri: string;
|
|
60
|
-
message: AuthMessage | null;
|
|
61
|
-
};
|
|
62
40
|
};
|
|
63
41
|
init(params: ICognitoInitParams): Promise<void>;
|
|
64
42
|
signIn(username: string, password: string): Promise<void>;
|
|
@@ -66,8 +44,6 @@ declare class CognitoPresenterImpl implements CognitoPresenterAbstraction.Interf
|
|
|
66
44
|
requestPasswordReset(username: string): Promise<void>;
|
|
67
45
|
resendPasswordResetCode(): Promise<void>;
|
|
68
46
|
confirmPasswordReset(code: string, password: string): Promise<void>;
|
|
69
|
-
confirmTotpCode(code: string): Promise<void>;
|
|
70
|
-
verifyTotpSetup(code: string): Promise<void>;
|
|
71
47
|
showSignIn(): void;
|
|
72
48
|
showRequestPasswordResetCode(): void;
|
|
73
49
|
showSetNewPassword(): void;
|
|
@@ -4,13 +4,10 @@ import { confirmResetPassword, confirmSignIn, fetchAuthSession, resetPassword, s
|
|
|
4
4
|
import { CognitoPresenter } from "./abstractions.js";
|
|
5
5
|
import { LogInUseCase } from "@webiny/app-admin/features/security/LogIn/index.js";
|
|
6
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
7
|
class CognitoPresenterImpl {
|
|
10
|
-
constructor(identity, logInUseCase
|
|
8
|
+
constructor(identity, logInUseCase){
|
|
11
9
|
this.identity = identity;
|
|
12
10
|
this.logInUseCase = logInUseCase;
|
|
13
|
-
this.signInConfig = signInConfig;
|
|
14
11
|
this.authState = "signIn";
|
|
15
12
|
this.authData = null;
|
|
16
13
|
this.message = null;
|
|
@@ -18,12 +15,6 @@ class CognitoPresenterImpl {
|
|
|
18
15
|
this.isLoggingIn = false;
|
|
19
16
|
this.formLoading = false;
|
|
20
17
|
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
18
|
makeAutoObservable(this);
|
|
28
19
|
}
|
|
29
20
|
get vm() {
|
|
@@ -35,11 +26,7 @@ class CognitoPresenterImpl {
|
|
|
35
26
|
isAuthenticated: identity.isAuthenticated,
|
|
36
27
|
signIn: {
|
|
37
28
|
isLoading: this.formLoading,
|
|
38
|
-
message: this.message
|
|
39
|
-
title: this.signInTitle,
|
|
40
|
-
description: this.signInDescription,
|
|
41
|
-
allowCredentialsLogin: this.allowCredentialsLogin,
|
|
42
|
-
federatedProviders: this.federatedProviders
|
|
29
|
+
message: this.message
|
|
43
30
|
},
|
|
44
31
|
requestPasswordResetCode: {
|
|
45
32
|
isLoading: this.formLoading,
|
|
@@ -56,50 +43,13 @@ class CognitoPresenterImpl {
|
|
|
56
43
|
requireNewPassword: {
|
|
57
44
|
isLoading: this.formLoading,
|
|
58
45
|
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
46
|
}
|
|
70
47
|
};
|
|
71
48
|
}
|
|
72
49
|
async init(params) {
|
|
73
50
|
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
51
|
Amplify.configure({
|
|
102
|
-
Auth:
|
|
52
|
+
Auth: {
|
|
103
53
|
Cognito: {
|
|
104
54
|
userPoolId: params.userPoolId,
|
|
105
55
|
userPoolClientId: params.clientId
|
|
@@ -131,20 +81,7 @@ class CognitoPresenterImpl {
|
|
|
131
81
|
};
|
|
132
82
|
this.formLoading = false;
|
|
133
83
|
});
|
|
134
|
-
else
|
|
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 {
|
|
84
|
+
else {
|
|
148
85
|
await this.handleSignedIn();
|
|
149
86
|
runInAction(()=>{
|
|
150
87
|
this.formLoading = false;
|
|
@@ -256,54 +193,6 @@ class CognitoPresenterImpl {
|
|
|
256
193
|
});
|
|
257
194
|
}
|
|
258
195
|
}
|
|
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
196
|
showSignIn() {
|
|
308
197
|
this.authState = "signIn";
|
|
309
198
|
this.authData = null;
|
|
@@ -352,6 +241,11 @@ class CognitoPresenterImpl {
|
|
|
352
241
|
}
|
|
353
242
|
}
|
|
354
243
|
async checkUrl() {
|
|
244
|
+
const query = new URLSearchParams(window.location.search);
|
|
245
|
+
const queryData = {};
|
|
246
|
+
query.forEach((value, key)=>queryData[key] = value);
|
|
247
|
+
const { state } = queryData;
|
|
248
|
+
if (state) return;
|
|
355
249
|
return this.checkSession();
|
|
356
250
|
}
|
|
357
251
|
async checkSession() {
|
|
@@ -372,13 +266,7 @@ const CognitoPresenter_CognitoPresenter = CognitoPresenter.createImplementation(
|
|
|
372
266
|
implementation: CognitoPresenterImpl,
|
|
373
267
|
dependencies: [
|
|
374
268
|
IdentityContext,
|
|
375
|
-
LogInUseCase
|
|
376
|
-
[
|
|
377
|
-
CognitoSignInConfig,
|
|
378
|
-
{
|
|
379
|
-
optional: true
|
|
380
|
-
}
|
|
381
|
-
]
|
|
269
|
+
LogInUseCase
|
|
382
270
|
]
|
|
383
271
|
});
|
|
384
272
|
export { CognitoPresenter_CognitoPresenter as CognitoPresenter };
|
|
@@ -1 +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;aAC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Ac;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC5F"}
|
|
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\";\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 constructor(\n private identity: IdentityContext.Interface,\n private logInUseCase: LogInUseCase.Interface\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 },\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 };\n }\n\n async init(params: ICognitoInitParams): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n Amplify.configure({\n Auth: {\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 {\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 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 const query = new URLSearchParams(window.location.search);\n const queryData: Record<string, string> = {};\n query.forEach((value, key) => (queryData[key] = value));\n const { state } = queryData;\n\n if (state) {\n // Handle state from URL if needed\n return;\n }\n\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]\n});\n"],"names":["CognitoPresenterImpl","identity","logInUseCase","makeAutoObservable","params","Amplify","username","password","runInAction","usernameOrPassword","result","signIn","nextStep","error","message","requiredAttributes","confirmSignIn","resetPassword","code","confirmResetPassword","session","fetchAuthSession","idToken","Error","signOut","console","query","URLSearchParams","window","queryData","value","key","state","CognitoPresenter","CognitoPresenterAbstraction","IdentityContext","LogInUseCase"],"mappings":";;;;;;AAoBA,MAAMA;IASF,YACYC,QAAmC,EACnCC,YAAoC,CAC9C;aAFUD,QAAQ,GAARA;aACAC,YAAY,GAAZA;aAVJ,SAAS,GAAc;aACvB,QAAQ,GAAoB;aAC5B,OAAO,GAAuB;aAC9B,eAAe,GAAG;aAClB,WAAW,GAAG;aACd,WAAW,GAAG;aACd,WAAW,GAAG;QAMlBC,mBAAmB,IAAI;IAC3B;IAEA,IAAI,KAAK;QACL,MAAMF,WAAW,IAAI,CAAC,QAAQ,CAAC,WAAW;QAE1C,OAAO;YACH,WAAW,IAAI,CAAC,SAAS;YACzB,iBAAiB,IAAI,CAAC,eAAe;YACrC,aAAa,IAAI,CAAC,WAAW;YAC7B,iBAAiBA,SAAS,eAAe;YAGzC,QAAQ;gBACJ,WAAW,IAAI,CAAC,WAAW;gBAC3B,SAAS,IAAI,CAAC,OAAO;YACzB;YACA,0BAA0B;gBACtB,WAAW,IAAI,CAAC,WAAW;gBAC3B,SAAS,IAAI,CAAC,OAAO;YACzB;YACA,uBAAuB;gBACnB,WAAW,IAAI,CAAC,WAAW;gBAC3B,SAAS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YAAY;gBACR,IAAI,CAAC,SAAS,GAAG;YACrB;QACJ,EAAE,OAAOK,OAAO;YACZY,QAAQ,KAAK,CAAC,yBAAyBZ;YACvCL,YAAY;gBACR,IAAI,CAAC,SAAS,GAAG;YACrB;QACJ,SAAU;YACNA,YAAY;gBACR,IAAI,CAAC,WAAW,GAAG;YACvB;QACJ;IACJ;IAEA,MAAc,WAA0B;QACpC,MAAMkB,QAAQ,IAAIC,gBAAgBC,OAAO,QAAQ,CAAC,MAAM;QACxD,MAAMC,YAAoC,CAAC;QAC3CH,MAAM,OAAO,CAAC,CAACI,OAAOC,MAASF,SAAS,CAACE,IAAI,GAAGD;QAChD,MAAM,EAAEE,KAAK,EAAE,GAAGH;QAElB,IAAIG,OAEA;QAGJ,OAAO,IAAI,CAAC,YAAY;IAC5B;IAEA,MAAc,eAA8B;QACxCxB,YAAY;YACR,IAAI,CAAC,eAAe,GAAG;QAC3B;QAEA,IAAI;YACA,MAAMY,UAAU,MAAMC;YACtB,IAAID,QAAQ,MAAM,EAEd,IAAI,CAAC,cAAc;QAE3B,EAAE,OAAM,CAER,SAAU;YACNZ,YAAY;gBACR,IAAI,CAAC,eAAe,GAAG;YAC3B;QACJ;IACJ;AACJ;AAEO,MAAMyB,oCAAmBC,iBAAAA,oBAAgD,CAAC;IAC7E,gBAAgBlC;IAChB,cAAc;QAACmC;QAAiBC;KAAa;AACjD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export type AuthState = "signIn" | "signedIn" | "signedOut" | "requestPasswordResetCode" | "passwordResetCodeSent" | "setNewPassword" | "requireNewPassword" | "confirmTotpCode" | "setupTotp";
|
|
1
|
+
export type AuthState = "signIn" | "signedIn" | "signedOut" | "requestPasswordResetCode" | "passwordResetCodeSent" | "setNewPassword" | "requireNewPassword";
|
|
3
2
|
export interface AuthDataVerified {
|
|
4
3
|
email?: string;
|
|
5
4
|
phone_number?: string;
|
|
@@ -28,10 +27,6 @@ export interface ICognitoInitParams {
|
|
|
28
27
|
export interface SignInVM {
|
|
29
28
|
isLoading: boolean;
|
|
30
29
|
message: AuthMessage | null;
|
|
31
|
-
title: string;
|
|
32
|
-
description: string | undefined;
|
|
33
|
-
allowCredentialsLogin: boolean;
|
|
34
|
-
federatedProviders: IFederatedProvider[];
|
|
35
30
|
}
|
|
36
31
|
export interface RequireNewPasswordVM {
|
|
37
32
|
isLoading: boolean;
|
|
@@ -49,16 +44,6 @@ export interface SetNewPasswordVM {
|
|
|
49
44
|
isLoading: boolean;
|
|
50
45
|
message: AuthMessage | null;
|
|
51
46
|
}
|
|
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
47
|
export interface ICognitoPresenter {
|
|
63
48
|
vm: {
|
|
64
49
|
authState: AuthState;
|
|
@@ -70,8 +55,6 @@ export interface ICognitoPresenter {
|
|
|
70
55
|
requestPasswordResetCode: RequestPasswordResetCodeVM;
|
|
71
56
|
passwordResetCodeSent: PasswordResetCodeSentVM;
|
|
72
57
|
setNewPassword: SetNewPasswordVM;
|
|
73
|
-
confirmTotpCode: ConfirmTotpCodeVM;
|
|
74
|
-
setupTotp: SetupTotpVM;
|
|
75
58
|
};
|
|
76
59
|
init(params: ICognitoInitParams): Promise<void>;
|
|
77
60
|
signIn(username: string, password: string): Promise<void>;
|
|
@@ -79,8 +62,6 @@ export interface ICognitoPresenter {
|
|
|
79
62
|
requestPasswordReset(username: string): Promise<void>;
|
|
80
63
|
resendPasswordResetCode(): Promise<void>;
|
|
81
64
|
confirmPasswordReset(code: string, password: string): Promise<void>;
|
|
82
|
-
confirmTotpCode(code: string): Promise<void>;
|
|
83
|
-
verifyTotpSetup(code: string): Promise<void>;
|
|
84
65
|
showSignIn(): void;
|
|
85
66
|
showRequestPasswordResetCode(): void;
|
|
86
67
|
showSetNewPassword(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/Cognito/abstractions.js","sources":["../../../../src/admin/presentation/Cognito/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\
|
|
1
|
+
{"version":3,"file":"admin/presentation/Cognito/abstractions.js","sources":["../../../../src/admin/presentation/Cognito/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport type AuthState =\n | \"signIn\"\n | \"signedIn\"\n | \"signedOut\"\n | \"requestPasswordResetCode\"\n | \"passwordResetCodeSent\"\n | \"setNewPassword\"\n | \"requireNewPassword\";\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}\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 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 };\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\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":";AAsGO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const Divider: (
|
|
3
|
-
original: () => React.JSX.Element;
|
|
4
|
-
originalName: string;
|
|
5
|
-
displayName: string;
|
|
6
|
-
} & {
|
|
7
|
-
original: (() => React.JSX.Element) & {
|
|
8
|
-
original: () => React.JSX.Element;
|
|
9
|
-
originalName: string;
|
|
10
|
-
displayName: string;
|
|
11
|
-
};
|
|
12
|
-
originalName: string;
|
|
13
|
-
displayName: string;
|
|
14
|
-
} & {
|
|
15
|
-
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(() => React.JSX.Element) & {
|
|
16
|
-
original: () => React.JSX.Element;
|
|
17
|
-
originalName: string;
|
|
18
|
-
displayName: string;
|
|
19
|
-
}>) => (props: unknown) => React.JSX.Element;
|
|
20
|
-
};
|
|
2
|
+
export declare const Divider: () => React.JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { Separator, Text } from "@webiny/admin-ui";
|
|
3
|
-
|
|
4
|
-
const Divider = makeDecoratable("CognitoDivider", ()=>/*#__PURE__*/ react.createElement("div", {
|
|
3
|
+
const Divider = ()=>/*#__PURE__*/ react.createElement("div", {
|
|
5
4
|
className: "relative my-lg"
|
|
6
5
|
}, /*#__PURE__*/ react.createElement("div", {
|
|
7
6
|
className: "absolute inset-0 flex items-center"
|
|
@@ -10,7 +9,7 @@ const Divider = makeDecoratable("CognitoDivider", ()=>/*#__PURE__*/ react.create
|
|
|
10
9
|
}, /*#__PURE__*/ react.createElement(Text, {
|
|
11
10
|
size: "sm",
|
|
12
11
|
className: "text-neutral-strong px-sm bg-neutral-base uppercase"
|
|
13
|
-
}, "Or continue with")))
|
|
12
|
+
}, "Or continue with")));
|
|
14
13
|
export { Divider };
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=Divider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/Cognito/components/Divider.js","sources":["../../../../../src/admin/presentation/Cognito/components/Divider.tsx"],"sourcesContent":["import React from \"react\";\nimport { Separator, Text } from \"@webiny/admin-ui\";\
|
|
1
|
+
{"version":3,"file":"admin/presentation/Cognito/components/Divider.js","sources":["../../../../../src/admin/presentation/Cognito/components/Divider.tsx"],"sourcesContent":["import React from \"react\";\nimport { Separator, Text } from \"@webiny/admin-ui\";\n\nexport const Divider = () => {\n return (\n <div className={\"relative my-lg\"}>\n <div className={\"absolute inset-0 flex items-center\"}>\n <Separator />\n </div>\n <div className={\"relative flex justify-center\"}>\n <Text size={\"sm\"} className={\"text-neutral-strong px-sm bg-neutral-base uppercase\"}>\n {\"Or continue with\"}\n </Text>\n </div>\n </div>\n );\n};\n"],"names":["Divider","Separator","Text"],"mappings":";;AAGO,MAAMA,UAAU,IACZ,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;qBACZ,oBAACC,WAASA,QAAAA,WAAAA,GAEd,oBAAC;QAAI,WAAW;qBACZ,oBAACC,MAAIA;QAAC,MAAM;QAAM,WAAW;OACxB"}
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
providers:
|
|
2
|
+
import type { FederatedIdentityProvider } from "../../../../admin/federatedIdentityProviders.js";
|
|
3
|
+
interface FederatedLoginProps {
|
|
4
|
+
providers: FederatedIdentityProvider[];
|
|
5
5
|
}
|
|
6
|
-
export declare const FederatedLogin: (
|
|
7
|
-
|
|
8
|
-
originalName: string;
|
|
9
|
-
displayName: string;
|
|
10
|
-
} & {
|
|
11
|
-
original: (({ providers }: FederatedLoginProps) => React.JSX.Element) & {
|
|
12
|
-
original: ({ providers }: FederatedLoginProps) => React.JSX.Element;
|
|
13
|
-
originalName: string;
|
|
14
|
-
displayName: string;
|
|
15
|
-
};
|
|
16
|
-
originalName: string;
|
|
17
|
-
displayName: string;
|
|
18
|
-
} & {
|
|
19
|
-
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ providers }: FederatedLoginProps) => React.JSX.Element) & {
|
|
20
|
-
original: ({ providers }: FederatedLoginProps) => React.JSX.Element;
|
|
21
|
-
originalName: string;
|
|
22
|
-
displayName: string;
|
|
23
|
-
}>) => (props: unknown) => React.JSX.Element;
|
|
24
|
-
};
|
|
6
|
+
export declare const FederatedLogin: ({ providers }: FederatedLoginProps) => React.JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { signInWithRedirect } from "aws-amplify/auth";
|
|
3
|
-
import { Button } from "@webiny/admin-ui";
|
|
4
|
-
import { makeDecoratable } from "@webiny/app-admin";
|
|
5
3
|
import { federatedIdentityProviders } from "../../../federatedIdentityProviders.js";
|
|
6
4
|
import { FederatedProviders } from "./FederatedProviders.js";
|
|
7
5
|
const builtInProviders = new Set([
|
|
@@ -10,8 +8,8 @@ const builtInProviders = new Set([
|
|
|
10
8
|
"Facebook",
|
|
11
9
|
"Google"
|
|
12
10
|
]);
|
|
13
|
-
const FederatedLogin =
|
|
14
|
-
const cognitoProviderName = federatedIdentityProviders[
|
|
11
|
+
const FederatedLogin = ({ providers })=>/*#__PURE__*/ react.createElement(FederatedProviders.Container, null, providers.map(({ name, component: Component })=>{
|
|
12
|
+
const cognitoProviderName = federatedIdentityProviders[name] ?? name;
|
|
15
13
|
const isBuiltIn = builtInProviders.has(cognitoProviderName);
|
|
16
14
|
const signIn = ()=>{
|
|
17
15
|
isBuiltIn ? signInWithRedirect({
|
|
@@ -22,22 +20,11 @@ const FederatedLogin = makeDecoratable("CognitoFederatedLogin", ({ providers })=
|
|
|
22
20
|
}
|
|
23
21
|
});
|
|
24
22
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
key: provider.name,
|
|
29
|
-
signIn: signIn
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return /*#__PURE__*/ react.createElement(Button, {
|
|
33
|
-
key: provider.name,
|
|
34
|
-
text: provider.label,
|
|
35
|
-
onClick: signIn,
|
|
36
|
-
style: {
|
|
37
|
-
width: "100%"
|
|
38
|
-
}
|
|
23
|
+
return /*#__PURE__*/ react.createElement(Component, {
|
|
24
|
+
key: name,
|
|
25
|
+
signIn: signIn
|
|
39
26
|
});
|
|
40
|
-
}))
|
|
27
|
+
}));
|
|
41
28
|
export { FederatedLogin };
|
|
42
29
|
|
|
43
30
|
//# sourceMappingURL=FederatedLogin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/Cognito/components/FederatedLogin.js","sources":["../../../../../src/admin/presentation/Cognito/components/FederatedLogin.tsx"],"sourcesContent":["import React from \"react\";\nimport { signInWithRedirect } from \"aws-amplify/auth\";\nimport {
|
|
1
|
+
{"version":3,"file":"admin/presentation/Cognito/components/FederatedLogin.js","sources":["../../../../../src/admin/presentation/Cognito/components/FederatedLogin.tsx"],"sourcesContent":["import React from \"react\";\nimport { signInWithRedirect } from \"aws-amplify/auth\";\nimport type { FederatedIdentityProvider } from \"~/admin/federatedIdentityProviders.js\";\nimport { federatedIdentityProviders } from \"~/admin/federatedIdentityProviders.js\";\nimport { FederatedProviders } from \"./FederatedProviders.js\";\n\ntype AuthProvider = \"Amazon\" | \"Apple\" | \"Facebook\" | \"Google\";\n\nconst builtInProviders = new Set<string>([\"Amazon\", \"Apple\", \"Facebook\", \"Google\"]);\n\ninterface FederatedLoginProps {\n providers: FederatedIdentityProvider[];\n}\n\nexport const FederatedLogin = ({ providers }: FederatedLoginProps) => {\n return (\n <FederatedProviders.Container>\n {providers.map(({ name, component: Component }) => {\n const cognitoProviderName = federatedIdentityProviders[name] ?? name;\n const isBuiltIn = builtInProviders.has(cognitoProviderName);\n\n const signIn = () => {\n if (isBuiltIn) {\n signInWithRedirect({\n provider: cognitoProviderName as AuthProvider\n });\n } else {\n signInWithRedirect({\n provider: { custom: cognitoProviderName }\n });\n }\n };\n\n return <Component key={name} signIn={signIn} />;\n })}\n </FederatedProviders.Container>\n );\n};\n"],"names":["builtInProviders","Set","FederatedLogin","providers","FederatedProviders","name","Component","cognitoProviderName","federatedIdentityProviders","isBuiltIn","signIn","signInWithRedirect"],"mappings":";;;;AAQA,MAAMA,mBAAmB,IAAIC,IAAY;IAAC;IAAU;IAAS;IAAY;CAAS;AAM3E,MAAMC,iBAAiB,CAAC,EAAEC,SAAS,EAAuB,GACtD,WAAP,GACI,oBAACC,mBAAmB,SAAS,QACxBD,UAAU,GAAG,CAAC,CAAC,EAAEE,IAAI,EAAE,WAAWC,SAAS,EAAE;QAC1C,MAAMC,sBAAsBC,0BAA0B,CAACH,KAAK,IAAIA;QAChE,MAAMI,YAAYT,iBAAiB,GAAG,CAACO;QAEvC,MAAMG,SAAS;YACPD,YACAE,mBAAmB;gBACf,UAAUJ;YACd,KAEAI,mBAAmB;gBACf,UAAU;oBAAE,QAAQJ;gBAAoB;YAC5C;QAER;QAEA,OAAO,WAAP,GAAO,oBAACD,WAAAA;YAAU,KAAKD;YAAM,QAAQK;;IACzC"}
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
interface FooterSignInProps {
|
|
3
3
|
onSignIn: () => void;
|
|
4
4
|
}
|
|
5
|
-
export declare const FooterSignIn: (
|
|
6
|
-
|
|
7
|
-
originalName: string;
|
|
8
|
-
displayName: string;
|
|
9
|
-
} & {
|
|
10
|
-
original: (({ onSignIn }: FooterSignInProps) => React.JSX.Element) & {
|
|
11
|
-
original: ({ onSignIn }: FooterSignInProps) => React.JSX.Element;
|
|
12
|
-
originalName: string;
|
|
13
|
-
displayName: string;
|
|
14
|
-
};
|
|
15
|
-
originalName: string;
|
|
16
|
-
displayName: string;
|
|
17
|
-
} & {
|
|
18
|
-
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ onSignIn }: FooterSignInProps) => React.JSX.Element) & {
|
|
19
|
-
original: ({ onSignIn }: FooterSignInProps) => React.JSX.Element;
|
|
20
|
-
originalName: string;
|
|
21
|
-
displayName: string;
|
|
22
|
-
}>) => (props: unknown) => React.JSX.Element;
|
|
23
|
-
};
|
|
5
|
+
export declare const FooterSignIn: ({ onSignIn }: FooterSignInProps) => React.JSX.Element;
|
|
6
|
+
export {};
|