@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/ui/views/Users/hooks/useUserForm.js","sources":["../../../../../../src/admin/ui/views/Users/hooks/useUserForm.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport
|
|
1
|
+
{"version":3,"file":"admin/ui/views/Users/hooks/useUserForm.js","sources":["../../../../../../src/admin/ui/views/Users/hooks/useUserForm.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport isEmpty from \"lodash/isEmpty.js\";\nimport omit from \"lodash/omit.js\";\nimport { useFeature } from \"@webiny/app\";\nimport { useRoute, useRouter } from \"@webiny/app-admin\";\nimport { GetUserFeature } from \"~/admin/features/users/getUser/index.js\";\nimport type { IGetUserGatewayResult } from \"~/admin/features/users/getUser/abstractions/GetUserGateway.js\";\nimport { CreateUserFeature } from \"~/admin/features/users/createUser/index.js\";\nimport { UpdateUserFeature } from \"~/admin/features/users/updateUser/index.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { useToast } from \"@webiny/admin-ui\";\n\ninterface SubmitUserCallableParams {\n id?: string;\n firstName: string;\n lastName: string;\n email: string;\n password?: string;\n avatar: {\n src?: string;\n };\n external?: boolean;\n}\n\ninterface SubmitUserCallable {\n (data: SubmitUserCallableParams): Promise<void>;\n}\n\nexport function useUserForm() {\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.Users.List);\n const toast = useToast();\n\n const { useCase: getUser } = useFeature(GetUserFeature);\n const { useCase: createUser } = useFeature(CreateUserFeature);\n const { useCase: updateUser } = useFeature(UpdateUserFeature);\n\n const id = route.params.id;\n const newUser = route.params.new === true;\n\n const [user, setUser] = useState<IGetUserGatewayResult | undefined>(undefined);\n const [userLoading, setUserLoading] = useState(false);\n const [mutationLoading, setMutationLoading] = useState(false);\n\n useEffect(() => {\n if (!id) {\n return;\n }\n setUserLoading(true);\n getUser\n .execute({ id })\n .then(data => {\n setUser(data);\n setUserLoading(false);\n })\n .catch(error => {\n goToRoute(Routes.Users.List);\n toast.showWarningToast({\n title: \"Error loading user profile\",\n description: error.message,\n duration: Infinity\n });\n setUserLoading(false);\n });\n }, [id]);\n\n const loading = userLoading || mutationLoading;\n\n const onSubmit = useCallback<SubmitUserCallable>(\n async data => {\n setMutationLoading(true);\n\n try {\n if (newUser) {\n const resultUser = await createUser.execute({ data });\n goToRoute(Routes.Users.List, { id: resultUser.id });\n } else {\n const { id: userId, ...rest } = data;\n await updateUser.execute({\n id: userId as string,\n data: omit(rest, [\"external\"])\n });\n }\n\n toast.showSuccessToast({\n title: \"User saved successfully.\"\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n toast.showWarningToast({\n title: \"Error updating user profile\",\n description: message,\n duration: Infinity\n });\n } finally {\n setMutationLoading(false);\n }\n },\n [id, newUser]\n );\n\n const showEmptyView = !newUser && !userLoading && isEmpty(user);\n\n return {\n id,\n loading,\n user,\n onSubmit,\n isNewUser: newUser,\n fullName: `${user?.firstName || \"\"} ${user?.lastName || \"\"}`.trim(),\n showEmptyView,\n createUser() {\n goToRoute(Routes.Users.List, { new: true });\n },\n cancelEditing() {\n goToRoute(Routes.Users.List);\n }\n };\n}\n"],"names":["useUserForm","goToRoute","useRouter","route","useRoute","Routes","toast","useToast","getUser","useFeature","GetUserFeature","createUser","CreateUserFeature","updateUser","UpdateUserFeature","id","newUser","user","setUser","useState","undefined","userLoading","setUserLoading","mutationLoading","setMutationLoading","useEffect","data","error","Infinity","loading","onSubmit","useCallback","resultUser","userId","rest","omit","message","Error","showEmptyView","isEmpty"],"mappings":";;;;;;;;;;AA4BO,SAASA;IACZ,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,O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AAC;gBACnB,OAAO;YACX;QACJ,EAAE,OAAOqB,OAAO;YACZ,MAAMS,UAAUT,iBAAiBU,QAAQV,MAAM,OAAO,GAAG;YACzDrB,MAAM,gBAAgB,CAAC;gBACnB,OAAO;gBACP,aAAa8B;gBACb,UAAUR;YACd;QACJ,SAAU;YACNJ,mBAAmB;QACvB;IACJ,GACA;QAACT;QAAIC;KAAQ;IAGjB,MAAMsB,gBAAgB,CAACtB,WAAW,CAACK,eAAekB,QAAQtB;IAE1D,OAAO;QACHF;QACAc;QACAZ;QACAa;QACA,WAAWd;QACX,UAAU,GAAGC,MAAM,aAAa,GAAG,CAAC,EAAEA,MAAM,YAAY,IAAI,CAAC,IAAI;QACjEqB;QACA;YACIrC,UAAUI,OAAO,KAAK,CAAC,IAAI,EAAE;gBAAE,KAAK;YAAK;QAC7C;QACA;YACIJ,UAAUI,OAAO,KAAK,CAAC,IAAI;QAC/B;IACJ;AACJ"}
|
|
@@ -14,12 +14,20 @@ class CognitoIdentityProviderImpl {
|
|
|
14
14
|
return issuer === this.issuer;
|
|
15
15
|
}
|
|
16
16
|
async getIdentity(token) {
|
|
17
|
-
const
|
|
17
|
+
const customIdentity = this.config ? await this.config.getIdentity(token) : null;
|
|
18
|
+
if (customIdentity) return {
|
|
19
|
+
...customIdentity,
|
|
20
|
+
type: "admin",
|
|
21
|
+
profile: {
|
|
22
|
+
...customIdentity,
|
|
23
|
+
external: false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
18
26
|
const customId = token["custom:id"];
|
|
19
27
|
const givenName = token["given_name"];
|
|
20
28
|
const familyName = token["family_name"];
|
|
21
29
|
const email = token["email"];
|
|
22
|
-
|
|
30
|
+
return {
|
|
23
31
|
id: customId || token.sub || "",
|
|
24
32
|
displayName: `${givenName || ""} ${familyName || ""}`.trim() || email || "Unknown User",
|
|
25
33
|
type: "admin",
|
|
@@ -27,19 +35,7 @@ class CognitoIdentityProviderImpl {
|
|
|
27
35
|
email: email || "",
|
|
28
36
|
firstName: givenName || "",
|
|
29
37
|
lastName: familyName || "",
|
|
30
|
-
external:
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const customIdentity = this.config ? await this.config.getIdentity(token) : null;
|
|
34
|
-
if (!customIdentity) return defaultIdentity;
|
|
35
|
-
return {
|
|
36
|
-
...defaultIdentity,
|
|
37
|
-
...customIdentity,
|
|
38
|
-
type: "admin",
|
|
39
|
-
profile: {
|
|
40
|
-
...defaultIdentity.profile,
|
|
41
|
-
...customIdentity.profile,
|
|
42
|
-
external: isFederated
|
|
38
|
+
external: false
|
|
43
39
|
}
|
|
44
40
|
};
|
|
45
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/CognitoIdp/CognitoIdentityProvider.js","sources":["../../../../src/api/features/CognitoIdp/CognitoIdentityProvider.ts"],"sourcesContent":["import { OidcIdentityProvider } from \"@webiny/api-core/idp\";\nimport { CognitoIdpConfig } from \"./abstractions.js\";\n\nclass CognitoIdentityProviderImpl implements OidcIdentityProvider.Interface {\n public clientId: string;\n public issuer: string;\n\n constructor(private config: CognitoIdpConfig.Interface | undefined) {\n const region = String(process.env.COGNITO_REGION);\n const userPoolId = String(process.env.COGNITO_USER_POOL_ID);\n this.clientId = String(process.env.COGNITO_CLIENT_ID);\n this.issuer = `https://cognito-idp.${region}.amazonaws.com/${userPoolId}`;\n }\n\n isApplicable(token: OidcIdentityProvider.JwtPayload) {\n const issuer = token.iss as string;\n if (!issuer) {\n return false;\n }\n\n return issuer === this.issuer;\n }\n\n async getIdentity(\n token: OidcIdentityProvider.JwtPayload\n ): Promise<OidcIdentityProvider.IdentityData> {\n const
|
|
1
|
+
{"version":3,"file":"api/features/CognitoIdp/CognitoIdentityProvider.js","sources":["../../../../src/api/features/CognitoIdp/CognitoIdentityProvider.ts"],"sourcesContent":["import { OidcIdentityProvider } from \"@webiny/api-core/idp\";\nimport { CognitoIdpConfig } from \"./abstractions.js\";\n\nclass CognitoIdentityProviderImpl implements OidcIdentityProvider.Interface {\n public clientId: string;\n public issuer: string;\n\n constructor(private config: CognitoIdpConfig.Interface | undefined) {\n const region = String(process.env.COGNITO_REGION);\n const userPoolId = String(process.env.COGNITO_USER_POOL_ID);\n this.clientId = String(process.env.COGNITO_CLIENT_ID);\n this.issuer = `https://cognito-idp.${region}.amazonaws.com/${userPoolId}`;\n }\n\n isApplicable(token: OidcIdentityProvider.JwtPayload) {\n const issuer = token.iss as string;\n if (!issuer) {\n return false;\n }\n\n return issuer === this.issuer;\n }\n\n async getIdentity(\n token: OidcIdentityProvider.JwtPayload\n ): Promise<OidcIdentityProvider.IdentityData> {\n const customIdentity = this.config ? await this.config.getIdentity(token) : null;\n\n if (customIdentity) {\n return {\n ...customIdentity,\n type: \"admin\",\n profile: {\n ...customIdentity,\n external: false\n }\n };\n }\n\n // Default identity\n const customId = token[\"custom:id\"] as string | undefined;\n const givenName = token[\"given_name\"] as string | undefined;\n const familyName = token[\"family_name\"] as string | undefined;\n const email = token[\"email\"] as string | undefined;\n\n return {\n id: customId || token.sub || \"\",\n displayName: `${givenName || \"\"} ${familyName || \"\"}`.trim() || email || \"Unknown User\",\n type: \"admin\",\n profile: {\n email: email || \"\",\n firstName: givenName || \"\",\n lastName: familyName || \"\",\n external: false\n }\n };\n }\n\n async verifyTokenClaims(token: OidcIdentityProvider.JwtPayload): Promise<void> {\n if (this.config?.verifyTokenClaims) {\n await this.config.verifyTokenClaims(token);\n }\n }\n}\n\nexport const CognitoIdentityProvider = OidcIdentityProvider.createImplementation({\n implementation: CognitoIdentityProviderImpl,\n dependencies: [[CognitoIdpConfig, { optional: true }]]\n});\n"],"names":["CognitoIdentityProviderImpl","config","region","String","process","userPoolId","token","issuer","customIdentity","customId","givenName","familyName","email","CognitoIdentityProvider","OidcIdentityProvider","CognitoIdpConfig"],"mappings":";;AAGA,MAAMA;IAIF,YAAoBC,MAA8C,CAAE;aAAhDA,MAAM,GAANA;QAChB,MAAMC,SAASC,OAAOC,QAAQ,GAAG,CAA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AK;SAAE;KAAC;AAC1D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type jwt from "jsonwebtoken";
|
|
2
2
|
import type { IdentityData } from "@webiny/api-core/idp";
|
|
3
3
|
export type CognitoIdentity = Omit<IdentityData, "type"> & {
|
|
4
|
-
profile
|
|
4
|
+
profile: Omit<IdentityData["profile"], "external">;
|
|
5
5
|
};
|
|
6
6
|
export interface ICognitoIdpConfig {
|
|
7
7
|
getIdentity(token: jwt.JwtPayload): Promise<CognitoIdentity> | CognitoIdentity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/CognitoIdp/abstractions.js","sources":["../../../../src/api/features/CognitoIdp/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type jwt from \"jsonwebtoken\";\nimport type { IdentityData } from \"@webiny/api-core/idp\";\n\nexport type CognitoIdentity = Omit<IdentityData, \"type\"> & {\n profile
|
|
1
|
+
{"version":3,"file":"api/features/CognitoIdp/abstractions.js","sources":["../../../../src/api/features/CognitoIdp/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type jwt from \"jsonwebtoken\";\nimport type { IdentityData } from \"@webiny/api-core/idp\";\n\nexport type CognitoIdentity = Omit<IdentityData, \"type\"> & {\n profile: Omit<IdentityData[\"profile\"], \"external\">;\n};\n\nexport interface ICognitoIdpConfig {\n getIdentity(token: jwt.JwtPayload): Promise<CognitoIdentity> | CognitoIdentity;\n verifyTokenClaims?(token: jwt.JwtPayload): Promise<void> | void;\n}\n\nexport const CognitoIdpConfig = createAbstraction<ICognitoIdpConfig>(\"CognitoIdpConfig\");\n\nexport namespace CognitoIdpConfig {\n export type Interface = ICognitoIdpConfig;\n export type IdentityData = CognitoIdentity;\n export type JwtPayload = jwt.JwtPayload;\n}\n"],"names":["CognitoIdpConfig","createAbstraction"],"mappings":";AAaO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CoreGraphQLSchemaFactory } from "@webiny/
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
2
|
declare class AdminUserSchemaImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
3
3
|
execute(builder: CoreGraphQLSchemaFactory.SchemaBuilder): CoreGraphQLSchemaFactory.Return;
|
|
4
4
|
}
|
|
5
5
|
export declare const AdminUsersSchema: typeof AdminUserSchemaImpl & {
|
|
6
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/
|
|
6
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
|
|
7
7
|
};
|
|
8
8
|
export {};
|
package/api/graphql/user.gql.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorResponse, NotFoundResponse, Response } from "@webiny/
|
|
2
|
-
import { CoreGraphQLSchemaFactory } from "@webiny/
|
|
1
|
+
import { ErrorResponse, NotFoundResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
2
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
3
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
4
|
import { GetUserUseCase } from "@webiny/api-core/features/users/GetUser/index.js";
|
|
5
5
|
import NotAuthorizedResponse from "@webiny/api-core/graphql/security/NotAuthorizedResponse.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/graphql/user.gql.js","sources":["../../../src/api/graphql/user.gql.ts"],"sourcesContent":["import { ErrorResponse, NotFoundResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetUserUseCase } from \"@webiny/api-core/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { CreateUserUseCase } from \"~/api/features/CreateUser/index.js\";\nimport { UpdateUserUseCase } from \"~/api/features/UpdateUser/index.js\";\nimport { DeleteUserUseCase } from \"~/api/features/DeleteUser/index.js\";\n\nclass AdminUserSchemaImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(\n builder: CoreGraphQLSchemaFactory.SchemaBuilder\n ): CoreGraphQLSchemaFactory.Return {\n builder.addTypeDefs(/* GraphQL */ `\n \"\"\"\n This input type is used by administrators to create other user's accounts within the same tenant.\n \"\"\"\n input AdminUsersCreateInput {\n email: String!\n firstName: String!\n lastName: String!\n password: String!\n avatar: JSON\n roles: [RefInput!]\n teams: [RefInput!]\n }\n\n \"\"\"\n This input type is used by administrators to update other user's accounts within the same tenant.\n \"\"\"\n input AdminUsersUpdateInput {\n email: String\n firstName: String\n lastName: String\n password: String\n avatar: JSON\n roles: [RefInput!]\n teams: [RefInput!]\n }\n\n \"\"\"\n This input type is used by the user who is updating his own account\n \"\"\"\n input AdminUsersCurrentUserInput {\n email: String\n firstName: String\n lastName: String\n password: String\n avatar: JSON\n }\n\n extend type AdminUsersMutation {\n updateCurrentUser(data: AdminUsersCurrentUserInput!): AdminUsersResponse\n\n createUser(data: AdminUsersCreateInput!): AdminUsersResponse\n\n updateUser(id: ID!, data: AdminUsersUpdateInput!): AdminUsersResponse\n\n deleteUser(id: ID!): AdminUsersBooleanResponse\n }\n `);\n\n builder.addResolver({\n path: \"AdminUsersMutation.updateCurrentUser\",\n dependencies: [IdentityContext, GetUserUseCase, UpdateUserUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n getUserUseCase: GetUserUseCase.Interface,\n updateUserUseCase: UpdateUserUseCase.Interface\n ) => {\n return async ({ args }) => {\n const identity = identityContext.getIdentity();\n if (!identity.isAdmin()) {\n return new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions for `adminUsers`.\n return await identityContext.withoutAuthorization(async () => {\n const getUserResult = await getUserUseCase.execute({ id: identity.id });\n if (getUserResult.isFail()) {\n // TODO: check if current identity belongs to a different tenant.\n // TODO: If so, switch to that other tenant, and update his profile there.\n return new NotFoundResponse(\"User not found!\");\n }\n\n const user = getUserResult.value;\n\n // TODO: UpdateCurrentUser should be a dedicated use case\n const updateResult = await updateUserUseCase.execute(user.id, args.data);\n if (updateResult.isFail()) {\n return new ErrorResponse({\n message: updateResult.error.message,\n code: updateResult.error.code,\n data: updateResult.error.data\n });\n }\n\n return new Response(updateResult.value);\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersMutation.createUser\",\n dependencies: [CreateUserUseCase],\n resolver: (createUserUseCase: CreateUserUseCase.Interface) => {\n return async ({ args }) => {\n const result = await createUserUseCase.execute(args.data);\n if (result.isFail()) {\n return new ErrorResponse({\n message: result.error.message,\n code: result.error.code,\n data: result.error.data\n });\n }\n\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersMutation.updateUser\",\n dependencies: [UpdateUserUseCase, IdentityContext],\n resolver: (\n updateUserUseCase: UpdateUserUseCase.Interface,\n identityContext: IdentityContext.Interface\n ) => {\n return async ({ args }) => {\n if (args.id === identityContext.getIdentity().id) {\n return new ErrorResponse({\n message:\n \"You're not allowed to update your own account using this API.\",\n code: \"AdminUser/GraphQL/UpdateSelf\"\n });\n }\n\n const result = await updateUserUseCase.execute(args.id, args.data);\n if (result.isFail()) {\n return new ErrorResponse({\n message: result.error.message,\n code: result.error.code\n });\n }\n\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersMutation.deleteUser\",\n dependencies: [DeleteUserUseCase],\n resolver: (deleteUserUseCase: DeleteUserUseCase.Interface) => {\n return async ({ args }) => {\n const result = await deleteUserUseCase.execute(args.id);\n if (result.isFail()) {\n return new ErrorResponse({\n message: result.error.message,\n code: result.error.code,\n data: result.error.data\n });\n }\n\n return new Response(true);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const AdminUsersSchema = CoreGraphQLSchemaFactory.createImplementation({\n implementation: AdminUserSchemaImpl,\n dependencies: []\n});\n"],"names":["AdminUserSchemaImpl","builder","IdentityContext","GetUserUseCase","UpdateUserUseCase","identityContext","getUserUseCase","updateUserUseCase","args","identity","NotAuthorizedResponse","getUserResult","NotFoundResponse","user","updateResult","ErrorResponse","Response","CreateUserUseCase","createUserUseCase","result","DeleteUserUseCase","deleteUserUseCase","AdminUsersSchema","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;AASA,MAAMA;IACF,MAAM,QACFC,OAA+C,EAChB;QAC/BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+CnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;gBAAiBC;gBAAgBC;aAAkB;YAClE,UAAU,CACNC,iBACAC,gBACAC,oBAEO,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,WAAWJ,gBAAgB,WAAW;oBAC5C,IAAI,CAACI,SAAS,OAAO,IACjB,OAAO,IAAIC;oBAIf,OAAO,MAAML,gBAAgB,oBAAoB,CAAC;wBAC9C,MAAMM,gBAAgB,MAAML,eAAe,OAAO,CAAC;4BAAE,IAAIG,SAAS,EAAE;wBAAC;wBACrE,IAAIE,cAAc,MAAM,IAGpB,OAAO,IAAIC,iBAAiB;wBAGhC,MAAMC,OAAOF,cAAc,KAAK;wBAGhC,MAAMG,eAAe,MAAMP,kBAAkB,OAAO,CAACM,KAAK,EAAE,EAAEL,KAAK,IAAI;wBACvE,IAAIM,aAAa,MAAM,IACnB,OAAO,IAAIC,cAAc;4BACrB,SAASD,aAAa,KAAK,CAAC,OAAO;4BACnC,MAAMA,aAAa,KAAK,CAAC,IAAI;4BAC7B,MAAMA,aAAa,KAAK,CAAC,IAAI;wBACjC;wBAGJ,OAAO,IAAIE,SAASF,aAAa,KAAK;oBAC1C;gBACJ;QAER;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,MAAMA,OAAO,KAAK,CAAC,IAAI;oBAC3B;oBAGJ,OAAO,IAAIH,SAAS;gBACxB;QAER;QAEA,OAAOf;IACX;AACJ;AAEO,MAAMqB,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBvB;IAChB,cAAc,EAAE;AACpB"}
|
|
1
|
+
{"version":3,"file":"api/graphql/user.gql.js","sources":["../../../src/api/graphql/user.gql.ts"],"sourcesContent":["import { ErrorResponse, NotFoundResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetUserUseCase } from \"@webiny/api-core/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { CreateUserUseCase } from \"~/api/features/CreateUser/index.js\";\nimport { UpdateUserUseCase } from \"~/api/features/UpdateUser/index.js\";\nimport { DeleteUserUseCase } from \"~/api/features/DeleteUser/index.js\";\n\nclass AdminUserSchemaImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(\n builder: CoreGraphQLSchemaFactory.SchemaBuilder\n ): CoreGraphQLSchemaFactory.Return {\n builder.addTypeDefs(/* GraphQL */ `\n \"\"\"\n This input type is used by administrators to create other user's accounts within the same tenant.\n \"\"\"\n input AdminUsersCreateInput {\n email: String!\n firstName: String!\n lastName: String!\n password: String!\n avatar: JSON\n roles: [RefInput!]\n teams: [RefInput!]\n }\n\n \"\"\"\n This input type is used by administrators to update other user's accounts within the same tenant.\n \"\"\"\n input AdminUsersUpdateInput {\n email: String\n firstName: String\n lastName: String\n password: String\n avatar: JSON\n roles: [RefInput!]\n teams: [RefInput!]\n }\n\n \"\"\"\n This input type is used by the user who is updating his own account\n \"\"\"\n input AdminUsersCurrentUserInput {\n email: String\n firstName: String\n lastName: String\n password: String\n avatar: JSON\n }\n\n extend type AdminUsersMutation {\n updateCurrentUser(data: AdminUsersCurrentUserInput!): AdminUsersResponse\n\n createUser(data: AdminUsersCreateInput!): AdminUsersResponse\n\n updateUser(id: ID!, data: AdminUsersUpdateInput!): AdminUsersResponse\n\n deleteUser(id: ID!): AdminUsersBooleanResponse\n }\n `);\n\n builder.addResolver({\n path: \"AdminUsersMutation.updateCurrentUser\",\n dependencies: [IdentityContext, GetUserUseCase, UpdateUserUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n getUserUseCase: GetUserUseCase.Interface,\n updateUserUseCase: UpdateUserUseCase.Interface\n ) => {\n return async ({ args }) => {\n const identity = identityContext.getIdentity();\n if (!identity.isAdmin()) {\n return new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions for `adminUsers`.\n return await identityContext.withoutAuthorization(async () => {\n const getUserResult = await getUserUseCase.execute({ id: identity.id });\n if (getUserResult.isFail()) {\n // TODO: check if current identity belongs to a different tenant.\n // TODO: If so, switch to that other tenant, and update his profile there.\n return new NotFoundResponse(\"User not found!\");\n }\n\n const user = getUserResult.value;\n\n // TODO: UpdateCurrentUser should be a dedicated use case\n const updateResult = await updateUserUseCase.execute(user.id, args.data);\n if (updateResult.isFail()) {\n return new ErrorResponse({\n message: updateResult.error.message,\n code: updateResult.error.code,\n data: updateResult.error.data\n });\n }\n\n return new Response(updateResult.value);\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersMutation.createUser\",\n dependencies: [CreateUserUseCase],\n resolver: (createUserUseCase: CreateUserUseCase.Interface) => {\n return async ({ args }) => {\n const result = await createUserUseCase.execute(args.data);\n if (result.isFail()) {\n return new ErrorResponse({\n message: result.error.message,\n code: result.error.code,\n data: result.error.data\n });\n }\n\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersMutation.updateUser\",\n dependencies: [UpdateUserUseCase, IdentityContext],\n resolver: (\n updateUserUseCase: UpdateUserUseCase.Interface,\n identityContext: IdentityContext.Interface\n ) => {\n return async ({ args }) => {\n if (args.id === identityContext.getIdentity().id) {\n return new ErrorResponse({\n message:\n \"You're not allowed to update your own account using this API.\",\n code: \"AdminUser/GraphQL/UpdateSelf\"\n });\n }\n\n const result = await updateUserUseCase.execute(args.id, args.data);\n if (result.isFail()) {\n return new ErrorResponse({\n message: result.error.message,\n code: result.error.code\n });\n }\n\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersMutation.deleteUser\",\n dependencies: [DeleteUserUseCase],\n resolver: (deleteUserUseCase: DeleteUserUseCase.Interface) => {\n return async ({ args }) => {\n const result = await deleteUserUseCase.execute(args.id);\n if (result.isFail()) {\n return new ErrorResponse({\n message: result.error.message,\n code: result.error.code,\n data: result.error.data\n });\n }\n\n return new Response(true);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const AdminUsersSchema = CoreGraphQLSchemaFactory.createImplementation({\n implementation: AdminUserSchemaImpl,\n dependencies: []\n});\n"],"names":["AdminUserSchemaImpl","builder","IdentityContext","GetUserUseCase","UpdateUserUseCase","identityContext","getUserUseCase","updateUserUseCase","args","identity","NotAuthorizedResponse","getUserResult","NotFoundResponse","user","updateResult","ErrorResponse","Response","CreateUserUseCase","createUserUseCase","result","DeleteUserUseCase","deleteUserUseCase","AdminUsersSchema","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;AASA,MAAMA;IACF,MAAM,QACFC,OAA+C,EAChB;QAC/BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+CnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;gBAAiBC;gBAAgBC;aAAkB;YAClE,UAAU,CACNC,iBACAC,gBACAC,oBAEO,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,WAAWJ,gBAAgB,WAAW;oBAC5C,IAAI,CAACI,SAAS,OAAO,IACjB,OAAO,IAAIC;oBAIf,OAAO,MAAML,gBAAgB,oBAAoB,CA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IAAIW,OAAO,MAAM,IACb,OAAO,IAAIJ,cAAc;wBACrB,SAASI,OAAO,KAAK,CAAC,OAAO;wBAC7B,MAAMA,OAAO,KAAK,CAAC,IAAI;oBAC3B;oBAGJ,OAAO,IAAIH,SAASG,OAAO,KAAK;gBACpC;QAER;QAEAlB,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACmB;aAAkB;YACjC,UAAU,CAACC,oBACA,OAAO,EAAEb,IAAI,EAAE;oBAClB,MAAMW,SAAS,MAAME,kBAAkB,OAAO,CAACb,KAAK,EAAE;oBACtD,IAAIW,OAAO,MAAM,IACb,OAAO,IAAIJ,cAAc;wBACrB,SAASI,OAAO,KAAK,CAAC,OAAO;wBAC7B,MAAMA,OAAO,KAAK,CAAC,IAAI;wBACvB,MAAMA,OAAO,KAAK,CAAC,IAAI;oBAC3B;oBAGJ,OAAO,IAAIH,SAAS;gBACxB;QAER;QAEA,OAAOf;IACX;AACJ;AAEO,MAAMqB,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBvB;IAChB,cAAc,EAAE;AACpB"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cognito",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|
|
9
|
-
"
|
|
10
|
-
"./admin": "./admin/index.js"
|
|
9
|
+
"./*": "./*"
|
|
11
10
|
},
|
|
12
11
|
"description": "Security plugins for Cognito",
|
|
13
12
|
"author": "Webiny Ltd.",
|
|
14
13
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@webiny/
|
|
17
|
-
"@webiny/api-
|
|
18
|
-
"@webiny/app": "6.
|
|
19
|
-
"@webiny/app-admin": "6.
|
|
20
|
-
"@webiny/aws-sdk": "6.
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"
|
|
28
|
-
"@webiny/react-properties": "6.4.5-beta.0",
|
|
29
|
-
"@webiny/validation": "6.4.5-beta.0",
|
|
30
|
-
"aws-amplify": "6.18.0",
|
|
14
|
+
"@webiny/admin-ui": "6.6.0-alpha.0",
|
|
15
|
+
"@webiny/api-core": "6.6.0-alpha.0",
|
|
16
|
+
"@webiny/api-graphql": "6.6.0-alpha.0",
|
|
17
|
+
"@webiny/app": "6.6.0-alpha.0",
|
|
18
|
+
"@webiny/app-admin": "6.6.0-alpha.0",
|
|
19
|
+
"@webiny/aws-sdk": "6.6.0-alpha.0",
|
|
20
|
+
"@webiny/feature": "6.6.0-alpha.0",
|
|
21
|
+
"@webiny/form": "6.6.0-alpha.0",
|
|
22
|
+
"@webiny/icons": "6.6.0-alpha.0",
|
|
23
|
+
"@webiny/project": "6.6.0-alpha.0",
|
|
24
|
+
"@webiny/project-aws": "6.6.0-alpha.0",
|
|
25
|
+
"@webiny/validation": "6.6.0-alpha.0",
|
|
26
|
+
"aws-amplify": "6.19.0",
|
|
31
27
|
"graphql": "16.14.2",
|
|
32
|
-
"graphql-tag": "2.12.7",
|
|
33
28
|
"jsonwebtoken": "9.0.3",
|
|
34
29
|
"lodash": "4.18.1",
|
|
35
30
|
"mobx": "6.16.1",
|
|
@@ -39,9 +34,9 @@
|
|
|
39
34
|
},
|
|
40
35
|
"devDependencies": {
|
|
41
36
|
"@types/react": "18.3.31",
|
|
42
|
-
"@webiny/build-tools": "6.
|
|
43
|
-
"@webiny/project-utils": "6.
|
|
44
|
-
"@webiny/wcp": "6.
|
|
37
|
+
"@webiny/build-tools": "6.6.0-alpha.0",
|
|
38
|
+
"@webiny/project-utils": "6.6.0-alpha.0",
|
|
39
|
+
"@webiny/wcp": "6.6.0-alpha.0",
|
|
45
40
|
"vitest": "4.1.10"
|
|
46
41
|
},
|
|
47
42
|
"publishConfig": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BuildParams } from "@webiny/app-admin/features/buildParams/index.js";
|
|
2
|
-
import { type ICognitoSignInConfig } from "./presentation/Cognito/CognitoSignInConfig.js";
|
|
3
|
-
declare class DefaultCognitoSignInConfigImpl implements ICognitoSignInConfig {
|
|
4
|
-
private buildParams;
|
|
5
|
-
constructor(buildParams: BuildParams.Interface);
|
|
6
|
-
getConfig(): Promise<{
|
|
7
|
-
oauth: {
|
|
8
|
-
scopes: string[];
|
|
9
|
-
redirectSignIn: string[];
|
|
10
|
-
redirectSignOut: string[];
|
|
11
|
-
responseType: "code" | "token";
|
|
12
|
-
};
|
|
13
|
-
allowCredentialsLogin: boolean;
|
|
14
|
-
providers: {
|
|
15
|
-
name: string;
|
|
16
|
-
label: string;
|
|
17
|
-
}[];
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export declare const DefaultCognitoSignInConfig: typeof DefaultCognitoSignInConfigImpl & {
|
|
21
|
-
__abstraction: import("@webiny/di").Abstraction<ICognitoSignInConfig>;
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BuildParams } from "@webiny/app-admin/features/buildParams/index.js";
|
|
2
|
-
import { CognitoSignInConfig } from "./presentation/Cognito/CognitoSignInConfig.js";
|
|
3
|
-
class DefaultCognitoSignInConfigImpl {
|
|
4
|
-
constructor(buildParams){
|
|
5
|
-
this.buildParams = buildParams;
|
|
6
|
-
}
|
|
7
|
-
async getConfig() {
|
|
8
|
-
const config = this.buildParams.get("cognitoFederation");
|
|
9
|
-
if (!config) return {
|
|
10
|
-
oauth: {
|
|
11
|
-
scopes: [
|
|
12
|
-
"profile",
|
|
13
|
-
"email",
|
|
14
|
-
"openid"
|
|
15
|
-
],
|
|
16
|
-
redirectSignIn: [
|
|
17
|
-
window.location.origin
|
|
18
|
-
],
|
|
19
|
-
redirectSignOut: [
|
|
20
|
-
window.location.origin
|
|
21
|
-
],
|
|
22
|
-
responseType: "code"
|
|
23
|
-
},
|
|
24
|
-
allowCredentialsLogin: true,
|
|
25
|
-
providers: []
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
oauth: {
|
|
29
|
-
scopes: [
|
|
30
|
-
"profile",
|
|
31
|
-
"email",
|
|
32
|
-
"openid"
|
|
33
|
-
],
|
|
34
|
-
redirectSignIn: config.callbackUrls,
|
|
35
|
-
redirectSignOut: config.logoutUrls,
|
|
36
|
-
responseType: config.responseType
|
|
37
|
-
},
|
|
38
|
-
allowCredentialsLogin: config.allowCredentialsLogin,
|
|
39
|
-
providers: config.providers
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const DefaultCognitoSignInConfig = CognitoSignInConfig.createImplementation({
|
|
44
|
-
implementation: DefaultCognitoSignInConfigImpl,
|
|
45
|
-
dependencies: [
|
|
46
|
-
BuildParams
|
|
47
|
-
]
|
|
48
|
-
});
|
|
49
|
-
export { DefaultCognitoSignInConfig };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=DefaultCognitoSignInConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin/DefaultCognitoSignInConfig.js","sources":["../../src/admin/DefaultCognitoSignInConfig.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/app-admin/features/buildParams/index.js\";\nimport {\n CognitoSignInConfig,\n type ICognitoSignInConfig\n} from \"./presentation/Cognito/CognitoSignInConfig.js\";\n\ninterface FederationBuildParam {\n callbackUrls: string[];\n logoutUrls: string[];\n responseType: \"code\" | \"token\";\n allowCredentialsLogin: boolean;\n providers: { name: string; label: string }[];\n}\n\nclass DefaultCognitoSignInConfigImpl implements ICognitoSignInConfig {\n constructor(private buildParams: BuildParams.Interface) {}\n\n async getConfig() {\n const config = this.buildParams.get<FederationBuildParam>(\"cognitoFederation\");\n\n if (!config) {\n return {\n oauth: {\n scopes: [\"profile\", \"email\", \"openid\"],\n redirectSignIn: [window.location.origin],\n redirectSignOut: [window.location.origin],\n responseType: \"code\" as const\n },\n allowCredentialsLogin: true,\n providers: []\n };\n }\n\n return {\n oauth: {\n scopes: [\"profile\", \"email\", \"openid\"],\n redirectSignIn: config.callbackUrls,\n redirectSignOut: config.logoutUrls,\n responseType: config.responseType\n },\n allowCredentialsLogin: config.allowCredentialsLogin,\n providers: config.providers\n };\n }\n}\n\nexport const DefaultCognitoSignInConfig = CognitoSignInConfig.createImplementation({\n implementation: DefaultCognitoSignInConfigImpl,\n dependencies: [BuildParams]\n});\n"],"names":["DefaultCognitoSignInConfigImpl","buildParams","config","window","DefaultCognitoSignInConfig","CognitoSignInConfig","BuildParams"],"mappings":";;AAcA,MAAMA;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,MAAM,YAAY;QACd,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,GAAG,CAAuB;QAE1D,IAAI,CAACA,QACD,OAAO;YACH,OAAO;gBACH,QAAQ;oBAAC;oBAAW;oBAAS;iBAAS;gBACtC,gBAAgB;oBAACC,OAAO,QAAQ,CAAC,MAAM;iBAAC;gBACxC,iBAAiB;oBAACA,OAAO,QAAQ,CAAC,MAAM;iBAAC;gBACzC,cAAc;YAClB;YACA,uBAAuB;YACvB,WAAW,EAAE;QACjB;QAGJ,OAAO;YACH,OAAO;gBACH,QAAQ;oBAAC;oBAAW;oBAAS;iBAAS;gBACtC,gBAAgBD,OAAO,YAAY;gBACnC,iBAAiBA,OAAO,UAAU;gBAClC,cAAcA,OAAO,YAAY;YACrC;YACA,uBAAuBA,OAAO,qBAAqB;YACnD,WAAWA,OAAO,SAAS;QAC/B;IACJ;AACJ;AAEO,MAAME,6BAA6BC,oBAAoB,oBAAoB,CAAC;IAC/E,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
package/admin/SignInExtension.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { RegisterFeature } from "@webiny/app-admin";
|
|
3
|
-
import { CognitoSignInFeature } from "./presentation/Cognito/signInFeature.js";
|
|
4
|
-
const SignInExtension = ()=>/*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
5
|
-
feature: CognitoSignInFeature
|
|
6
|
-
});
|
|
7
|
-
export { SignInExtension };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=SignInExtension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin/SignInExtension.js","sources":["../../src/admin/SignInExtension.tsx"],"sourcesContent":["import React from \"react\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { CognitoSignInFeature } from \"./presentation/Cognito/signInFeature.js\";\n\nexport const SignInExtension = () => {\n return <RegisterFeature feature={CognitoSignInFeature} />;\n};\n"],"names":["SignInExtension","RegisterFeature","CognitoSignInFeature"],"mappings":";;;AAIO,MAAMA,kBAAkB,IACpB,WAAP,GAAO,oBAACC,iBAAeA;QAAC,SAASC"}
|
package/admin/index.d.ts
DELETED
package/admin/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/Cognito/components/ConfirmTotpCode.js","sources":["../../../../../src/admin/presentation/Cognito/components/ConfirmTotpCode.tsx"],"sourcesContent":["import React from \"react\";\nimport { Button, Grid, Input, Alert } from \"@webiny/admin-ui\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { Form, Bind } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport { View } from \"./View.js\";\nimport type { ConfirmTotpCodeVM } from \"~/admin/presentation/Cognito/abstractions.js\";\nimport { FooterSignIn } from \"~/admin/presentation/Cognito/components/FooterSignIn.js\";\n\nexport interface ConfirmTotpCodeProps {\n vm: ConfirmTotpCodeVM;\n onSubmit: (code: string) => void;\n onCancel: () => void;\n}\n\nexport const ConfirmTotpCode = makeDecoratable(\n \"CognitoConfirmTotpCode\",\n (props: ConfirmTotpCodeProps) => {\n const { vm, onSubmit, onCancel } = props;\n\n return (\n <View.Container>\n <Form<{ code: string }> onSubmit={data => onSubmit(data.code)} submitOnEnter>\n {({ submit }) => (\n <View.Content>\n <View.Title\n title={\"Two-factor authentication\"}\n description={\"Enter the 6-digit code from your authenticator app.\"}\n />\n\n {vm.message && (\n <div className={\"mb-lg\"}>\n <Alert title={vm.message.title} type={vm.message.type}>\n {vm.message.text}\n </Alert>\n </div>\n )}\n\n <Grid>\n <Grid.Column span={12}>\n <Bind name=\"code\" validators={validation.create(\"required\")}>\n <Input\n label={\"Verification Code\"}\n autoComplete={\"one-time-code\"}\n inputMode={\"numeric\"}\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <div className={\"flex items-center justify-between\"}>\n <FooterSignIn onSignIn={onCancel} />\n <Button\n text={\"Verify\"}\n onClick={submit}\n containerClassName={\"ml-auto\"}\n disabled={vm.isLoading}\n />\n </div>\n </Grid.Column>\n </Grid>\n </View.Content>\n )}\n </Form>\n </View.Container>\n );\n }\n);\n"],"names":["ConfirmTotpCode","makeDecoratable","props","vm","onSubmit","onCancel","View","Form","data","submit","Alert","Grid","Bind","validation","Input","FooterSignIn","Button"],"mappings":";;;;;;;AAeO,MAAMA,kBAAkBC,gBAC3B,0BACA,CAACC;IACG,MAAM,EAAEC,EAAE,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IAEnC,OAAO,WAAP,GACI,oBAACI,KAAK,SAAS,sBACX,oBAACC,MAAIA;QAAmB,UAAUC,CAAAA,OAAQJ,SAASI,KAAK,IAAI;QAAG;OAC1D,CAAC,EAAEC,MAAM,EAAE,iBACR,oBAACH,KAAK,OAAO,sBACT,oBAACA,KAAK,KAAK;YACP,OAAO;YACP,aAAa;YAGhBH,GAAG,OAAO,IAAI,WAAJ,GACP,oBAAC;YAAI,WAAW;yBACZ,oBAACO,OAAKA;YAAC,OAAOP,GAAG,OAAO,CAAC,KAAK;YAAE,MAAMA,GAAG,OAAO,CAAC,IAAI;WAChDA,GAAG,OAAO,CAAC,IAAI,kBAK5B,oBAACQ,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;YAAC,MAAM;yBACf,oBAACC,MAAIA;YAAC,MAAK;YAAO,YAAYC,WAAW,MAAM,CAAC;yBAC5C,oBAACC,OAAKA;YACF,OAAO;YACP,cAAc;YACd,WAAW;4BAIvB,oBAACH,KAAK,MAAM;YAAC,MAAM;yBACf,oBAAC;YAAI,WAAW;yBACZ,oBAACI,cAAYA;YAAC,UAAUV;0BACxB,oBAACW,QAAMA;YACH,MAAM;YACN,SAASP;YACT,oBAAoB;YACpB,UAAUN,GAAG,SAAS;;AAU9D"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { SetupTotpVM } from "../../../../admin/presentation/Cognito/abstractions.js";
|
|
3
|
-
export interface SetupTotpProps {
|
|
4
|
-
vm: SetupTotpVM;
|
|
5
|
-
onSubmit: (code: string) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare const SetupTotp: ((props: SetupTotpProps) => React.JSX.Element) & {
|
|
8
|
-
original: (props: SetupTotpProps) => React.JSX.Element;
|
|
9
|
-
originalName: string;
|
|
10
|
-
displayName: string;
|
|
11
|
-
} & {
|
|
12
|
-
original: ((props: SetupTotpProps) => React.JSX.Element) & {
|
|
13
|
-
original: (props: SetupTotpProps) => React.JSX.Element;
|
|
14
|
-
originalName: string;
|
|
15
|
-
displayName: string;
|
|
16
|
-
};
|
|
17
|
-
originalName: string;
|
|
18
|
-
displayName: string;
|
|
19
|
-
} & {
|
|
20
|
-
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<((props: SetupTotpProps) => React.JSX.Element) & {
|
|
21
|
-
original: (props: SetupTotpProps) => React.JSX.Element;
|
|
22
|
-
originalName: string;
|
|
23
|
-
displayName: string;
|
|
24
|
-
}>) => (props: unknown) => React.JSX.Element;
|
|
25
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { Alert, Button, Grid, Input, Text } 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
|
-
const SetupTotp = makeDecoratable("CognitoSetupTotp", (props)=>{
|
|
8
|
-
const { vm, onSubmit } = props;
|
|
9
|
-
return /*#__PURE__*/ react.createElement(View.Container, null, /*#__PURE__*/ react.createElement(Form, {
|
|
10
|
-
onSubmit: (data)=>onSubmit(data.code),
|
|
11
|
-
submitOnEnter: true
|
|
12
|
-
}, ({ submit })=>/*#__PURE__*/ react.createElement(View.Content, null, /*#__PURE__*/ react.createElement(View.Title, {
|
|
13
|
-
title: "Set up two-factor authentication",
|
|
14
|
-
description: "Scan the QR code with your authenticator app (Google Authenticator, Authy, etc.), then enter the 6-digit code to verify."
|
|
15
|
-
}), vm.message && /*#__PURE__*/ react.createElement("div", {
|
|
16
|
-
className: "mb-lg"
|
|
17
|
-
}, /*#__PURE__*/ react.createElement(Alert, {
|
|
18
|
-
title: vm.message.title,
|
|
19
|
-
type: vm.message.type
|
|
20
|
-
}, vm.message.text)), /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
21
|
-
span: 12
|
|
22
|
-
}, /*#__PURE__*/ react.createElement("div", {
|
|
23
|
-
className: "flex justify-center my-md"
|
|
24
|
-
}, /*#__PURE__*/ react.createElement("img", {
|
|
25
|
-
src: `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(vm.qrCodeUri)}`,
|
|
26
|
-
alt: "TOTP QR Code",
|
|
27
|
-
width: 200,
|
|
28
|
-
height: 200
|
|
29
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
30
|
-
span: 12
|
|
31
|
-
}, /*#__PURE__*/ react.createElement(Text, {
|
|
32
|
-
size: "sm",
|
|
33
|
-
className: "text-neutral-strong"
|
|
34
|
-
}, "Can't scan the code? Enter this key manually:"), /*#__PURE__*/ react.createElement(Text, {
|
|
35
|
-
as: "div",
|
|
36
|
-
size: "sm",
|
|
37
|
-
className: "font-mono mt-xs select-all break-all"
|
|
38
|
-
}, vm.sharedSecret)), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
39
|
-
span: 12
|
|
40
|
-
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
41
|
-
name: "code",
|
|
42
|
-
validators: validation.create("required")
|
|
43
|
-
}, /*#__PURE__*/ react.createElement(Input, {
|
|
44
|
-
label: "Verification Code",
|
|
45
|
-
description: "Enter the 6-digit code from your authenticator app.",
|
|
46
|
-
autoComplete: "one-time-code",
|
|
47
|
-
inputMode: "numeric"
|
|
48
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
49
|
-
span: 12
|
|
50
|
-
}, /*#__PURE__*/ react.createElement("div", {
|
|
51
|
-
className: "flex justify-end"
|
|
52
|
-
}, /*#__PURE__*/ react.createElement(Button, {
|
|
53
|
-
text: "Verify & Enable",
|
|
54
|
-
onClick: submit,
|
|
55
|
-
disabled: vm.isLoading
|
|
56
|
-
})))))));
|
|
57
|
-
});
|
|
58
|
-
export { SetupTotp };
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=SetupTotp.js.map
|