@contember/engine-tenant-api 2.0.0-alpha.14 → 2.0.0-alpha.16
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/dist/development/index.cjs +18 -6
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +20 -8
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/TenantContainer.cjs +7 -1
- package/dist/development/src/TenantContainer.cjs.map +1 -1
- package/dist/development/src/TenantContainer.js +7 -1
- package/dist/development/src/TenantContainer.js.map +1 -1
- package/dist/development/src/migrations/2024-08-26-120000-passwordless.cjs +31 -0
- package/dist/development/src/migrations/2024-08-26-120000-passwordless.cjs.map +1 -0
- package/dist/development/src/migrations/2024-08-26-120000-passwordless.js +32 -0
- package/dist/development/src/migrations/2024-08-26-120000-passwordless.js.map +1 -0
- package/dist/development/src/migrations/runner.cjs +3 -1
- package/dist/development/src/migrations/runner.cjs.map +1 -1
- package/dist/development/src/migrations/runner.js +3 -1
- package/dist/development/src/migrations/runner.js.map +1 -1
- package/dist/development/src/migrations/snapshot.cjs +33 -5
- package/dist/development/src/migrations/snapshot.cjs.map +1 -1
- package/dist/development/src/migrations/snapshot.js +33 -5
- package/dist/development/src/migrations/snapshot.js.map +1 -1
- package/dist/development/src/model/authorization/PermissionActions.cjs +5 -0
- package/dist/development/src/model/authorization/PermissionActions.cjs.map +1 -1
- package/dist/development/src/model/authorization/PermissionActions.js +5 -0
- package/dist/development/src/model/authorization/PermissionActions.js.map +1 -1
- package/dist/development/src/model/authorization/PermissionsFactory.cjs +5 -0
- package/dist/development/src/model/authorization/PermissionsFactory.cjs.map +1 -1
- package/dist/development/src/model/authorization/PermissionsFactory.js +5 -0
- package/dist/development/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs +20 -0
- package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js +20 -0
- package/dist/development/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -0
- package/dist/development/src/model/commands/person/CreatePersonCommand.cjs +2 -1
- package/dist/development/src/model/commands/person/CreatePersonCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/person/CreatePersonCommand.js +2 -1
- package/dist/development/src/model/commands/person/CreatePersonCommand.js.map +1 -1
- package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.cjs +18 -0
- package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.js +18 -0
- package/dist/development/src/model/commands/person/TogglePersonPasswordlessCommand.js.map +1 -0
- package/dist/development/src/model/commands/personToken/ActivateOtpCommand.cjs +20 -0
- package/dist/development/src/model/commands/personToken/ActivateOtpCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/personToken/ActivateOtpCommand.js +20 -0
- package/dist/development/src/model/commands/personToken/ActivateOtpCommand.js.map +1 -0
- package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.cjs +33 -0
- package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.js +33 -0
- package/dist/development/src/model/commands/personToken/CreatePersonTokenCommand.js.map +1 -0
- package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs +19 -0
- package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.js +19 -0
- package/dist/development/src/model/commands/personToken/IncreaseOtpAttemptCommand.js.map +1 -0
- package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.cjs +19 -0
- package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.js +19 -0
- package/dist/development/src/model/commands/personToken/InvalidateTokenCommand.js.map +1 -0
- package/dist/development/src/model/commands/personToken/ResetPasswordCommand.cjs +28 -0
- package/dist/development/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/personToken/ResetPasswordCommand.js +28 -0
- package/dist/development/src/model/commands/personToken/ResetPasswordCommand.js.map +1 -0
- package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.cjs +28 -0
- package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.cjs.map +1 -0
- package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.js +28 -0
- package/dist/development/src/model/commands/personToken/SavePersonTokenCommand.js.map +1 -0
- package/dist/development/src/model/consts/expirations.cjs +7 -0
- package/dist/development/src/model/consts/expirations.cjs.map +1 -0
- package/dist/development/src/model/consts/expirations.js +7 -0
- package/dist/development/src/model/consts/expirations.js.map +1 -0
- package/dist/development/src/model/mailing/UserMailer.cjs +10 -1
- package/dist/development/src/model/mailing/UserMailer.cjs.map +1 -1
- package/dist/development/src/model/mailing/UserMailer.js +10 -1
- package/dist/development/src/model/mailing/UserMailer.js.map +1 -1
- package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs +17 -0
- package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs.map +1 -0
- package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.js +18 -0
- package/dist/development/src/model/mailing/templates/PasswordlessSignIn.mustache.js.map +1 -0
- package/dist/development/src/model/mailing/type.cjs +9 -3
- package/dist/development/src/model/mailing/type.cjs.map +1 -1
- package/dist/development/src/model/mailing/type.js +9 -3
- package/dist/development/src/model/mailing/type.js.map +1 -1
- package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs +21 -0
- package/dist/development/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -0
- package/dist/development/src/model/queries/configuration/ConfigurationQuery.js +21 -0
- package/dist/development/src/model/queries/configuration/ConfigurationQuery.js.map +1 -0
- package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
- package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
- package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
- package/dist/development/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
- package/dist/development/src/model/queries/personToken/PersonTokenQuery.cjs +29 -0
- package/dist/development/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -0
- package/dist/development/src/model/queries/personToken/PersonTokenQuery.js +29 -0
- package/dist/development/src/model/queries/personToken/PersonTokenQuery.js.map +1 -0
- package/dist/development/src/model/service/ConfigurationManager.cjs +27 -0
- package/dist/development/src/model/service/ConfigurationManager.cjs.map +1 -0
- package/dist/development/src/model/service/ConfigurationManager.js +27 -0
- package/dist/development/src/model/service/ConfigurationManager.js.map +1 -0
- package/dist/development/src/model/service/InviteManager.cjs +7 -7
- package/dist/development/src/model/service/InviteManager.cjs.map +1 -1
- package/dist/development/src/model/service/InviteManager.js +6 -6
- package/dist/development/src/model/service/InviteManager.js.map +1 -1
- package/dist/development/src/model/service/PasswordChangeManager.cjs +1 -1
- package/dist/development/src/model/service/PasswordChangeManager.js +1 -1
- package/dist/development/src/model/service/PasswordResetManager.cjs +7 -15
- package/dist/development/src/model/service/PasswordResetManager.cjs.map +1 -1
- package/dist/development/src/model/service/PasswordResetManager.js +7 -15
- package/dist/development/src/model/service/PasswordResetManager.js.map +1 -1
- package/dist/development/src/model/service/PasswordlessSignInManager.cjs +135 -0
- package/dist/development/src/model/service/PasswordlessSignInManager.cjs.map +1 -0
- package/dist/development/src/model/service/PasswordlessSignInManager.js +135 -0
- package/dist/development/src/model/service/PasswordlessSignInManager.js.map +1 -0
- package/dist/development/src/model/service/PersonManager.cjs +7 -0
- package/dist/development/src/model/service/PersonManager.cjs.map +1 -1
- package/dist/development/src/model/service/PersonManager.js +7 -0
- package/dist/development/src/model/service/PersonManager.js.map +1 -1
- package/dist/development/src/model/service/ProjectManager.cjs +2 -2
- package/dist/development/src/model/service/ProjectManager.js +2 -2
- package/dist/development/src/model/service/RolesManager.cjs +1 -1
- package/dist/development/src/model/service/RolesManager.js +1 -1
- package/dist/development/src/model/service/SignUpManager.cjs +1 -1
- package/dist/development/src/model/service/SignUpManager.js +1 -1
- package/dist/development/src/model/service/helpers/getPreferredProject.cjs +13 -0
- package/dist/development/src/model/service/helpers/getPreferredProject.cjs.map +1 -0
- package/dist/development/src/model/service/helpers/getPreferredProject.js +13 -0
- package/dist/development/src/model/service/helpers/getPreferredProject.js.map +1 -0
- package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs +2 -1
- package/dist/development/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCProvider.js +2 -1
- package/dist/development/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.cjs +2 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.js +2 -1
- package/dist/development/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
- package/dist/development/src/model/utils/tokenUtils.cjs +39 -0
- package/dist/development/src/model/utils/tokenUtils.cjs.map +1 -1
- package/dist/development/src/model/utils/tokenUtils.js +40 -1
- package/dist/development/src/model/utils/tokenUtils.js.map +1 -1
- package/dist/development/src/resolvers/ResolverFactory.cjs +8 -1
- package/dist/development/src/resolvers/ResolverFactory.cjs.map +1 -1
- package/dist/development/src/resolvers/ResolverFactory.js +8 -1
- package/dist/development/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +41 -0
- package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -0
- package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +41 -0
- package/dist/development/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -0
- package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +83 -0
- package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -0
- package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js +83 -0
- package/dist/development/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -0
- package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +52 -0
- package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -0
- package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +52 -0
- package/dist/development/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -0
- package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs +34 -0
- package/dist/development/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -0
- package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js +34 -0
- package/dist/development/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -0
- package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.cjs +1 -0
- package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
- package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.js +1 -0
- package/dist/development/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
- package/dist/development/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
- package/dist/development/src/schema/tenant.graphql.cjs +161 -10
- package/dist/development/src/schema/tenant.graphql.cjs.map +1 -1
- package/dist/development/src/schema/tenant.graphql.js +161 -10
- package/dist/development/src/schema/tenant.graphql.js.map +1 -1
- package/dist/production/index.cjs +18 -6
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +20 -8
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/TenantContainer.cjs +7 -1
- package/dist/production/src/TenantContainer.cjs.map +1 -1
- package/dist/production/src/TenantContainer.js +7 -1
- package/dist/production/src/TenantContainer.js.map +1 -1
- package/dist/production/src/migrations/2024-08-26-120000-passwordless.cjs +31 -0
- package/dist/production/src/migrations/2024-08-26-120000-passwordless.cjs.map +1 -0
- package/dist/production/src/migrations/2024-08-26-120000-passwordless.js +32 -0
- package/dist/production/src/migrations/2024-08-26-120000-passwordless.js.map +1 -0
- package/dist/production/src/migrations/runner.cjs +3 -1
- package/dist/production/src/migrations/runner.cjs.map +1 -1
- package/dist/production/src/migrations/runner.js +3 -1
- package/dist/production/src/migrations/runner.js.map +1 -1
- package/dist/production/src/migrations/snapshot.cjs +33 -5
- package/dist/production/src/migrations/snapshot.cjs.map +1 -1
- package/dist/production/src/migrations/snapshot.js +33 -5
- package/dist/production/src/migrations/snapshot.js.map +1 -1
- package/dist/production/src/model/authorization/PermissionActions.cjs +5 -0
- package/dist/production/src/model/authorization/PermissionActions.cjs.map +1 -1
- package/dist/production/src/model/authorization/PermissionActions.js +5 -0
- package/dist/production/src/model/authorization/PermissionActions.js.map +1 -1
- package/dist/production/src/model/authorization/PermissionsFactory.cjs +5 -0
- package/dist/production/src/model/authorization/PermissionsFactory.cjs.map +1 -1
- package/dist/production/src/model/authorization/PermissionsFactory.js +5 -0
- package/dist/production/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs +20 -0
- package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js +20 -0
- package/dist/production/src/model/commands/configuration/UpdateConfigurationCommand.js.map +1 -0
- package/dist/production/src/model/commands/person/CreatePersonCommand.cjs +2 -1
- package/dist/production/src/model/commands/person/CreatePersonCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/person/CreatePersonCommand.js +2 -1
- package/dist/production/src/model/commands/person/CreatePersonCommand.js.map +1 -1
- package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.cjs +18 -0
- package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.js +18 -0
- package/dist/production/src/model/commands/person/TogglePersonPasswordlessCommand.js.map +1 -0
- package/dist/production/src/model/commands/personToken/ActivateOtpCommand.cjs +20 -0
- package/dist/production/src/model/commands/personToken/ActivateOtpCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/personToken/ActivateOtpCommand.js +20 -0
- package/dist/production/src/model/commands/personToken/ActivateOtpCommand.js.map +1 -0
- package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs +33 -0
- package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js +33 -0
- package/dist/production/src/model/commands/personToken/CreatePersonTokenCommand.js.map +1 -0
- package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs +19 -0
- package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.js +19 -0
- package/dist/production/src/model/commands/personToken/IncreaseOtpAttemptCommand.js.map +1 -0
- package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.cjs +19 -0
- package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.js +19 -0
- package/dist/production/src/model/commands/personToken/InvalidateTokenCommand.js.map +1 -0
- package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs +28 -0
- package/dist/production/src/model/commands/personToken/ResetPasswordCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js +28 -0
- package/dist/production/src/model/commands/personToken/ResetPasswordCommand.js.map +1 -0
- package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.cjs +28 -0
- package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.cjs.map +1 -0
- package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.js +28 -0
- package/dist/production/src/model/commands/personToken/SavePersonTokenCommand.js.map +1 -0
- package/dist/production/src/model/consts/expirations.cjs +7 -0
- package/dist/production/src/model/consts/expirations.cjs.map +1 -0
- package/dist/production/src/model/consts/expirations.js +7 -0
- package/dist/production/src/model/consts/expirations.js.map +1 -0
- package/dist/production/src/model/mailing/UserMailer.cjs +10 -1
- package/dist/production/src/model/mailing/UserMailer.cjs.map +1 -1
- package/dist/production/src/model/mailing/UserMailer.js +10 -1
- package/dist/production/src/model/mailing/UserMailer.js.map +1 -1
- package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs +17 -0
- package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.cjs.map +1 -0
- package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.js +18 -0
- package/dist/production/src/model/mailing/templates/PasswordlessSignIn.mustache.js.map +1 -0
- package/dist/production/src/model/mailing/type.cjs +9 -3
- package/dist/production/src/model/mailing/type.cjs.map +1 -1
- package/dist/production/src/model/mailing/type.js +9 -3
- package/dist/production/src/model/mailing/type.js.map +1 -1
- package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs +21 -0
- package/dist/production/src/model/queries/configuration/ConfigurationQuery.cjs.map +1 -0
- package/dist/production/src/model/queries/configuration/ConfigurationQuery.js +21 -0
- package/dist/production/src/model/queries/configuration/ConfigurationQuery.js.map +1 -0
- package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs +1 -1
- package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.cjs.map +1 -1
- package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js +1 -1
- package/dist/production/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
- package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs +29 -0
- package/dist/production/src/model/queries/personToken/PersonTokenQuery.cjs.map +1 -0
- package/dist/production/src/model/queries/personToken/PersonTokenQuery.js +29 -0
- package/dist/production/src/model/queries/personToken/PersonTokenQuery.js.map +1 -0
- package/dist/production/src/model/service/ConfigurationManager.cjs +27 -0
- package/dist/production/src/model/service/ConfigurationManager.cjs.map +1 -0
- package/dist/production/src/model/service/ConfigurationManager.js +27 -0
- package/dist/production/src/model/service/ConfigurationManager.js.map +1 -0
- package/dist/production/src/model/service/InviteManager.cjs +7 -7
- package/dist/production/src/model/service/InviteManager.cjs.map +1 -1
- package/dist/production/src/model/service/InviteManager.js +6 -6
- package/dist/production/src/model/service/InviteManager.js.map +1 -1
- package/dist/production/src/model/service/PasswordChangeManager.cjs +1 -1
- package/dist/production/src/model/service/PasswordChangeManager.js +1 -1
- package/dist/production/src/model/service/PasswordResetManager.cjs +7 -15
- package/dist/production/src/model/service/PasswordResetManager.cjs.map +1 -1
- package/dist/production/src/model/service/PasswordResetManager.js +7 -15
- package/dist/production/src/model/service/PasswordResetManager.js.map +1 -1
- package/dist/production/src/model/service/PasswordlessSignInManager.cjs +135 -0
- package/dist/production/src/model/service/PasswordlessSignInManager.cjs.map +1 -0
- package/dist/production/src/model/service/PasswordlessSignInManager.js +135 -0
- package/dist/production/src/model/service/PasswordlessSignInManager.js.map +1 -0
- package/dist/production/src/model/service/PersonManager.cjs +7 -0
- package/dist/production/src/model/service/PersonManager.cjs.map +1 -1
- package/dist/production/src/model/service/PersonManager.js +7 -0
- package/dist/production/src/model/service/PersonManager.js.map +1 -1
- package/dist/production/src/model/service/ProjectManager.cjs +2 -2
- package/dist/production/src/model/service/ProjectManager.js +2 -2
- package/dist/production/src/model/service/RolesManager.cjs +1 -1
- package/dist/production/src/model/service/RolesManager.js +1 -1
- package/dist/production/src/model/service/SignUpManager.cjs +1 -1
- package/dist/production/src/model/service/SignUpManager.js +1 -1
- package/dist/production/src/model/service/helpers/getPreferredProject.cjs +13 -0
- package/dist/production/src/model/service/helpers/getPreferredProject.cjs.map +1 -0
- package/dist/production/src/model/service/helpers/getPreferredProject.js +13 -0
- package/dist/production/src/model/service/helpers/getPreferredProject.js.map +1 -0
- package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs +2 -1
- package/dist/production/src/model/service/idp/providers/OIDCProvider.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCProvider.js +2 -1
- package/dist/production/src/model/service/idp/providers/OIDCProvider.js.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs +2 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.cjs.map +1 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.js +2 -1
- package/dist/production/src/model/service/idp/providers/OIDCTypes.js.map +1 -1
- package/dist/production/src/model/utils/tokenUtils.cjs +39 -0
- package/dist/production/src/model/utils/tokenUtils.cjs.map +1 -1
- package/dist/production/src/model/utils/tokenUtils.js +40 -1
- package/dist/production/src/model/utils/tokenUtils.js.map +1 -1
- package/dist/production/src/resolvers/ResolverFactory.cjs +8 -1
- package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
- package/dist/production/src/resolvers/ResolverFactory.js +8 -1
- package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs +41 -0
- package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.cjs.map +1 -0
- package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js +41 -0
- package/dist/production/src/resolvers/mutation/configuration/ConfigurationMutationResolver.js.map +1 -0
- package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs +83 -0
- package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.cjs.map +1 -0
- package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js +83 -0
- package/dist/production/src/resolvers/mutation/person/PasswordlessMutationResolver.js.map +1 -0
- package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs +52 -0
- package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.cjs.map +1 -0
- package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js +52 -0
- package/dist/production/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.js.map +1 -0
- package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs +34 -0
- package/dist/production/src/resolvers/query/ConfigurationQueryResolver.cjs.map +1 -0
- package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js +34 -0
- package/dist/production/src/resolvers/query/ConfigurationQueryResolver.js.map +1 -0
- package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs +1 -0
- package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.cjs.map +1 -1
- package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js +1 -0
- package/dist/production/src/resolvers/responseHelpers/PersonResponseFactory.js.map +1 -1
- package/dist/production/src/resolvers/types/ProjectTypeResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
- package/dist/production/src/schema/tenant.graphql.cjs +161 -10
- package/dist/production/src/schema/tenant.graphql.cjs.map +1 -1
- package/dist/production/src/schema/tenant.graphql.js +161 -10
- package/dist/production/src/schema/tenant.graphql.js.map +1 -1
- package/dist/tests/cases/integration/mocked/sql/{createPasswordResetSql.d.ts → createPersonTokenSql.d.ts} +3 -2
- package/dist/tests/cases/integration/mocked/sql/createPersonTokenSql.d.ts.map +1 -0
- package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.d.ts.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/TenantContainer.d.ts +18 -0
- package/dist/types/TenantContainer.d.ts.map +1 -1
- package/dist/types/migrations/2024-08-26-120000-passwordless.d.ts +3 -0
- package/dist/types/migrations/2024-08-26-120000-passwordless.d.ts.map +1 -0
- package/dist/types/migrations/runner.d.ts.map +1 -1
- package/dist/types/migrations/snapshot.d.ts.map +1 -1
- package/dist/types/model/authorization/PermissionActions.d.ts +25 -0
- package/dist/types/model/authorization/PermissionActions.d.ts.map +1 -1
- package/dist/types/model/authorization/PermissionsFactory.d.ts.map +1 -1
- package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts +8 -0
- package/dist/types/model/commands/configuration/UpdateConfigurationCommand.d.ts.map +1 -0
- package/dist/types/model/commands/configuration/index.d.ts +2 -0
- package/dist/types/model/commands/configuration/index.d.ts.map +1 -0
- package/dist/types/model/commands/index.d.ts +2 -2
- package/dist/types/model/commands/index.d.ts.map +1 -1
- package/dist/types/model/commands/person/CreatePersonCommand.d.ts.map +1 -1
- package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts +8 -0
- package/dist/types/model/commands/person/TogglePersonPasswordlessCommand.d.ts.map +1 -0
- package/dist/types/model/commands/person/index.d.ts +1 -0
- package/dist/types/model/commands/person/index.d.ts.map +1 -1
- package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts +8 -0
- package/dist/types/model/commands/personToken/ActivateOtpCommand.d.ts.map +1 -0
- package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts +19 -0
- package/dist/types/model/commands/personToken/CreatePersonTokenCommand.d.ts.map +1 -0
- package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts +7 -0
- package/dist/types/model/commands/personToken/IncreaseOtpAttemptCommand.d.ts.map +1 -0
- package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts +7 -0
- package/dist/types/model/commands/personToken/InvalidateTokenCommand.d.ts.map +1 -0
- package/dist/types/model/commands/{passwordReset → personToken}/ResetPasswordCommand.d.ts +3 -2
- package/dist/types/model/commands/personToken/ResetPasswordCommand.d.ts.map +1 -0
- package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts +19 -0
- package/dist/types/model/commands/personToken/SavePersonTokenCommand.d.ts.map +1 -0
- package/dist/types/model/commands/personToken/index.d.ts +7 -0
- package/dist/types/model/commands/personToken/index.d.ts.map +1 -0
- package/dist/types/model/consts/expirations.d.ts +3 -0
- package/dist/types/model/consts/expirations.d.ts.map +1 -0
- package/dist/types/model/mailing/UserMailer.d.ts +10 -0
- package/dist/types/model/mailing/UserMailer.d.ts.map +1 -1
- package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts +3 -0
- package/dist/types/model/mailing/templates/PasswordlessSignIn.mustache.d.ts.map +1 -0
- package/dist/types/model/mailing/type.d.ts +2 -1
- package/dist/types/model/mailing/type.d.ts.map +1 -1
- package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts +6 -0
- package/dist/types/model/queries/configuration/ConfigurationQuery.d.ts.map +1 -0
- package/dist/types/model/queries/configuration/index.d.ts +2 -0
- package/dist/types/model/queries/configuration/index.d.ts.map +1 -0
- package/dist/types/model/queries/index.d.ts +1 -0
- package/dist/types/model/queries/index.d.ts.map +1 -1
- package/dist/types/model/queries/person/PersonQueryBuilderFactory.d.ts.map +1 -1
- package/dist/types/model/queries/person/types.d.ts +1 -0
- package/dist/types/model/queries/person/types.d.ts.map +1 -1
- package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts +12 -0
- package/dist/types/model/queries/personToken/PersonTokenQuery.d.ts.map +1 -0
- package/dist/types/model/service/ConfigurationManager.d.ts +9 -0
- package/dist/types/model/service/ConfigurationManager.d.ts.map +1 -0
- package/dist/types/model/service/InviteManager.d.ts.map +1 -1
- package/dist/types/model/service/PasswordResetManager.d.ts +1 -1
- package/dist/types/model/service/PasswordResetManager.d.ts.map +1 -1
- package/dist/types/model/service/PasswordlessSignInManager.d.ts +54 -0
- package/dist/types/model/service/PasswordlessSignInManager.d.ts.map +1 -0
- package/dist/types/model/service/PersonManager.d.ts +1 -0
- package/dist/types/model/service/PersonManager.d.ts.map +1 -1
- package/dist/types/model/service/PersonTokenManager.d.ts +3 -0
- package/dist/types/model/service/PersonTokenManager.d.ts.map +1 -0
- package/dist/types/model/service/helpers/getPreferredProject.d.ts +3 -0
- package/dist/types/model/service/helpers/getPreferredProject.d.ts.map +1 -0
- package/dist/types/model/service/idp/providers/AppleProvider.d.ts +2 -0
- package/dist/types/model/service/idp/providers/AppleProvider.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/FacebookProvider.d.ts +2 -0
- package/dist/types/model/service/idp/providers/FacebookProvider.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/OIDCProvider.d.ts +1 -0
- package/dist/types/model/service/idp/providers/OIDCProvider.d.ts.map +1 -1
- package/dist/types/model/service/idp/providers/OIDCTypes.d.ts +9 -5
- package/dist/types/model/service/idp/providers/OIDCTypes.d.ts.map +1 -1
- package/dist/types/model/type/PersonToken.d.ts +16 -0
- package/dist/types/model/type/PersonToken.d.ts.map +1 -0
- package/dist/types/model/type/index.d.ts +1 -0
- package/dist/types/model/type/index.d.ts.map +1 -1
- package/dist/types/model/utils/tokenUtils.d.ts +8 -0
- package/dist/types/model/utils/tokenUtils.d.ts.map +1 -1
- package/dist/types/resolvers/ResolverFactory.d.ts +8 -0
- package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts +9 -0
- package/dist/types/resolvers/mutation/configuration/ConfigurationMutationResolver.d.ts.map +1 -0
- package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts +13 -0
- package/dist/types/resolvers/mutation/person/PasswordlessMutationResolver.d.ts.map +1 -0
- package/dist/types/resolvers/mutation/person/ResetPasswordMutationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts +13 -0
- package/dist/types/resolvers/mutation/person/TogglePasswordlessMutationResolver.d.ts.map +1 -0
- package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts +9 -0
- package/dist/types/resolvers/query/ConfigurationQueryResolver.d.ts.map +1 -0
- package/dist/types/resolvers/responseHelpers/PersonResponseFactory.d.ts.map +1 -1
- package/dist/types/resolvers/types/ProjectTypeResolver.d.ts +3 -3
- package/dist/types/schema/index.d.ts +360 -38
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/tenant.graphql.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/batchQuery.d.ts.map +1 -1
- package/{graphql-tenant.codegen.yml → graphql.codegen.yml} +1 -1
- package/package.json +22 -26
- package/src/TenantContainer.ts +18 -0
- package/src/migrations/2024-08-26-120000-passwordless.ts +31 -0
- package/src/migrations/runner.ts +2 -0
- package/src/migrations/snapshot-template-end.txt +3 -0
- package/src/migrations/snapshot.ts +33 -5
- package/src/model/authorization/PermissionActions.ts +7 -0
- package/src/model/authorization/PermissionsFactory.ts +5 -0
- package/src/model/commands/configuration/UpdateConfigurationCommand.ts +26 -0
- package/src/model/commands/configuration/index.ts +1 -0
- package/src/model/commands/index.ts +2 -2
- package/src/model/commands/person/CreatePersonCommand.ts +1 -0
- package/src/model/commands/person/TogglePersonPasswordlessCommand.ts +18 -0
- package/src/model/commands/person/index.ts +1 -0
- package/src/model/commands/personToken/ActivateOtpCommand.ts +24 -0
- package/src/model/commands/personToken/CreatePersonTokenCommand.ts +42 -0
- package/src/model/commands/personToken/IncreaseOtpAttemptCommand.ts +23 -0
- package/src/model/commands/personToken/InvalidateTokenCommand.ts +22 -0
- package/src/model/commands/personToken/ResetPasswordCommand.ts +28 -0
- package/src/model/commands/personToken/SavePersonTokenCommand.ts +42 -0
- package/src/model/commands/personToken/index.ts +6 -0
- package/src/model/consts/expirations.ts +2 -0
- package/src/model/mailing/UserMailer.ts +14 -0
- package/src/model/mailing/templates/PasswordlessSignIn.mustache.ts +15 -0
- package/src/model/mailing/type.ts +3 -0
- package/src/model/queries/configuration/ConfigurationQuery.ts +30 -0
- package/src/model/queries/configuration/index.ts +1 -0
- package/src/model/queries/index.ts +1 -0
- package/src/model/queries/person/PersonQueryBuilderFactory.ts +1 -0
- package/src/model/queries/person/types.ts +1 -0
- package/src/model/queries/personToken/PersonTokenQuery.ts +35 -0
- package/src/model/service/ConfigurationManager.ts +22 -0
- package/src/model/service/InviteManager.ts +5 -6
- package/src/model/service/PasswordResetManager.ts +4 -10
- package/src/model/service/PasswordlessSignInManager.ts +190 -0
- package/src/model/service/PersonManager.ts +6 -0
- package/src/model/service/PersonTokenManager.ts +2 -0
- package/src/model/service/helpers/getPreferredProject.ts +11 -0
- package/src/model/service/idp/providers/OIDCProvider.ts +1 -0
- package/src/model/service/idp/providers/OIDCTypes.ts +1 -0
- package/src/model/type/PersonToken.ts +21 -0
- package/src/model/type/index.ts +1 -0
- package/src/model/utils/tokenUtils.ts +47 -0
- package/src/resolvers/ResolverFactory.ts +19 -0
- package/src/resolvers/mutation/configuration/ConfigurationMutationResolver.ts +29 -0
- package/src/resolvers/mutation/person/PasswordlessMutationResolver.ts +81 -0
- package/src/resolvers/mutation/person/ResetPasswordMutationResolver.ts +1 -10
- package/src/resolvers/mutation/person/TogglePasswordlessMutationResolver.ts +44 -0
- package/src/resolvers/query/ConfigurationQueryResolver.ts +21 -0
- package/src/resolvers/responseHelpers/PersonResponseFactory.ts +1 -0
- package/src/resolvers/types/ProjectTypeResolver.ts +3 -3
- package/src/schema/index.ts +360 -35
- package/src/schema/tenant.graphql.ts +161 -10
- package/tests/cases/integration/mocked/inviteMutations.test.ts +2 -2
- package/tests/cases/integration/mocked/sql/{createPasswordResetSql.ts → createPersonTokenSql.ts} +5 -3
- package/tests/cases/integration/mocked/sql/getPersonByEmailSql.ts +2 -1
- package/tests/cases/integration/mocked/sql/getPersonByIdSql.ts +1 -1
- package/tests/cases/integration/mocked/sql/getPersonByIdentity.ts +1 -1
- package/tests/cases/integration/mocked/sql/getPersonByIdpSql.ts +1 -1
- package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs +0 -30
- package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs.map +0 -1
- package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js +0 -30
- package/dist/development/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js.map +0 -1
- package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.cjs +0 -38
- package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.cjs.map +0 -1
- package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.js +0 -38
- package/dist/development/src/model/commands/passwordReset/ResetPasswordCommand.js.map +0 -1
- package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs +0 -24
- package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs.map +0 -1
- package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js +0 -24
- package/dist/development/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js.map +0 -1
- package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs +0 -30
- package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.cjs.map +0 -1
- package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js +0 -30
- package/dist/production/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.js.map +0 -1
- package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.cjs +0 -38
- package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.cjs.map +0 -1
- package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.js +0 -38
- package/dist/production/src/model/commands/passwordReset/ResetPasswordCommand.js.map +0 -1
- package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs +0 -24
- package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.cjs.map +0 -1
- package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js +0 -24
- package/dist/production/src/model/commands/passwordReset/SavePasswordResetRequestCommand.js.map +0 -1
- package/dist/tests/cases/integration/mocked/sql/createPasswordResetSql.d.ts.map +0 -1
- package/dist/types/model/commands/passwordReset/CreatePasswordResetRequestCommand.d.ts +0 -12
- package/dist/types/model/commands/passwordReset/CreatePasswordResetRequestCommand.d.ts.map +0 -1
- package/dist/types/model/commands/passwordReset/ResetPasswordCommand.d.ts.map +0 -1
- package/dist/types/model/commands/passwordReset/SavePasswordResetRequestCommand.d.ts +0 -10
- package/dist/types/model/commands/passwordReset/SavePasswordResetRequestCommand.d.ts.map +0 -1
- package/dist/types/model/commands/passwordReset/index.d.ts +0 -4
- package/dist/types/model/commands/passwordReset/index.d.ts.map +0 -1
- package/src/model/commands/passwordReset/CreatePasswordResetRequestCommand.ts +0 -25
- package/src/model/commands/passwordReset/ResetPasswordCommand.ts +0 -57
- package/src/model/commands/passwordReset/SavePasswordResetRequestCommand.ts +0 -28
- package/src/model/commands/passwordReset/index.ts +0 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Layout from './Layout.mustache'
|
|
2
|
+
// language=Mustache
|
|
3
|
+
export default Layout(`
|
|
4
|
+
<p>Hello,</p>
|
|
5
|
+
<p>
|
|
6
|
+
sign in was requested for your account ({{email}}):<br>
|
|
7
|
+
{{#url}}
|
|
8
|
+
<p>Click the following link to sign in:</p>
|
|
9
|
+
<a href="{{url}}">{{url}}</a>
|
|
10
|
+
{{/url}}
|
|
11
|
+
{{^url}}
|
|
12
|
+
<p>Passwordless sign-in is misconfigured. Please contact your administrator.</p>
|
|
13
|
+
{{/url}}
|
|
14
|
+
</p>
|
|
15
|
+
`)
|
|
@@ -4,6 +4,7 @@ export enum MailType {
|
|
|
4
4
|
existingUserInvited = 'existingUserInvited',
|
|
5
5
|
newUserInvited = 'newUserInvited',
|
|
6
6
|
passwordReset = 'passwordReset',
|
|
7
|
+
passwordlessSignIn = 'passwordlessSignIn',
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const mailTypeFromSchemaToDb = (type: SchemaMailType): MailType => {
|
|
@@ -11,6 +12,7 @@ export const mailTypeFromSchemaToDb = (type: SchemaMailType): MailType => {
|
|
|
11
12
|
EXISTING_USER_INVITED: MailType.existingUserInvited,
|
|
12
13
|
NEW_USER_INVITED: MailType.newUserInvited,
|
|
13
14
|
RESET_PASSWORD_REQUEST: MailType.passwordReset,
|
|
15
|
+
PASSWORDLESS_SIGN_IN: MailType.passwordlessSignIn,
|
|
14
16
|
}[type]
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -19,6 +21,7 @@ export const mailTypeFromDbToSchema = (type: MailType): SchemaMailType => {
|
|
|
19
21
|
[MailType.existingUserInvited]: 'EXISTING_USER_INVITED' as const,
|
|
20
22
|
[MailType.newUserInvited]: 'NEW_USER_INVITED' as const,
|
|
21
23
|
[MailType.passwordReset]: 'RESET_PASSWORD_REQUEST' as const,
|
|
24
|
+
[MailType.passwordlessSignIn]: 'PASSWORDLESS_SIGN_IN' as const,
|
|
22
25
|
}[type]
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'
|
|
2
|
+
import { Config, ConfigPolicy } from '../../../schema'
|
|
3
|
+
|
|
4
|
+
export class ConfigurationQuery extends DatabaseQuery<Config> {
|
|
5
|
+
|
|
6
|
+
async fetch({ db }: DatabaseQueryable): Promise<Config> {
|
|
7
|
+
const rows = await SelectBuilder.create<ConfigurationRow>()
|
|
8
|
+
.from('config')
|
|
9
|
+
.select(new Literal('*'))
|
|
10
|
+
.getResult(db)
|
|
11
|
+
const result = this.fetchOneOrNull(rows)
|
|
12
|
+
if (!result) {
|
|
13
|
+
throw new Error('Configuration not found')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
passwordless: {
|
|
18
|
+
enabled: result.passwordless_enabled,
|
|
19
|
+
url: result.passwordless_url,
|
|
20
|
+
expirationMinutes: result.passwordless_expiration_minutes,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ConfigurationRow {
|
|
27
|
+
passwordless_enabled: ConfigPolicy
|
|
28
|
+
passwordless_url: string | null
|
|
29
|
+
passwordless_expiration_minutes: number
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ConfigurationQuery'
|
|
@@ -12,6 +12,7 @@ export class PersonQueryBuilderFactory {
|
|
|
12
12
|
.select(['person', 'email'])
|
|
13
13
|
.select(['person', 'name'])
|
|
14
14
|
.select(['person', 'disabled_at'])
|
|
15
|
+
.select(['person', 'passwordless_enabled'])
|
|
15
16
|
.select(['identity', 'roles'])
|
|
16
17
|
.from('person')
|
|
17
18
|
.join('identity', 'identity', expr => expr.columnsEq(['identity', 'id'], ['person', 'identity_id']))
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'
|
|
2
|
+
import { PersonToken } from '../../type'
|
|
3
|
+
import { computeTokenHash } from '../../utils'
|
|
4
|
+
|
|
5
|
+
export class PersonTokenQuery extends DatabaseQuery<PersonToken.Row | null> {
|
|
6
|
+
|
|
7
|
+
private constructor(
|
|
8
|
+
private readonly identifierType: 'id' | 'token_hash',
|
|
9
|
+
private readonly identifier: string,
|
|
10
|
+
private readonly type: PersonToken.Type,
|
|
11
|
+
) {
|
|
12
|
+
super()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public static byId(id: string, type: PersonToken.Type): PersonTokenQuery {
|
|
16
|
+
return new PersonTokenQuery('id', id, type)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static byToken(token: string, type: PersonToken.Type): PersonTokenQuery {
|
|
20
|
+
const tokenHash = computeTokenHash(token)
|
|
21
|
+
return new PersonTokenQuery('token_hash', tokenHash, type)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async fetch({ db }: DatabaseQueryable): Promise<PersonToken.Row | null> {
|
|
25
|
+
const result = await SelectBuilder.create<PersonToken.Row>()
|
|
26
|
+
.from('person_token')
|
|
27
|
+
.select(new Literal('*'))
|
|
28
|
+
.where({
|
|
29
|
+
[this.identifierType]: this.identifier,
|
|
30
|
+
type: this.type,
|
|
31
|
+
})
|
|
32
|
+
.getResult(db)
|
|
33
|
+
return this.fetchOneOrNull(result)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Config, ConfigInput, ConfigureErrorCode } from '../../schema'
|
|
2
|
+
import { Response, ResponseOk } from '../utils/Response'
|
|
3
|
+
import { DatabaseContext } from '../utils'
|
|
4
|
+
import { UpdateConfigurationCommand } from '../commands'
|
|
5
|
+
import { ConfigurationQuery } from '../queries'
|
|
6
|
+
|
|
7
|
+
export class ConfigurationManager {
|
|
8
|
+
constructor() {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async updateConfiguration(db: DatabaseContext, configuration: ConfigInput): Promise<Response<null, ConfigureErrorCode>> {
|
|
12
|
+
// todo: validate configuration
|
|
13
|
+
|
|
14
|
+
await db.commandBus.execute(new UpdateConfigurationCommand(configuration))
|
|
15
|
+
|
|
16
|
+
return new ResponseOk(null)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async fetchConfiguration(db: DatabaseContext): Promise<Config> {
|
|
20
|
+
return await db.queryHandler.fetch(new ConfigurationQuery())
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CreateIdentityCommand,
|
|
3
3
|
CreateOrUpdateProjectMembershipCommand,
|
|
4
|
-
CreatePasswordResetRequestCommand,
|
|
5
4
|
CreatePersonCommand,
|
|
6
|
-
|
|
5
|
+
CreatePersonTokenCommand,
|
|
6
|
+
SavePersonTokenCommand,
|
|
7
7
|
} from '../commands'
|
|
8
8
|
import { Providers } from '../providers'
|
|
9
9
|
import { PersonQuery, PersonRow } from '../queries'
|
|
@@ -17,6 +17,7 @@ import { DatabaseContext, TokenHash } from '../utils'
|
|
|
17
17
|
import { NoPassword, PasswordPlain } from '../dtos'
|
|
18
18
|
import { Acl } from '@contember/schema'
|
|
19
19
|
import { validateEmail } from '../utils/email'
|
|
20
|
+
import { INVITATION_RESET_TOKEN_EXPIRATION_MINUTES } from '../consts/expirations'
|
|
20
21
|
|
|
21
22
|
export interface InviteData {
|
|
22
23
|
email: string
|
|
@@ -30,8 +31,6 @@ export interface InviteData {
|
|
|
30
31
|
passwordResetTokenHash?: TokenHash
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const INVITATION_RESET_TOKEN_EXPIRATION_MINUTES = 60 * 24
|
|
34
|
-
|
|
35
34
|
export class InviteManager {
|
|
36
35
|
constructor(
|
|
37
36
|
private readonly providers: Providers,
|
|
@@ -76,11 +75,11 @@ export class InviteManager {
|
|
|
76
75
|
password: passwordWrapper,
|
|
77
76
|
}))
|
|
78
77
|
if (method === 'RESET_PASSWORD') {
|
|
79
|
-
const result = await trx.commandBus.execute(
|
|
78
|
+
const result = await trx.commandBus.execute(CreatePersonTokenCommand.createPasswordResetRequest(person.id, await this.getInviteExpiration(project.slug)))
|
|
80
79
|
resetToken = result.token
|
|
81
80
|
}
|
|
82
81
|
if (passwordResetTokenHash) {
|
|
83
|
-
await trx.commandBus.execute(new
|
|
82
|
+
await trx.commandBus.execute(new SavePersonTokenCommand(person.id, passwordResetTokenHash, 'password_reset', await this.getInviteExpiration(project.slug)))
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
for (const membershipUpdate of createAppendMembershipVariables(memberships)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CreatePasswordResetRequestCommand, ResetPasswordCommand, ResetPasswordCommandErrorCode } from '../commands'
|
|
2
1
|
import { Response, ResponseError } from '../utils/Response'
|
|
3
2
|
import { getPasswordWeaknessMessage } from '../utils/password'
|
|
4
3
|
import { UserMailer } from '../mailing'
|
|
@@ -7,6 +6,8 @@ import { PermissionContext } from '../authorization'
|
|
|
7
6
|
import { ProjectManager } from './ProjectManager'
|
|
8
7
|
import { DatabaseContext } from '../utils'
|
|
9
8
|
import { ImplementationException } from '../../exceptions'
|
|
9
|
+
import { getPreferredProject } from './helpers/getPreferredProject'
|
|
10
|
+
import { CreatePersonTokenCommand, ResetPasswordCommand, ResetPasswordCommandErrorCode } from '../commands/personToken'
|
|
10
11
|
|
|
11
12
|
interface MailOptions {
|
|
12
13
|
project?: string
|
|
@@ -25,16 +26,9 @@ export class PasswordResetManager {
|
|
|
25
26
|
person: PersonRow,
|
|
26
27
|
mailOptions: MailOptions = {},
|
|
27
28
|
): Promise<void> {
|
|
28
|
-
const result = await dbContext.commandBus.execute(
|
|
29
|
+
const result = await dbContext.commandBus.execute(CreatePersonTokenCommand.createPasswordResetRequest(person.id))
|
|
29
30
|
const projects = await this.projectManager.getProjectsByIdentity(dbContext, person.identity_id, permissionContext)
|
|
30
|
-
const project = (
|
|
31
|
-
if (projects.length === 1) {
|
|
32
|
-
return projects[0]
|
|
33
|
-
} else if (mailOptions.project) {
|
|
34
|
-
return projects.find(it => it.slug === mailOptions.project) || null
|
|
35
|
-
}
|
|
36
|
-
return null
|
|
37
|
-
})()
|
|
31
|
+
const project = getPreferredProject(projects, mailOptions.project ?? null)
|
|
38
32
|
if (!person.email) {
|
|
39
33
|
throw new ImplementationException()
|
|
40
34
|
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { ApiKeyManager } from './apiKey'
|
|
2
|
+
import { PersonQuery, PersonRow } from '../queries'
|
|
3
|
+
import { Response, ResponseError, ResponseOk } from '../utils/Response'
|
|
4
|
+
import {
|
|
5
|
+
ActivatePasswordlessOtpErrorCode,
|
|
6
|
+
ConfigPolicy,
|
|
7
|
+
InitSignInPasswordlessErrorCode,
|
|
8
|
+
InitSignInPasswordlessResult,
|
|
9
|
+
SignInPasswordlessErrorCode,
|
|
10
|
+
} from '../../schema'
|
|
11
|
+
import { DatabaseContext, validateToken } from '../utils'
|
|
12
|
+
import { ConfigurationManager } from './ConfigurationManager'
|
|
13
|
+
import { UserMailer } from '../mailing'
|
|
14
|
+
import { ActivateOtpCommand, CreatePersonTokenCommand, IncreaseOtpAttemptCommand } from '../commands'
|
|
15
|
+
import { getPreferredProject } from './helpers/getPreferredProject'
|
|
16
|
+
import { ProjectManager } from './ProjectManager'
|
|
17
|
+
import { PermissionContext } from '../authorization'
|
|
18
|
+
import { PersonTokenQuery } from '../queries/personToken/PersonTokenQuery'
|
|
19
|
+
import { ImplementationException } from '../../exceptions'
|
|
20
|
+
import { OtpAuthenticator } from './OtpAuthenticator'
|
|
21
|
+
import { InvalidateTokenCommand } from '../commands/personToken/InvalidateTokenCommand'
|
|
22
|
+
import { PersonToken } from '../type'
|
|
23
|
+
|
|
24
|
+
class PasswordlessSignInManager {
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly apiKeyManager: ApiKeyManager,
|
|
27
|
+
private readonly configurationManager: ConfigurationManager,
|
|
28
|
+
private readonly mailer: UserMailer,
|
|
29
|
+
private readonly projectManager: ProjectManager,
|
|
30
|
+
private readonly otpAuthenticator: OtpAuthenticator,
|
|
31
|
+
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
async initSignInPasswordless({ db, permissionContext, mailVariant, mailProject, email }: {
|
|
35
|
+
db: DatabaseContext
|
|
36
|
+
permissionContext: PermissionContext
|
|
37
|
+
email: string
|
|
38
|
+
mailVariant?: string
|
|
39
|
+
mailProject?: string
|
|
40
|
+
}): Promise<PasswordlessSignInManager.InitSignInPasswordlessResponse> {
|
|
41
|
+
return db.transaction(async (db): Promise<PasswordlessSignInManager.InitSignInPasswordlessResponse> => {
|
|
42
|
+
const configuration = await this.configurationManager.fetchConfiguration(db)
|
|
43
|
+
if (configuration.passwordless.enabled === 'never') {
|
|
44
|
+
return new ResponseError('PASSWORDLESS_DISABLED', 'Passwordless sign-in is disabled')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const person = await db.queryHandler.fetch(PersonQuery.byEmail(email))
|
|
48
|
+
if (!person) {
|
|
49
|
+
return new ResponseError('PERSON_NOT_FOUND', `Person ${email} not found`)
|
|
50
|
+
}
|
|
51
|
+
if (!this.isEnabled(configuration.passwordless.enabled, person.passwordless_enabled)) {
|
|
52
|
+
return new ResponseError('PASSWORDLESS_DISABLED', 'Passwordless sign-in is disabled for this person')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const createTokenCommand = CreatePersonTokenCommand.createPasswordlessRequest(person.id, configuration.passwordless.expirationMinutes)
|
|
56
|
+
const result = await db.commandBus.execute(createTokenCommand)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const url = this.formatUrl(configuration.passwordless.url ?? null, result.token, result.id, email) ?? undefined
|
|
60
|
+
|
|
61
|
+
const projects = await this.projectManager.getProjectsByIdentity(db, person.identity_id, permissionContext)
|
|
62
|
+
const project = getPreferredProject(projects, mailProject ?? null)
|
|
63
|
+
|
|
64
|
+
await this.mailer.sendPasswordlessEmail(db, {
|
|
65
|
+
email,
|
|
66
|
+
token: result.token,
|
|
67
|
+
url,
|
|
68
|
+
project: project?.name,
|
|
69
|
+
projectSlug: project?.slug,
|
|
70
|
+
}, {
|
|
71
|
+
variant: mailVariant || '',
|
|
72
|
+
projectId: project?.id ?? null,
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
return new ResponseOk({ requestId: result.id, expiresAt: result.expiresAt })
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private formatUrl(url: string | null, token: string, requestId: string, email: string): string | null {
|
|
80
|
+
if (!url) {
|
|
81
|
+
return null
|
|
82
|
+
}
|
|
83
|
+
const urlObj = new URL(url)
|
|
84
|
+
urlObj.searchParams.set('token', token)
|
|
85
|
+
urlObj.searchParams.set('request_id', requestId)
|
|
86
|
+
urlObj.searchParams.set('email', email)
|
|
87
|
+
return urlObj.toString()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async signInPasswordless({ db, expiration, token, requestId, mfaOtp, validationType }: {
|
|
91
|
+
db: DatabaseContext
|
|
92
|
+
validationType: PersonToken.ValidationType
|
|
93
|
+
requestId: string
|
|
94
|
+
token: string
|
|
95
|
+
mfaOtp?: string
|
|
96
|
+
expiration?: number
|
|
97
|
+
}): Promise<PasswordlessSignInManager.SignInPasswordlessResponse> {
|
|
98
|
+
return db.transaction(async (db): Promise<PasswordlessSignInManager.SignInPasswordlessResponse> => {
|
|
99
|
+
|
|
100
|
+
const tokenResult = await db.queryHandler.fetch(PersonTokenQuery.byId(requestId, 'passwordless'))
|
|
101
|
+
const tokenValidationResult = validateToken({
|
|
102
|
+
entry: tokenResult,
|
|
103
|
+
token,
|
|
104
|
+
now: db.providers.now(),
|
|
105
|
+
validationType,
|
|
106
|
+
})
|
|
107
|
+
if (!tokenValidationResult.ok) {
|
|
108
|
+
if (tokenValidationResult.error === 'TOKEN_INVALID' && validationType === 'otp') {
|
|
109
|
+
await db.commandBus.execute(new IncreaseOtpAttemptCommand(tokenResult!.id))
|
|
110
|
+
}
|
|
111
|
+
return tokenValidationResult
|
|
112
|
+
}
|
|
113
|
+
const personRow = await db.queryHandler.fetch(PersonQuery.byId(tokenValidationResult.result.person_id))
|
|
114
|
+
if (!personRow) {
|
|
115
|
+
throw new ImplementationException()
|
|
116
|
+
}
|
|
117
|
+
if (personRow.disabled_at !== null) {
|
|
118
|
+
return new ResponseError('PERSON_DISABLED', `Person is disabled`)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (personRow.otp_uri && personRow.otp_activated_at) {
|
|
122
|
+
if (!mfaOtp) {
|
|
123
|
+
return new ResponseError('OTP_REQUIRED', `2FA is enabled. OTP token is required`)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!this.otpAuthenticator.validate({ uri: personRow.otp_uri }, mfaOtp)) {
|
|
127
|
+
return new ResponseError('INVALID_OTP_TOKEN', 'OTP token validation has failed')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await db.commandBus.execute(new InvalidateTokenCommand(tokenValidationResult.result.id))
|
|
132
|
+
const sessionToken = await this.apiKeyManager.createSessionApiKey(db, personRow.identity_id, expiration)
|
|
133
|
+
|
|
134
|
+
return new ResponseOk({ person: personRow, token: sessionToken })
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async activatePasswordlessOtp({ db, token, requestId, otpHash }: {
|
|
139
|
+
db: DatabaseContext
|
|
140
|
+
requestId: string
|
|
141
|
+
token: string
|
|
142
|
+
otpHash: string
|
|
143
|
+
}): Promise<PasswordlessSignInManager.ActivatePasswordlessOtpResponse> {
|
|
144
|
+
return db.transaction(async (db): Promise<PasswordlessSignInManager.ActivatePasswordlessOtpResponse> => {
|
|
145
|
+
|
|
146
|
+
const tokenResult = await db.queryHandler.fetch(PersonTokenQuery.byId(requestId, 'passwordless'))
|
|
147
|
+
const tokenValidationResult = validateToken({
|
|
148
|
+
entry: tokenResult,
|
|
149
|
+
token,
|
|
150
|
+
now: db.providers.now(),
|
|
151
|
+
validationType: 'token',
|
|
152
|
+
})
|
|
153
|
+
if (!tokenValidationResult.ok) {
|
|
154
|
+
return tokenValidationResult
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
await db.commandBus.execute(new ActivateOtpCommand(tokenValidationResult.result.id, otpHash))
|
|
158
|
+
|
|
159
|
+
return new ResponseOk(null)
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private isEnabled(globalValue: ConfigPolicy, personValue: boolean | null): boolean {
|
|
164
|
+
switch (globalValue) {
|
|
165
|
+
case 'always':
|
|
166
|
+
return true
|
|
167
|
+
case 'never':
|
|
168
|
+
return false
|
|
169
|
+
case 'optIn':
|
|
170
|
+
return personValue === true
|
|
171
|
+
case 'optOut':
|
|
172
|
+
return personValue !== false
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
namespace PasswordlessSignInManager {
|
|
178
|
+
export type InitSignInPasswordlessResponse = Response<InitSignInPasswordlessResult, InitSignInPasswordlessErrorCode>
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
interface SignInPasswordlessResult {
|
|
182
|
+
readonly person: PersonRow
|
|
183
|
+
readonly token: string
|
|
184
|
+
}
|
|
185
|
+
export type SignInPasswordlessResponse = Response<SignInPasswordlessResult, SignInPasswordlessErrorCode>
|
|
186
|
+
|
|
187
|
+
export type ActivatePasswordlessOtpResponse = Response<null, ActivatePasswordlessOtpErrorCode>
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { PasswordlessSignInManager }
|
|
@@ -3,6 +3,7 @@ import { Response, ResponseError, ResponseOk } from '../utils/Response'
|
|
|
3
3
|
import { PersonQuery, PersonRow } from '../queries'
|
|
4
4
|
import { DatabaseContext } from '../utils'
|
|
5
5
|
import { EmailValidator, EmailValidatorError } from './EmailValidator'
|
|
6
|
+
import { TogglePersonPasswordlessCommand } from '../commands'
|
|
6
7
|
|
|
7
8
|
class PersonManager {
|
|
8
9
|
constructor(
|
|
@@ -27,6 +28,11 @@ class PersonManager {
|
|
|
27
28
|
return new ResponseOk(null)
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
async togglePasswordless(dbContext: DatabaseContext, person: PersonRow, value: boolean): Promise<Response<null, never>> {
|
|
32
|
+
await dbContext.commandBus.execute(new TogglePersonPasswordlessCommand(person.id, value))
|
|
33
|
+
return new ResponseOk(null)
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
namespace PersonManager {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Project } from '../../type'
|
|
2
|
+
|
|
3
|
+
export const getPreferredProject = (projects: Project[], preferredProjectSlug: string | null): Project | null => {
|
|
4
|
+
if (projects.length === 1) {
|
|
5
|
+
return projects[0]
|
|
6
|
+
}
|
|
7
|
+
if (preferredProjectSlug) {
|
|
8
|
+
return projects.find(it => it.slug === preferredProjectSlug) || null
|
|
9
|
+
}
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
@@ -40,6 +40,7 @@ export class OIDCProvider implements IdentityProviderHandler<OIDCConfiguration>
|
|
|
40
40
|
client_id: configuration.clientId,
|
|
41
41
|
client_secret: configuration.clientSecret,
|
|
42
42
|
response_types: [configuration.responseType || 'code'],
|
|
43
|
+
id_token_signed_response_alg: configuration.idTokenSignedResponseAlg ?? 'RS256',
|
|
43
44
|
},
|
|
44
45
|
undefined,
|
|
45
46
|
{
|
|
@@ -10,6 +10,7 @@ export const OIDCConfigurationOptions = Typesafe.partial({
|
|
|
10
10
|
responseType: Typesafe.enumeration<ResponseType>('code', 'code id_token', 'code id_token token', 'code token', 'id_token', 'id_token token', 'none'),
|
|
11
11
|
claims: Typesafe.string,
|
|
12
12
|
additionalAuthorizedParties: Typesafe.array(Typesafe.string),
|
|
13
|
+
idTokenSignedResponseAlg: Typesafe.string,
|
|
13
14
|
})
|
|
14
15
|
export const BaseOIDCConfiguration = Typesafe.intersection(
|
|
15
16
|
Typesafe.object({
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export namespace PersonToken {
|
|
2
|
+
export type Type = 'password_reset' | 'passwordless'
|
|
3
|
+
export type ValidationType = 'token' | 'otp'
|
|
4
|
+
|
|
5
|
+
export interface Row {
|
|
6
|
+
id: string
|
|
7
|
+
created_at: Date
|
|
8
|
+
token_hash: string
|
|
9
|
+
used_at: null | Date
|
|
10
|
+
expires_at: Date
|
|
11
|
+
person_id: string
|
|
12
|
+
otp_hash: string | null
|
|
13
|
+
otp_attempts: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TokenValidationError =
|
|
17
|
+
| 'TOKEN_NOT_FOUND'
|
|
18
|
+
| 'TOKEN_INVALID'
|
|
19
|
+
| 'TOKEN_USED'
|
|
20
|
+
| 'TOKEN_EXPIRED'
|
|
21
|
+
}
|
package/src/model/type/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import crypto from 'node:crypto'
|
|
2
2
|
import { FixedLengthHexString, isFixedLengthHexString } from './typeUtils'
|
|
3
|
+
import { PersonToken } from '../type'
|
|
4
|
+
import { ImplementationException } from '../../exceptions'
|
|
5
|
+
import { Response, ResponseError, ResponseOk } from './Response'
|
|
3
6
|
|
|
4
7
|
export const generateToken = async (generator: {
|
|
5
8
|
randomBytes: (bytes: number) => Promise<Buffer>
|
|
@@ -17,3 +20,47 @@ export const computeTokenHash = (token: string): TokenHash => {
|
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export const isTokenHash = (token: string): token is TokenHash => isFixedLengthHexString(token, 64)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const MAX_OTP_ATTEMPTS = 3
|
|
26
|
+
|
|
27
|
+
export const validateToken = ({ entry, validationType, token, now }: {
|
|
28
|
+
entry: PersonToken.Row | null
|
|
29
|
+
validationType: PersonToken.ValidationType
|
|
30
|
+
token: string
|
|
31
|
+
now: Date
|
|
32
|
+
}): Response<PersonToken.Row, PersonToken.TokenValidationError> => {
|
|
33
|
+
if (!entry) {
|
|
34
|
+
return new ResponseError('TOKEN_NOT_FOUND', 'Token not found')
|
|
35
|
+
}
|
|
36
|
+
if (validationType === 'otp' && entry.otp_attempts >= MAX_OTP_ATTEMPTS) {
|
|
37
|
+
return new ResponseError('TOKEN_EXPIRED', 'OTP attempts exceeded')
|
|
38
|
+
}
|
|
39
|
+
switch (validationType) {
|
|
40
|
+
case 'token':
|
|
41
|
+
if (entry.otp_hash !== null) {
|
|
42
|
+
return new ResponseError('TOKEN_INVALID', 'The token was exchanged for OTP')
|
|
43
|
+
}
|
|
44
|
+
if (entry.token_hash !== computeTokenHash(token)) {
|
|
45
|
+
return new ResponseError('TOKEN_INVALID', 'Token invalid')
|
|
46
|
+
}
|
|
47
|
+
break
|
|
48
|
+
case 'otp':
|
|
49
|
+
if (entry.otp_hash === null) {
|
|
50
|
+
return new ResponseError('TOKEN_INVALID', 'OTP not set')
|
|
51
|
+
}
|
|
52
|
+
if (entry.otp_hash !== computeTokenHash(token)) {
|
|
53
|
+
return new ResponseError('TOKEN_INVALID', 'OTP invalid')
|
|
54
|
+
}
|
|
55
|
+
break
|
|
56
|
+
default:
|
|
57
|
+
throw new ImplementationException()
|
|
58
|
+
}
|
|
59
|
+
if (entry.used_at) {
|
|
60
|
+
return new ResponseError('TOKEN_USED', 'Token used at ' + entry.used_at.toISOString())
|
|
61
|
+
}
|
|
62
|
+
if (entry.expires_at < now) {
|
|
63
|
+
return new ResponseError('TOKEN_EXPIRED', 'Token expired at ' + entry.expires_at.toISOString())
|
|
64
|
+
}
|
|
65
|
+
return new ResponseOk(entry)
|
|
66
|
+
}
|
|
@@ -31,6 +31,10 @@ import { IDPQueryResolver } from './query/IDPQueryResolver'
|
|
|
31
31
|
import { UpdateIDPMutationResolver } from './mutation/idp/UpdateIDPMutationResolver'
|
|
32
32
|
import { DisablePersonMutationResolver } from './mutation/person/DisablePersonMutationResolver'
|
|
33
33
|
import { MailTemplateQueryResolver } from './query/MailTemplateQueryResolver'
|
|
34
|
+
import { ConfigurationMutationResolver } from './mutation/configuration/ConfigurationMutationResolver'
|
|
35
|
+
import { ConfigurationQueryResolver } from './query/ConfigurationQueryResolver'
|
|
36
|
+
import { PasswordlessMutationResolver } from './mutation/person/PasswordlessMutationResolver'
|
|
37
|
+
import { TogglePasswordlessMutationResolver } from './mutation/person/TogglePasswordlessMutationResolver'
|
|
34
38
|
|
|
35
39
|
class ResolverFactory {
|
|
36
40
|
public constructor(
|
|
@@ -53,6 +57,7 @@ class ResolverFactory {
|
|
|
53
57
|
disableIdpMutationResolver: DisableIDPMutationResolver
|
|
54
58
|
enableIdpMutationResolver: EnableIDPMutationResolver
|
|
55
59
|
updateIdpMutationResolver: UpdateIDPMutationResolver
|
|
60
|
+
passwordlessMutationResolver: PasswordlessMutationResolver
|
|
56
61
|
|
|
57
62
|
disablePersonMutationResolver: DisablePersonMutationResolver
|
|
58
63
|
|
|
@@ -77,6 +82,11 @@ class ResolverFactory {
|
|
|
77
82
|
|
|
78
83
|
identityGlobalRolesMutationResolver: IdentityGlobalRolesMutationResolver
|
|
79
84
|
|
|
85
|
+
configurationMutationResolver: ConfigurationMutationResolver
|
|
86
|
+
configurationQueryResolver: ConfigurationQueryResolver
|
|
87
|
+
|
|
88
|
+
togglePasswordlessMutationResolver: TogglePasswordlessMutationResolver
|
|
89
|
+
|
|
80
90
|
},
|
|
81
91
|
) { }
|
|
82
92
|
|
|
@@ -102,6 +112,7 @@ class ResolverFactory {
|
|
|
102
112
|
projectMemberships: this.resolvers.projectMembersQueryResolver.projectMemberships.bind(this.resolvers.projectMembersQueryResolver),
|
|
103
113
|
identityProviders: this.resolvers.idpQueryResolver.identityProviders.bind(this.resolvers.idpQueryResolver),
|
|
104
114
|
mailTemplates: this.resolvers.mailTemplateQueryResolver.mailTemplates.bind(this.resolvers.mailTemplateQueryResolver),
|
|
115
|
+
configuration: this.resolvers.configurationQueryResolver.configuration.bind(this.resolvers.configurationQueryResolver),
|
|
105
116
|
checkResetPasswordToken: () => {
|
|
106
117
|
throw new Error('not implemented')
|
|
107
118
|
},
|
|
@@ -127,6 +138,12 @@ class ResolverFactory {
|
|
|
127
138
|
updateIDP: this.resolvers.updateIdpMutationResolver.updateIDP.bind(this.resolvers.updateIdpMutationResolver),
|
|
128
139
|
disablePerson: this.resolvers.disablePersonMutationResolver.disablePerson.bind(this.resolvers.disablePersonMutationResolver),
|
|
129
140
|
|
|
141
|
+
signInPasswordless: this.resolvers.passwordlessMutationResolver.signInPasswordless.bind(this.resolvers.passwordlessMutationResolver),
|
|
142
|
+
initSignInPasswordless: this.resolvers.passwordlessMutationResolver.initSignInPasswordless.bind(this.resolvers.passwordlessMutationResolver),
|
|
143
|
+
activatePasswordlessOtp: this.resolvers.passwordlessMutationResolver.activatePasswordlessOtp.bind(this.resolvers.passwordlessMutationResolver),
|
|
144
|
+
disableMyPasswordless: this.resolvers.togglePasswordlessMutationResolver.disableMyPasswordless.bind(this.resolvers.togglePasswordlessMutationResolver),
|
|
145
|
+
enableMyPasswordless: this.resolvers.togglePasswordlessMutationResolver.enableMyPasswordless.bind(this.resolvers.togglePasswordlessMutationResolver),
|
|
146
|
+
|
|
130
147
|
invite: this.resolvers.inviteMutationResolver.invite.bind(this.resolvers.inviteMutationResolver),
|
|
131
148
|
unmanagedInvite: this.resolvers.inviteMutationResolver.unmanagedInvite.bind(this.resolvers.inviteMutationResolver),
|
|
132
149
|
|
|
@@ -154,6 +171,8 @@ class ResolverFactory {
|
|
|
154
171
|
|
|
155
172
|
addGlobalIdentityRoles: this.resolvers.identityGlobalRolesMutationResolver.addGlobalIdentityRoles.bind(this.resolvers.identityGlobalRolesMutationResolver),
|
|
156
173
|
removeGlobalIdentityRoles: this.resolvers.identityGlobalRolesMutationResolver.removeGlobalIdentityRoles.bind(this.resolvers.identityGlobalRolesMutationResolver),
|
|
174
|
+
|
|
175
|
+
configure: this.resolvers.configurationMutationResolver.configure.bind(this.resolvers.configurationMutationResolver),
|
|
157
176
|
},
|
|
158
177
|
}
|
|
159
178
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigureResponse, MutationConfigureArgs, MutationResolvers } from '../../../schema'
|
|
2
|
+
import { ConfigurationManager } from '../../../model/service/ConfigurationManager'
|
|
3
|
+
import { TenantResolverContext } from '../../TenantResolverContext'
|
|
4
|
+
import { PermissionActions } from '../../../model'
|
|
5
|
+
import { createErrorResponse } from '../../errorUtils'
|
|
6
|
+
|
|
7
|
+
export class ConfigurationMutationResolver implements Pick<MutationResolvers, 'configure'> {
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly configurationManager: ConfigurationManager,
|
|
10
|
+
) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async configure(parent: any, { config }: MutationConfigureArgs, context: TenantResolverContext): Promise<ConfigureResponse> {
|
|
14
|
+
await context.requireAccess({
|
|
15
|
+
action: PermissionActions.CONFIGURE,
|
|
16
|
+
message: 'You are not allowed to configure',
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const result = await this.configurationManager.updateConfiguration(context.db, config)
|
|
20
|
+
|
|
21
|
+
if (!result.ok) {
|
|
22
|
+
return createErrorResponse(result.error, result.errorMessage)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
ok: true,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|