@contember/engine-tenant-api 2.0.0-alpha.13 → 2.0.0-alpha.15
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/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/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 +5 -1
- 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/schema/index.d.ts +258 -5
- 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/package.json +12 -12
- 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/schema/index.ts +326 -2
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-tenant-api",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"generate": "gql-gen --config graphql-tenant.codegen.yml"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/authorization": "2.0.0-alpha.
|
|
30
|
-
"@contember/config-loader": "2.0.0-alpha.
|
|
31
|
-
"@contember/database": "2.0.0-alpha.
|
|
32
|
-
"@contember/database-migrations": "2.0.0-alpha.
|
|
33
|
-
"@contember/dic": "2.0.0-alpha.
|
|
34
|
-
"@contember/graphql-utils": "2.0.0-alpha.
|
|
35
|
-
"@contember/logger": "2.0.0-alpha.
|
|
36
|
-
"@contember/schema": "2.0.0-alpha.
|
|
37
|
-
"@contember/schema-utils": "2.0.0-alpha.
|
|
38
|
-
"@contember/typesafe": "2.0.0-alpha.
|
|
29
|
+
"@contember/authorization": "2.0.0-alpha.15",
|
|
30
|
+
"@contember/config-loader": "2.0.0-alpha.15",
|
|
31
|
+
"@contember/database": "2.0.0-alpha.15",
|
|
32
|
+
"@contember/database-migrations": "2.0.0-alpha.15",
|
|
33
|
+
"@contember/dic": "2.0.0-alpha.15",
|
|
34
|
+
"@contember/graphql-utils": "2.0.0-alpha.15",
|
|
35
|
+
"@contember/logger": "2.0.0-alpha.15",
|
|
36
|
+
"@contember/schema": "2.0.0-alpha.15",
|
|
37
|
+
"@contember/schema-utils": "2.0.0-alpha.15",
|
|
38
|
+
"@contember/typesafe": "2.0.0-alpha.15",
|
|
39
39
|
"@graphql-tools/utils": "^10.0.8",
|
|
40
40
|
"graphql-tag": "^2.12.6",
|
|
41
41
|
"jose": "^5.1.1",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"otpauth": "^9.1.5"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@contember/database-tester": "2.0.0-alpha.
|
|
48
|
+
"@contember/database-tester": "2.0.0-alpha.15",
|
|
49
49
|
"@graphql-codegen/cli": "^5.0.0",
|
|
50
50
|
"@graphql-codegen/typescript": "^4.0.1",
|
|
51
51
|
"@graphql-codegen/typescript-operations": "^4.0.1",
|
package/src/TenantContainer.ts
CHANGED
|
@@ -79,6 +79,12 @@ import { UpdateIDPMutationResolver } from './resolvers/mutation/idp/UpdateIDPMut
|
|
|
79
79
|
import { TenantCredentials, TenantMigrationsRunner } from './migrations'
|
|
80
80
|
import { DisablePersonMutationResolver } from './resolvers/mutation/person/DisablePersonMutationResolver'
|
|
81
81
|
import { MailTemplateQueryResolver } from './resolvers/query/MailTemplateQueryResolver'
|
|
82
|
+
import { ConfigurationManager } from './model/service/ConfigurationManager'
|
|
83
|
+
import { ConfigurationMutationResolver } from './resolvers/mutation/configuration/ConfigurationMutationResolver'
|
|
84
|
+
import { ConfigurationQueryResolver } from './resolvers/query/ConfigurationQueryResolver'
|
|
85
|
+
import { PasswordlessMutationResolver } from './resolvers/mutation/person/PasswordlessMutationResolver'
|
|
86
|
+
import { PasswordlessSignInManager } from './model/service/PasswordlessSignInManager'
|
|
87
|
+
import { TogglePasswordlessMutationResolver } from './resolvers/mutation/person/TogglePasswordlessMutationResolver'
|
|
82
88
|
|
|
83
89
|
export interface TenantContainer {
|
|
84
90
|
projectMemberManager: ProjectMemberManager
|
|
@@ -201,6 +207,10 @@ export class TenantContainerFactory {
|
|
|
201
207
|
new MailTemplateManager())
|
|
202
208
|
.addService('rolesManager', () =>
|
|
203
209
|
new RolesManager())
|
|
210
|
+
.addService('configurationManager', () =>
|
|
211
|
+
new ConfigurationManager())
|
|
212
|
+
.addService('passwordlessSignInManager', ({ apiKeyManager, configurationManager, userMailer, projectManager, otpAuthenticator }) =>
|
|
213
|
+
new PasswordlessSignInManager(apiKeyManager, configurationManager, userMailer, projectManager, otpAuthenticator))
|
|
204
214
|
|
|
205
215
|
.addService('identityTypeResolver', ({ projectMemberManager, projectManager, permissionContextFactory }) =>
|
|
206
216
|
new IdentityTypeResolver(projectMemberManager, projectManager, permissionContextFactory))
|
|
@@ -268,6 +278,14 @@ export class TenantContainerFactory {
|
|
|
268
278
|
new SetProjectSecretMutationResolver(projectManager, secretManager))
|
|
269
279
|
.addService('identityGlobalRolesMutationResolver', ({ rolesManager }) =>
|
|
270
280
|
new IdentityGlobalRolesMutationResolver(rolesManager))
|
|
281
|
+
.addService('configurationMutationResolver', ({ configurationManager }) =>
|
|
282
|
+
new ConfigurationMutationResolver(configurationManager))
|
|
283
|
+
.addService('configurationQueryResolver', ({ configurationManager }) =>
|
|
284
|
+
new ConfigurationQueryResolver(configurationManager))
|
|
285
|
+
.addService('passwordlessMutationResolver', ({ passwordlessSignInManager, signInResponseFactory }) =>
|
|
286
|
+
new PasswordlessMutationResolver(passwordlessSignInManager, signInResponseFactory))
|
|
287
|
+
.addService('togglePasswordlessMutationResolver', ({ configurationManager, personManager }) =>
|
|
288
|
+
new TogglePasswordlessMutationResolver(configurationManager, personManager))
|
|
271
289
|
.addService('resolverContextFactory', ({ permissionContextFactory }) =>
|
|
272
290
|
new TenantResolverContextFactory(permissionContextFactory))
|
|
273
291
|
.addService('resolvers', container =>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MigrationBuilder } from '@contember/database-migrations'
|
|
2
|
+
|
|
3
|
+
const sql = `
|
|
4
|
+
CREATE TYPE CONFIG_SINGLETON AS ENUM ('singleton');
|
|
5
|
+
CREATE TYPE CONFIG_POLICY AS ENUM ('always', 'never', 'optIn', 'optOut');
|
|
6
|
+
CREATE TABLE "config"
|
|
7
|
+
(
|
|
8
|
+
id CONFIG_SINGLETON PRIMARY KEY DEFAULT 'singleton',
|
|
9
|
+
passwordless_enabled CONFIG_POLICY NOT NULL DEFAULT 'never',
|
|
10
|
+
passwordless_url TEXT,
|
|
11
|
+
passwordless_expiration_minutes INTEGER NOT NULL DEFAULT 5
|
|
12
|
+
);
|
|
13
|
+
INSERT INTO "config" (id)
|
|
14
|
+
VALUES (DEFAULT);
|
|
15
|
+
|
|
16
|
+
ALTER TABLE person_password_reset
|
|
17
|
+
RENAME TO person_token;
|
|
18
|
+
CREATE TYPE PERSON_TOKEN_TYPE AS ENUM ('password_reset', 'passwordless');
|
|
19
|
+
ALTER TABLE person_token
|
|
20
|
+
ADD COLUMN type PERSON_TOKEN_TYPE NOT NULL DEFAULT 'password_reset',
|
|
21
|
+
ADD COLUMN otp_hash TEXT DEFAULT NULL,
|
|
22
|
+
ADD COLUMN otp_attempts INTEGER NOT NULL DEFAULT 0;
|
|
23
|
+
|
|
24
|
+
ALTER TABLE person
|
|
25
|
+
ADD COLUMN passwordless_enabled BOOLEAN DEFAULT NULL;
|
|
26
|
+
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
export default async function (builder: MigrationBuilder) {
|
|
30
|
+
builder.sql(sql)
|
|
31
|
+
}
|
package/src/migrations/runner.ts
CHANGED
|
@@ -37,6 +37,7 @@ import _20230120135500personemailnormalize from './2023-01-20-135500-person-emai
|
|
|
37
37
|
import _20230603104000persondisabled from './2023-06-03-104000-person-disabled'
|
|
38
38
|
import _20230901165000idpreturnconfig from './2023-09-01-165000-idp-return-config'
|
|
39
39
|
import _20240620140000mailreply from './2024-06-20-140000-mail-reply'
|
|
40
|
+
import _20240826120000passwordless from './2024-08-26-120000-passwordless'
|
|
40
41
|
|
|
41
42
|
import snapshot from './snapshot'
|
|
42
43
|
import { computeTokenHash, Providers } from '../model'
|
|
@@ -87,6 +88,7 @@ const migrations = {
|
|
|
87
88
|
'2023-06-03-104000-person-disabled': _20230603104000persondisabled,
|
|
88
89
|
'2023-09-01-165000-idp-return-config': _20230901165000idpreturnconfig,
|
|
89
90
|
'2024-06-20-140000-mail-reply': _20240620140000mailreply,
|
|
91
|
+
'2024-08-26-120000-passwordless': _20240826120000passwordless,
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
export class TenantMigrationsRunner {
|
|
@@ -4,6 +4,19 @@ import { createCredentials } from './tenantCredentials'
|
|
|
4
4
|
|
|
5
5
|
export default async function (builder: MigrationBuilder, args: TenantMigrationArgs) {
|
|
6
6
|
builder.sql(`
|
|
7
|
+
CREATE TYPE "config_policy" AS ENUM (
|
|
8
|
+
'always',
|
|
9
|
+
'never',
|
|
10
|
+
'optIn',
|
|
11
|
+
'optOut'
|
|
12
|
+
);
|
|
13
|
+
CREATE TYPE "config_singleton" AS ENUM (
|
|
14
|
+
'singleton'
|
|
15
|
+
);
|
|
16
|
+
CREATE TYPE "person_token_type" AS ENUM (
|
|
17
|
+
'password_reset',
|
|
18
|
+
'passwordless'
|
|
19
|
+
);
|
|
7
20
|
CREATE FUNCTION "project_deleted"() RETURNS "trigger"
|
|
8
21
|
LANGUAGE "plpgsql"
|
|
9
22
|
AS $$
|
|
@@ -40,6 +53,12 @@ CREATE TABLE "api_key" (
|
|
|
40
53
|
"expiration" integer,
|
|
41
54
|
"disabled_at" timestamp with time zone
|
|
42
55
|
);
|
|
56
|
+
CREATE TABLE "config" (
|
|
57
|
+
"id" "config_singleton" DEFAULT 'singleton'::"config_singleton" NOT NULL,
|
|
58
|
+
"passwordless_enabled" "config_policy" DEFAULT 'never'::"config_policy" NOT NULL,
|
|
59
|
+
"passwordless_url" "text",
|
|
60
|
+
"passwordless_expiration_minutes" integer DEFAULT 5 NOT NULL
|
|
61
|
+
);
|
|
43
62
|
CREATE TABLE "identity" (
|
|
44
63
|
"id" "uuid" NOT NULL,
|
|
45
64
|
"parent_id" "uuid",
|
|
@@ -77,6 +96,7 @@ CREATE TABLE "person" (
|
|
|
77
96
|
"name" "text",
|
|
78
97
|
"idp_only" boolean DEFAULT false NOT NULL,
|
|
79
98
|
"disabled_at" timestamp with time zone,
|
|
99
|
+
"passwordless_enabled" boolean,
|
|
80
100
|
CONSTRAINT "idp_only_no_email" CHECK ((("idp_only" = false) OR (("idp_only" = true) AND ("email" IS NULL))))
|
|
81
101
|
);
|
|
82
102
|
CREATE TABLE "person_identity_provider" (
|
|
@@ -86,13 +106,16 @@ CREATE TABLE "person_identity_provider" (
|
|
|
86
106
|
"created_at" timestamp with time zone DEFAULT "now"() NOT NULL,
|
|
87
107
|
"external_identifier" "text" NOT NULL
|
|
88
108
|
);
|
|
89
|
-
CREATE TABLE "
|
|
109
|
+
CREATE TABLE "person_token" (
|
|
90
110
|
"id" "uuid" NOT NULL,
|
|
91
111
|
"token_hash" "text" NOT NULL,
|
|
92
112
|
"person_id" "uuid" NOT NULL,
|
|
93
113
|
"expires_at" timestamp with time zone NOT NULL,
|
|
94
114
|
"created_at" timestamp with time zone NOT NULL,
|
|
95
|
-
"used_at" timestamp with time zone
|
|
115
|
+
"used_at" timestamp with time zone,
|
|
116
|
+
"type" "person_token_type" DEFAULT 'password_reset'::"person_token_type" NOT NULL,
|
|
117
|
+
"otp_hash" "text",
|
|
118
|
+
"otp_attempts" integer DEFAULT 0 NOT NULL
|
|
96
119
|
);
|
|
97
120
|
CREATE TABLE "project" (
|
|
98
121
|
"id" "uuid" NOT NULL,
|
|
@@ -124,6 +147,8 @@ CREATE TABLE "project_secret" (
|
|
|
124
147
|
);
|
|
125
148
|
ALTER TABLE ONLY "api_key"
|
|
126
149
|
ADD CONSTRAINT "api_key_id" PRIMARY KEY ("id");
|
|
150
|
+
ALTER TABLE ONLY "config"
|
|
151
|
+
ADD CONSTRAINT "config_pkey" PRIMARY KEY ("id");
|
|
127
152
|
ALTER TABLE ONLY "person"
|
|
128
153
|
ADD CONSTRAINT "email_unique" UNIQUE ("email");
|
|
129
154
|
ALTER TABLE ONLY "identity"
|
|
@@ -140,7 +165,7 @@ ALTER TABLE ONLY "person"
|
|
|
140
165
|
ADD CONSTRAINT "person_identity_id_key" UNIQUE ("identity_id");
|
|
141
166
|
ALTER TABLE ONLY "person_identity_provider"
|
|
142
167
|
ADD CONSTRAINT "person_identity_provider_pkey" PRIMARY KEY ("id");
|
|
143
|
-
ALTER TABLE ONLY "
|
|
168
|
+
ALTER TABLE ONLY "person_token"
|
|
144
169
|
ADD CONSTRAINT "person_password_reset_id" PRIMARY KEY ("id");
|
|
145
170
|
ALTER TABLE ONLY "project"
|
|
146
171
|
ADD CONSTRAINT "project_id" PRIMARY KEY ("id");
|
|
@@ -161,7 +186,7 @@ CREATE INDEX "mail_template_project_index" ON "mail_template" USING "btree" ("pr
|
|
|
161
186
|
CREATE INDEX "person_identity_id" ON "person" USING "btree" ("identity_id");
|
|
162
187
|
CREATE UNIQUE INDEX "person_identity_provider_identifier" ON "person_identity_provider" USING "btree" ("identity_provider_id", "external_identifier");
|
|
163
188
|
CREATE INDEX "person_identity_provider_person_id" ON "person_identity_provider" USING "btree" ("person_id");
|
|
164
|
-
CREATE UNIQUE INDEX "person_password_reset_token" ON "
|
|
189
|
+
CREATE UNIQUE INDEX "person_password_reset_token" ON "person_token" USING "btree" ("token_hash");
|
|
165
190
|
CREATE INDEX "project_alias" ON "project" USING "gin" ((("config" -> 'alias'::"text")));
|
|
166
191
|
CREATE INDEX "project_membership_identity_index" ON "project_membership" USING "btree" ("identity_id");
|
|
167
192
|
CREATE UNIQUE INDEX "project_membership_unique" ON "project_membership" USING "btree" ("project_id", "identity_id", "role");
|
|
@@ -183,7 +208,7 @@ ALTER TABLE ONLY "person_identity_provider"
|
|
|
183
208
|
ADD CONSTRAINT "person_identity_provider_idp" FOREIGN KEY ("identity_provider_id") REFERENCES "identity_provider"("id") ON DELETE CASCADE;
|
|
184
209
|
ALTER TABLE ONLY "person_identity_provider"
|
|
185
210
|
ADD CONSTRAINT "person_identity_provider_person" FOREIGN KEY ("person_id") REFERENCES "person"("id") ON DELETE CASCADE;
|
|
186
|
-
ALTER TABLE ONLY "
|
|
211
|
+
ALTER TABLE ONLY "person_token"
|
|
187
212
|
ADD CONSTRAINT "person_password_reset_person" FOREIGN KEY ("person_id") REFERENCES "person"("id") ON DELETE CASCADE;
|
|
188
213
|
ALTER TABLE ONLY "project_membership"
|
|
189
214
|
ADD CONSTRAINT "project_membership_identity" FOREIGN KEY ("identity_id") REFERENCES "identity"("id") ON DELETE CASCADE;
|
|
@@ -193,6 +218,9 @@ ALTER TABLE ONLY "project_membership_variable"
|
|
|
193
218
|
ADD CONSTRAINT "project_membership_variable_membership" FOREIGN KEY ("membership_id") REFERENCES "project_membership"("id") ON DELETE CASCADE;
|
|
194
219
|
ALTER TABLE ONLY "project_secret"
|
|
195
220
|
ADD CONSTRAINT "project_secret_project" FOREIGN KEY ("project_id") REFERENCES "project"("id") ON DELETE CASCADE;
|
|
221
|
+
INSERT INTO "config" (id)
|
|
222
|
+
VALUES (DEFAULT);
|
|
223
|
+
|
|
196
224
|
DO LANGUAGE plpgsql
|
|
197
225
|
$$
|
|
198
226
|
BEGIN
|
|
@@ -13,6 +13,10 @@ namespace PermissionActions {
|
|
|
13
13
|
idp = 'idp',
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
export const CONFIGURE = Authorizator.createAction(Resources.system, 'configure')
|
|
18
|
+
export const CONFIG_VIEW = Authorizator.createAction(Resources.system, 'viewConfig')
|
|
19
|
+
|
|
16
20
|
export const IDENTITY_VIEW_PERMISSIONS = Authorizator.createAction(Resources.identity, 'viewPermissions')
|
|
17
21
|
export const IDENTITY_ADD_GLOBAL_ROLES = (roles?: readonly string[]) => Authorizator.createAction(Resources.identity, 'addGlobalRoles', { roles })
|
|
18
22
|
export const IDENTITY_REMOVE_GLOBAL_ROLES = (roles?: readonly string[]) => Authorizator.createAction(Resources.identity, 'removeGlobalRoles', { roles })
|
|
@@ -26,11 +30,14 @@ namespace PermissionActions {
|
|
|
26
30
|
export const PERSON_SETUP_OTP = Authorizator.createAction(Resources.person, 'setupOtp')
|
|
27
31
|
export const PERSON_CHANGE_PROFILE = (roles?: readonly string[]) => Authorizator.createAction(Resources.person, 'changeProfile', { roles })
|
|
28
32
|
export const PERSON_CHANGE_MY_PROFILE = Authorizator.createAction(Resources.person, 'changeMyProfile')
|
|
33
|
+
export const PERSON_TOGGLE_PASSWORDLESS = Authorizator.createAction(Resources.person, 'togglePasswordless')
|
|
29
34
|
export const PERSON_CHANGE_PASSWORD = (roles?: readonly string[]) => Authorizator.createAction(Resources.person, 'changePassword', { roles })
|
|
30
35
|
export const PERSON_CHANGE_MY_PASSWORD = Authorizator.createAction(Resources.person, 'changeMyPassword')
|
|
31
36
|
export const PERSON_RESET_PASSWORD = Authorizator.createAction(Resources.person, 'resetPassword')
|
|
32
37
|
export const PERSON_CREATE_IDP_URL = Authorizator.createAction(Resources.person, 'createIdPUrl')
|
|
33
38
|
export const PERSON_SIGN_IN_IDP = Authorizator.createAction(Resources.person, 'signInIdp')
|
|
39
|
+
export const PERSON_REQUEST_PASSWORDLESS_SIGN_IN = Authorizator.createAction(Resources.person, 'requestPasswordlessSignIn')
|
|
40
|
+
export const PERSON_PASSWORDLESS_SIGN_IN = Authorizator.createAction(Resources.person, 'passwordlessSignIn')
|
|
34
41
|
export const PERSON_CREATE_SESSION_KEY = (roles?: readonly string[]) => Authorizator.createAction(Resources.person, 'createSessionToken', { roles })
|
|
35
42
|
|
|
36
43
|
export const PERSON_INVITE = (memberships: readonly Acl.Membership[]) => Authorizator.createAction(Resources.person, 'invite', { memberships })
|
|
@@ -24,10 +24,13 @@ class PermissionsFactory {
|
|
|
24
24
|
permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_RESET_PASSWORD)
|
|
25
25
|
permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_CREATE_IDP_URL)
|
|
26
26
|
permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_SIGN_IN_IDP)
|
|
27
|
+
permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_PASSWORDLESS_SIGN_IN)
|
|
28
|
+
permissions.allow(TenantRole.LOGIN, PermissionActions.PERSON_REQUEST_PASSWORDLESS_SIGN_IN)
|
|
27
29
|
|
|
28
30
|
permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_VIEW)
|
|
29
31
|
permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_CHANGE_MY_PASSWORD)
|
|
30
32
|
permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_CHANGE_MY_PROFILE)
|
|
33
|
+
permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_TOGGLE_PASSWORDLESS)
|
|
31
34
|
permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_SIGN_OUT)
|
|
32
35
|
permissions.allow(TenantRole.PERSON, PermissionActions.PERSON_SETUP_OTP)
|
|
33
36
|
|
|
@@ -65,6 +68,8 @@ class PermissionsFactory {
|
|
|
65
68
|
permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.IDP_LIST)
|
|
66
69
|
|
|
67
70
|
permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.ENTRYPOINT_DEPLOY)
|
|
71
|
+
permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.CONFIGURE)
|
|
72
|
+
permissions.allow(TenantRole.PROJECT_ADMIN, PermissionActions.CONFIG_VIEW)
|
|
68
73
|
|
|
69
74
|
permissions.allow(TenantRole.PROJECT_CREATOR, PermissionActions.PROJECT_CREATE)
|
|
70
75
|
permissions.allow(TenantRole.ENTRYPOINT_DEPLOYER, PermissionActions.ENTRYPOINT_DEPLOY)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { ConfigInput } from '../../../schema'
|
|
3
|
+
import { UpdateBuilder } from '@contember/database'
|
|
4
|
+
|
|
5
|
+
export class UpdateConfigurationCommand implements Command<void> {
|
|
6
|
+
constructor(
|
|
7
|
+
private readonly configuration: ConfigInput,
|
|
8
|
+
) {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async execute({ db }: Command.Args): Promise<void> {
|
|
12
|
+
const result = await UpdateBuilder.create()
|
|
13
|
+
.table('config')
|
|
14
|
+
.where({ id: 'singleton' })
|
|
15
|
+
.values({
|
|
16
|
+
passwordless_enabled: this.configuration.passwordless?.enabled,
|
|
17
|
+
passwordless_url: this.configuration.passwordless?.url,
|
|
18
|
+
passwordless_expiration_minutes: this.configuration.passwordless?.expirationMinutes,
|
|
19
|
+
})
|
|
20
|
+
.execute(db)
|
|
21
|
+
if (!result) {
|
|
22
|
+
throw new Error('Configuration not found')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './UpdateConfigurationCommand'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './apiKey'
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './configuration'
|
|
3
3
|
export * from './person'
|
|
4
4
|
export * from './Command'
|
|
5
5
|
export * from './CommandBus'
|
|
@@ -8,4 +8,4 @@ export * from './project'
|
|
|
8
8
|
export * from './mailTemplate'
|
|
9
9
|
export * from './membership'
|
|
10
10
|
export * from './otp'
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './personToken'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { UpdateBuilder } from '@contember/database'
|
|
3
|
+
|
|
4
|
+
export class TogglePersonPasswordlessCommand implements Command<void> {
|
|
5
|
+
constructor(private readonly personId: string, private readonly value: boolean | null) { }
|
|
6
|
+
|
|
7
|
+
async execute({ db }: Command.Args): Promise<void> {
|
|
8
|
+
await UpdateBuilder.create()
|
|
9
|
+
.table('person')
|
|
10
|
+
.values({
|
|
11
|
+
passwordless_enabled: this.value,
|
|
12
|
+
})
|
|
13
|
+
.where({
|
|
14
|
+
id: this.personId,
|
|
15
|
+
})
|
|
16
|
+
.execute(db)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { UpdateBuilder } from '@contember/database'
|
|
3
|
+
import { ImplementationException } from '../../../exceptions'
|
|
4
|
+
|
|
5
|
+
export class ActivateOtpCommand implements Command<void> {
|
|
6
|
+
constructor(
|
|
7
|
+
private readonly id: string,
|
|
8
|
+
private readonly otpHash: string,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
async execute({ db, providers }: Command.Args): Promise<void> {
|
|
12
|
+
const count = await UpdateBuilder.create()
|
|
13
|
+
.table('person_token')
|
|
14
|
+
.where({ id: this.id })
|
|
15
|
+
.values({
|
|
16
|
+
otp_hash: this.otpHash,
|
|
17
|
+
})
|
|
18
|
+
.execute(db)
|
|
19
|
+
|
|
20
|
+
if (count === 0) {
|
|
21
|
+
throw new ImplementationException()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { computeTokenHash, generateToken } from '../../utils'
|
|
3
|
+
import { SavePersonTokenCommand } from './SavePersonTokenCommand'
|
|
4
|
+
import { PersonToken } from '../../type'
|
|
5
|
+
import { PASSWORD_RESET_EXPIRATION_MINUTES } from '../../consts/expirations'
|
|
6
|
+
|
|
7
|
+
export class CreatePersonTokenCommand implements Command<CreatePersonTokenCommand.Result> {
|
|
8
|
+
private constructor(
|
|
9
|
+
private readonly personId: string,
|
|
10
|
+
private readonly type: PersonToken.Type,
|
|
11
|
+
private readonly expirationMinutes: number,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
static createPasswordResetRequest(personId: string, expirationMinutes: number = PASSWORD_RESET_EXPIRATION_MINUTES): CreatePersonTokenCommand {
|
|
15
|
+
return new CreatePersonTokenCommand(personId, 'password_reset', expirationMinutes)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static createPasswordlessRequest(personId: string, expirationMinutes: number): CreatePersonTokenCommand {
|
|
19
|
+
return new CreatePersonTokenCommand(personId, 'passwordless', expirationMinutes)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async execute({ db, providers, bus }: Command.Args): Promise<CreatePersonTokenCommand.Result> {
|
|
23
|
+
const token = await generateToken(providers)
|
|
24
|
+
const tokenHash = computeTokenHash(token)
|
|
25
|
+
const result = await bus.execute(new SavePersonTokenCommand(
|
|
26
|
+
this.personId,
|
|
27
|
+
tokenHash,
|
|
28
|
+
this.type,
|
|
29
|
+
this.expirationMinutes,
|
|
30
|
+
))
|
|
31
|
+
|
|
32
|
+
return { ...result, token }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
namespace CreatePersonTokenCommand {
|
|
37
|
+
export interface Result {
|
|
38
|
+
readonly id: string
|
|
39
|
+
readonly token: string
|
|
40
|
+
readonly expiresAt: Date
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { Literal, UpdateBuilder } from '@contember/database'
|
|
3
|
+
import { ImplementationException } from '../../../exceptions'
|
|
4
|
+
|
|
5
|
+
export class IncreaseOtpAttemptCommand implements Command<void> {
|
|
6
|
+
constructor(
|
|
7
|
+
private readonly id: string,
|
|
8
|
+
) {}
|
|
9
|
+
|
|
10
|
+
async execute({ db, providers }: Command.Args): Promise<void> {
|
|
11
|
+
const count = await UpdateBuilder.create()
|
|
12
|
+
.table('person_token')
|
|
13
|
+
.where({ id: this.id })
|
|
14
|
+
.values({
|
|
15
|
+
otp_attempts: new Literal('otp_attempts + 1'),
|
|
16
|
+
})
|
|
17
|
+
.execute(db)
|
|
18
|
+
|
|
19
|
+
if (count === 0) {
|
|
20
|
+
throw new ImplementationException()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { UpdateBuilder } from '@contember/database'
|
|
3
|
+
import { ImplementationException } from '../../../exceptions'
|
|
4
|
+
|
|
5
|
+
export class InvalidateTokenCommand implements Command<void> {
|
|
6
|
+
constructor(private readonly id: string) {}
|
|
7
|
+
|
|
8
|
+
async execute({ db, providers }: Command.Args): Promise<void> {
|
|
9
|
+
const count = await UpdateBuilder.create()
|
|
10
|
+
.table('person_token')
|
|
11
|
+
.where({ id: this.id })
|
|
12
|
+
.where(expr => expr.isNull('used_at'))
|
|
13
|
+
.values({
|
|
14
|
+
used_at: providers.now(),
|
|
15
|
+
})
|
|
16
|
+
.execute(db)
|
|
17
|
+
|
|
18
|
+
if (count === 0) {
|
|
19
|
+
throw new ImplementationException()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { ChangePasswordCommand } from '../person/ChangePasswordCommand'
|
|
3
|
+
import { Response, ResponseOk } from '../../utils/Response'
|
|
4
|
+
import { PersonTokenQuery } from '../../queries/personToken/PersonTokenQuery'
|
|
5
|
+
import { InvalidateTokenCommand } from './InvalidateTokenCommand'
|
|
6
|
+
import { validateToken } from '../../utils'
|
|
7
|
+
import { PersonToken } from '../../type'
|
|
8
|
+
|
|
9
|
+
export class ResetPasswordCommand implements Command<ResetPasswordCommandResponse> {
|
|
10
|
+
constructor(private readonly token: string, private readonly password: string) {}
|
|
11
|
+
|
|
12
|
+
async execute({ db, providers, bus }: Command.Args): Promise<ResetPasswordCommandResponse> {
|
|
13
|
+
const now = providers.now()
|
|
14
|
+
const token = await db.createQueryHandler().fetch(PersonTokenQuery.byToken(this.token, 'password_reset'))
|
|
15
|
+
const tokenValidationResult = validateToken({ entry: token, token: this.token, now, validationType: 'token' })
|
|
16
|
+
if (!tokenValidationResult.ok) {
|
|
17
|
+
return tokenValidationResult
|
|
18
|
+
}
|
|
19
|
+
await bus.execute(new InvalidateTokenCommand(tokenValidationResult.result.id))
|
|
20
|
+
await bus.execute(new ChangePasswordCommand(tokenValidationResult.result.person_id, this.password))
|
|
21
|
+
|
|
22
|
+
return new ResponseOk(null)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export type ResetPasswordCommandErrorCode =
|
|
26
|
+
| PersonToken.TokenValidationError
|
|
27
|
+
|
|
28
|
+
export type ResetPasswordCommandResponse = Response<null, PersonToken.TokenValidationError>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command } from '../Command'
|
|
2
|
+
import { InsertBuilder } from '@contember/database'
|
|
3
|
+
import { plusMinutes } from '../../utils/time'
|
|
4
|
+
import { TokenHash } from '../../utils'
|
|
5
|
+
import { PersonToken } from '../../type'
|
|
6
|
+
|
|
7
|
+
class SavePersonTokenCommand implements Command<SavePersonTokenCommand.Result> {
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly personId: string,
|
|
10
|
+
private readonly tokenHash: TokenHash,
|
|
11
|
+
private readonly type: PersonToken.Type,
|
|
12
|
+
private readonly expirationMinutes: number,
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
async execute({ db, providers }: Command.Args): Promise<SavePersonTokenCommand.Result> {
|
|
16
|
+
const id = providers.uuid()
|
|
17
|
+
const expiresAt = plusMinutes(providers.now(), this.expirationMinutes)
|
|
18
|
+
await InsertBuilder.create()
|
|
19
|
+
.into('person_token')
|
|
20
|
+
.values({
|
|
21
|
+
id: id,
|
|
22
|
+
token_hash: this.tokenHash,
|
|
23
|
+
person_id: this.personId,
|
|
24
|
+
expires_at: expiresAt,
|
|
25
|
+
created_at: providers.now(),
|
|
26
|
+
used_at: null,
|
|
27
|
+
type: this.type,
|
|
28
|
+
})
|
|
29
|
+
.execute(db)
|
|
30
|
+
|
|
31
|
+
return { id, expiresAt }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
namespace SavePersonTokenCommand {
|
|
36
|
+
export interface Result {
|
|
37
|
+
id: string
|
|
38
|
+
expiresAt: Date
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { SavePersonTokenCommand }
|
|
@@ -2,6 +2,7 @@ import { Mailer, TemplateRenderer } from '../../utils'
|
|
|
2
2
|
import NewUserInvited from './templates/NewUserInvited.mustache'
|
|
3
3
|
import ExistingUserInvited from './templates/ExistingUserInvited.mustache'
|
|
4
4
|
import PasswordReset from './templates/PasswordReset.mustache'
|
|
5
|
+
import PasswordlessSignIn from './templates/PasswordlessSignIn.mustache'
|
|
5
6
|
import { MailTemplateData, MailTemplateIdentifier, MailType } from './type'
|
|
6
7
|
import { MailTemplateQuery } from '../queries'
|
|
7
8
|
import Layout from './templates/Layout.mustache'
|
|
@@ -52,6 +53,19 @@ export class UserMailer {
|
|
|
52
53
|
await this.sendTemplate(template, mailArguments)
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
async sendPasswordlessEmail(
|
|
57
|
+
dbContext: DatabaseContext,
|
|
58
|
+
mailArguments: { email: string; token: string; project?: string; projectSlug?: string; url?: string },
|
|
59
|
+
customMailOptions: { projectId: string | null; variant: string },
|
|
60
|
+
): Promise<void> {
|
|
61
|
+
const template = (await this.getCustomTemplate(dbContext, { type: MailType.passwordlessSignIn, ...customMailOptions })) || {
|
|
62
|
+
subject: 'Sign in here',
|
|
63
|
+
content: PasswordlessSignIn,
|
|
64
|
+
replyTo: null,
|
|
65
|
+
}
|
|
66
|
+
await this.sendTemplate(template, mailArguments)
|
|
67
|
+
}
|
|
68
|
+
|
|
55
69
|
private async sendTemplate(
|
|
56
70
|
template: Pick<MailTemplateData, 'subject' | 'content' | 'replyTo'>,
|
|
57
71
|
mailArguments: Record<string, any>,
|
|
@@ -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
|
|