rl-core-api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +19 -0
- package/dist/core/auth/authenticatedUser.interface.d.ts +16 -0
- package/dist/core/auth/authenticatedUser.interface.js +2 -0
- package/dist/core/auth/cookie.util.d.ts +9 -0
- package/dist/core/auth/cookie.util.js +28 -0
- package/dist/core/auth/decorators/currentUser.decorator.d.ts +2 -0
- package/dist/core/auth/decorators/currentUser.decorator.js +9 -0
- package/dist/core/auth/decorators/public.decorator.d.ts +3 -0
- package/dist/core/auth/decorators/public.decorator.js +7 -0
- package/dist/core/auth/decorators/requirePermission.decorator.d.ts +5 -0
- package/dist/core/auth/decorators/requirePermission.decorator.js +10 -0
- package/dist/core/auth/guards/appThrottler.guard.d.ts +5 -0
- package/dist/core/auth/guards/appThrottler.guard.js +23 -0
- package/dist/core/auth/guards/csrf.guard.d.ts +8 -0
- package/dist/core/auth/guards/csrf.guard.js +55 -0
- package/dist/core/auth/guards/jwtAuth.guard.d.ts +10 -0
- package/dist/core/auth/guards/jwtAuth.guard.js +37 -0
- package/dist/core/auth/guards/permissions.guard.d.ts +7 -0
- package/dist/core/auth/guards/permissions.guard.js +42 -0
- package/dist/core/bootstrap/bootstrapCore.util.d.ts +9 -0
- package/dist/core/bootstrap/bootstrapCore.util.js +67 -0
- package/dist/core/config/config.module.d.ts +8 -0
- package/dist/core/config/config.module.js +34 -0
- package/dist/core/config/env.schema.d.ts +65 -0
- package/dist/core/config/env.schema.js +94 -0
- package/dist/core/config/env.service.d.ts +7 -0
- package/dist/core/config/env.service.js +27 -0
- package/dist/core/context/auditContext.d.ts +7 -0
- package/dist/core/context/auditContext.js +5 -0
- package/dist/core/core.module.d.ts +11 -0
- package/dist/core/core.module.js +73 -0
- package/dist/core/database/base.schema.d.ts +7 -0
- package/dist/core/database/base.schema.js +49 -0
- package/dist/core/database/createDataSource.util.d.ts +8 -0
- package/dist/core/database/createDataSource.util.js +27 -0
- package/dist/core/database/migrations/1710000000000-InitialSchema.d.ts +6 -0
- package/dist/core/database/migrations/1710000000000-InitialSchema.js +272 -0
- package/dist/core/database/migrations/1786060800000-FirstAccessTokenType.d.ts +6 -0
- package/dist/core/database/migrations/1786060800000-FirstAccessTokenType.js +19 -0
- package/dist/core/database/migrations/1786147200000-PermanentAccountLock.d.ts +6 -0
- package/dist/core/database/migrations/1786147200000-PermanentAccountLock.js +15 -0
- package/dist/core/database/migrations/1786233600000-Notifications.d.ts +6 -0
- package/dist/core/database/migrations/1786233600000-Notifications.js +59 -0
- package/dist/core/database/migrations/index.d.ts +3 -0
- package/dist/core/database/migrations/index.js +13 -0
- package/dist/core/database/seeds/runSeeds.d.ts +1 -0
- package/dist/core/database/seeds/runSeeds.js +20 -0
- package/dist/core/database/seeds/seedAdmin.d.ts +2 -0
- package/dist/core/database/seeds/seedAdmin.js +44 -0
- package/dist/core/database/seeds/seedPermissions.d.ts +2 -0
- package/dist/core/database/seeds/seedPermissions.js +93 -0
- package/dist/core/events/appEvent.enum.d.ts +31 -0
- package/dist/core/events/appEvent.enum.js +12 -0
- package/dist/core/filters/allExceptions.filter.d.ts +5 -0
- package/dist/core/filters/allExceptions.filter.js +61 -0
- package/dist/core/filters/appErrorCode.enum.d.ts +9 -0
- package/dist/core/filters/appErrorCode.enum.js +13 -0
- package/dist/core/health/health.controller.d.ts +11 -0
- package/dist/core/health/health.controller.js +56 -0
- package/dist/core/logger/winston.config.d.ts +2 -0
- package/dist/core/logger/winston.config.js +74 -0
- package/dist/core/mailer/mailer.module.d.ts +2 -0
- package/dist/core/mailer/mailer.module.js +21 -0
- package/dist/core/mailer/mailer.service.d.ts +14 -0
- package/dist/core/mailer/mailer.service.js +148 -0
- package/dist/core/openapi/exportOpenapi.d.ts +1 -0
- package/dist/core/openapi/exportOpenapi.js +25 -0
- package/dist/core/query/applyFilter.util.d.ts +11 -0
- package/dist/core/query/applyFilter.util.js +122 -0
- package/dist/core/query/filter.constants.d.ts +7 -0
- package/dist/core/query/filter.constants.js +64 -0
- package/dist/core/query/filterField.interface.d.ts +35 -0
- package/dist/core/query/filterField.interface.js +2 -0
- package/dist/core/query/filterFieldType.enum.d.ts +10 -0
- package/dist/core/query/filterFieldType.enum.js +14 -0
- package/dist/core/query/filterOperator.enum.d.ts +23 -0
- package/dist/core/query/filterOperator.enum.js +28 -0
- package/dist/core/query/filterSchema.response.d.ts +17 -0
- package/dist/core/query/filterSchema.response.js +82 -0
- package/dist/core/query/filterSort.util.d.ts +7 -0
- package/dist/core/query/filterSort.util.js +11 -0
- package/dist/core/query/paginateWithFilter.util.d.ts +11 -0
- package/dist/core/query/paginateWithFilter.util.js +37 -0
- package/dist/core/query/parseFilter.util.d.ts +2 -0
- package/dist/core/query/parseFilter.util.js +220 -0
- package/dist/core/utils/codedError.util.d.ts +5 -0
- package/dist/core/utils/codedError.util.js +23 -0
- package/dist/core/utils/crypto.util.d.ts +2 -0
- package/dist/core/utils/crypto.util.js +39 -0
- package/dist/core/utils/hash.util.d.ts +6 -0
- package/dist/core/utils/hash.util.js +67 -0
- package/dist/core/utils/ip.util.d.ts +1 -0
- package/dist/core/utils/ip.util.js +15 -0
- package/dist/core/utils/pagination.util.d.ts +21 -0
- package/dist/core/utils/pagination.util.js +98 -0
- package/dist/core/utils/paginationMeta.response.d.ts +7 -0
- package/dist/core/utils/paginationMeta.response.js +32 -0
- package/dist/core/utils/password.constants.d.ts +2 -0
- package/dist/core/utils/password.constants.js +5 -0
- package/dist/core/websocket/baseGateway.d.ts +21 -0
- package/dist/core/websocket/baseGateway.js +63 -0
- package/dist/core/websocket/socket.constants.d.ts +4 -0
- package/dist/core/websocket/socket.constants.js +9 -0
- package/dist/core/websocket/socketEvent.envelope.d.ts +8 -0
- package/dist/core/websocket/socketEvent.envelope.js +11 -0
- package/dist/core/websocket/socketOrigin.util.d.ts +2 -0
- package/dist/core/websocket/socketOrigin.util.js +15 -0
- package/dist/core/websocket/wsAuth.service.d.ts +20 -0
- package/dist/core/websocket/wsAuth.service.js +97 -0
- package/dist/core/websocket/wsUserResolver.interface.d.ts +5 -0
- package/dist/core/websocket/wsUserResolver.interface.js +4 -0
- package/dist/coreEntities.d.ts +12 -0
- package/dist/coreEntities.js +35 -0
- package/dist/dataSource.d.ts +3 -0
- package/dist/dataSource.js +13 -0
- package/dist/features/audit/audit.module.d.ts +2 -0
- package/dist/features/audit/audit.module.js +44 -0
- package/dist/features/audit/domain/audit.service.d.ts +34 -0
- package/dist/features/audit/domain/audit.service.js +93 -0
- package/dist/features/audit/domain/classifyError.util.d.ts +2 -0
- package/dist/features/audit/domain/classifyError.util.js +24 -0
- package/dist/features/audit/domain/index.d.ts +2 -0
- package/dist/features/audit/domain/index.js +18 -0
- package/dist/features/audit/infra/auditData.subscriber.d.ts +17 -0
- package/dist/features/audit/infra/auditData.subscriber.js +139 -0
- package/dist/features/audit/infra/index.d.ts +7 -0
- package/dist/features/audit/infra/index.js +23 -0
- package/dist/features/audit/infra/repositories/auditChange.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/auditChange.repository.js +35 -0
- package/dist/features/audit/infra/repositories/auditDataChange.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/auditDataChange.repository.js +35 -0
- package/dist/features/audit/infra/repositories/errorLog.repository.d.ts +7 -0
- package/dist/features/audit/infra/repositories/errorLog.repository.js +35 -0
- package/dist/features/audit/infra/schema/auditChange.schema.d.ts +14 -0
- package/dist/features/audit/infra/schema/auditChange.schema.js +68 -0
- package/dist/features/audit/infra/schema/auditDataChange.schema.d.ts +15 -0
- package/dist/features/audit/infra/schema/auditDataChange.schema.js +56 -0
- package/dist/features/audit/infra/schema/errorLog.schema.d.ts +21 -0
- package/dist/features/audit/infra/schema/errorLog.schema.js +69 -0
- package/dist/features/audit/presentation/audit.controller.d.ts +16 -0
- package/dist/features/audit/presentation/audit.controller.js +107 -0
- package/dist/features/audit/presentation/audit.interceptor.d.ts +8 -0
- package/dist/features/audit/presentation/audit.interceptor.js +78 -0
- package/dist/features/audit/presentation/filters/audit.filters.d.ts +4 -0
- package/dist/features/audit/presentation/filters/audit.filters.js +154 -0
- package/dist/features/audit/presentation/index.d.ts +2 -0
- package/dist/features/audit/presentation/index.js +18 -0
- package/dist/features/audit/presentation/responses/auditDataChange.response.d.ts +25 -0
- package/dist/features/audit/presentation/responses/auditDataChange.response.js +96 -0
- package/dist/features/audit/presentation/responses/log.response.d.ts +45 -0
- package/dist/features/audit/presentation/responses/log.response.js +164 -0
- package/dist/features/auth/auth.module.d.ts +2 -0
- package/dist/features/auth/auth.module.js +55 -0
- package/dist/features/auth/domain/auth.service.d.ts +66 -0
- package/dist/features/auth/domain/auth.service.js +289 -0
- package/dist/features/auth/domain/index.d.ts +5 -0
- package/dist/features/auth/domain/index.js +21 -0
- package/dist/features/auth/domain/jwtPayload.interface.d.ts +11 -0
- package/dist/features/auth/domain/jwtPayload.interface.js +2 -0
- package/dist/features/auth/domain/token.service.d.ts +56 -0
- package/dist/features/auth/domain/token.service.js +205 -0
- package/dist/features/auth/domain/twoFactor.service.d.ts +19 -0
- package/dist/features/auth/domain/twoFactor.service.js +103 -0
- package/dist/features/auth/domain/wsUserResolver.service.d.ts +10 -0
- package/dist/features/auth/domain/wsUserResolver.service.js +34 -0
- package/dist/features/auth/infra/index.d.ts +2 -0
- package/dist/features/auth/infra/index.js +18 -0
- package/dist/features/auth/infra/repositories/authToken.repository.d.ts +5 -0
- package/dist/features/auth/infra/repositories/authToken.repository.js +25 -0
- package/dist/features/auth/infra/schema/authToken.schema.d.ts +21 -0
- package/dist/features/auth/infra/schema/authToken.schema.js +73 -0
- package/dist/features/auth/presentation/auth.controller.d.ts +56 -0
- package/dist/features/auth/presentation/auth.controller.js +242 -0
- package/dist/features/auth/presentation/commands/clientType.enum.d.ts +4 -0
- package/dist/features/auth/presentation/commands/clientType.enum.js +8 -0
- package/dist/features/auth/presentation/commands/login.command.d.ts +4 -0
- package/dist/features/auth/presentation/commands/login.command.js +28 -0
- package/dist/features/auth/presentation/commands/password.command.d.ts +7 -0
- package/dist/features/auth/presentation/commands/password.command.js +37 -0
- package/dist/features/auth/presentation/commands/refreshToken.command.d.ts +3 -0
- package/dist/features/auth/presentation/commands/refreshToken.command.js +26 -0
- package/dist/features/auth/presentation/commands/twoFactor.command.d.ts +12 -0
- package/dist/features/auth/presentation/commands/twoFactor.command.js +68 -0
- package/dist/features/auth/presentation/index.d.ts +7 -0
- package/dist/features/auth/presentation/index.js +23 -0
- package/dist/features/auth/presentation/responses/sessionUser.response.d.ts +19 -0
- package/dist/features/auth/presentation/responses/sessionUser.response.js +90 -0
- package/dist/features/auth/presentation/strategies/jwt.strategy.d.ts +18 -0
- package/dist/features/auth/presentation/strategies/jwt.strategy.js +59 -0
- package/dist/features/auth/token.module.d.ts +2 -0
- package/dist/features/auth/token.module.js +23 -0
- package/dist/features/maintenance/domain/cleanup.service.d.ts +22 -0
- package/dist/features/maintenance/domain/cleanup.service.js +142 -0
- package/dist/features/maintenance/maintenance.module.d.ts +2 -0
- package/dist/features/maintenance/maintenance.module.js +24 -0
- package/dist/features/notifications/domain/enums/channelType.enum.d.ts +7 -0
- package/dist/features/notifications/domain/enums/channelType.enum.js +11 -0
- package/dist/features/notifications/domain/enums/deliveryStatus.enum.d.ts +8 -0
- package/dist/features/notifications/domain/enums/deliveryStatus.enum.js +12 -0
- package/dist/features/notifications/domain/enums/notificationType.enum.d.ts +6 -0
- package/dist/features/notifications/domain/enums/notificationType.enum.js +10 -0
- package/dist/features/notifications/domain/enums/scopeType.enum.d.ts +5 -0
- package/dist/features/notifications/domain/enums/scopeType.enum.js +9 -0
- package/dist/features/notifications/domain/notifications.service.d.ts +45 -0
- package/dist/features/notifications/domain/notifications.service.js +101 -0
- package/dist/features/notifications/infra/repositories/notification.repository.d.ts +14 -0
- package/dist/features/notifications/infra/repositories/notification.repository.js +74 -0
- package/dist/features/notifications/infra/repositories/notificationRead.repository.d.ts +6 -0
- package/dist/features/notifications/infra/repositories/notificationRead.repository.js +40 -0
- package/dist/features/notifications/infra/repositories/notificationScope.repository.d.ts +5 -0
- package/dist/features/notifications/infra/repositories/notificationScope.repository.js +25 -0
- package/dist/features/notifications/infra/schema/notification.schema.d.ts +13 -0
- package/dist/features/notifications/infra/schema/notification.schema.js +52 -0
- package/dist/features/notifications/infra/schema/notificationRead.schema.d.ts +7 -0
- package/dist/features/notifications/infra/schema/notificationRead.schema.js +38 -0
- package/dist/features/notifications/infra/schema/notificationScope.schema.d.ts +9 -0
- package/dist/features/notifications/infra/schema/notificationScope.schema.js +43 -0
- package/dist/features/notifications/notifications.module.d.ts +2 -0
- package/dist/features/notifications/notifications.module.js +45 -0
- package/dist/features/notifications/presentation/commands/createNotification.command.d.ts +13 -0
- package/dist/features/notifications/presentation/commands/createNotification.command.js +72 -0
- package/dist/features/notifications/presentation/domainEvents.listener.d.ts +13 -0
- package/dist/features/notifications/presentation/domainEvents.listener.js +121 -0
- package/dist/features/notifications/presentation/notifications.controller.d.ts +16 -0
- package/dist/features/notifications/presentation/notifications.controller.js +108 -0
- package/dist/features/notifications/presentation/notifications.gateway.d.ts +13 -0
- package/dist/features/notifications/presentation/notifications.gateway.js +58 -0
- package/dist/features/notifications/presentation/notifications.publisher.d.ts +9 -0
- package/dist/features/notifications/presentation/notifications.publisher.js +42 -0
- package/dist/features/notifications/presentation/responses/notification.response.d.ts +18 -0
- package/dist/features/notifications/presentation/responses/notification.response.js +72 -0
- package/dist/features/rbac/domain/index.d.ts +2 -0
- package/dist/features/rbac/domain/index.js +18 -0
- package/dist/features/rbac/domain/rbac.catalog.d.ts +21 -0
- package/dist/features/rbac/domain/rbac.catalog.js +153 -0
- package/dist/features/rbac/domain/rbac.service.d.ts +68 -0
- package/dist/features/rbac/domain/rbac.service.js +436 -0
- package/dist/features/rbac/infra/index.d.ts +12 -0
- package/dist/features/rbac/infra/index.js +28 -0
- package/dist/features/rbac/infra/repositories/action.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/action.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/group.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/group.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/permission.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/permission.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/resource.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/resource.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/role.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/role.repository.js +25 -0
- package/dist/features/rbac/infra/repositories/scope.repository.d.ts +5 -0
- package/dist/features/rbac/infra/repositories/scope.repository.js +25 -0
- package/dist/features/rbac/infra/schema/action.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/action.schema.js +36 -0
- package/dist/features/rbac/infra/schema/group.schema.d.ts +12 -0
- package/dist/features/rbac/infra/schema/group.schema.js +60 -0
- package/dist/features/rbac/infra/schema/permission.schema.d.ts +15 -0
- package/dist/features/rbac/infra/schema/permission.schema.js +66 -0
- package/dist/features/rbac/infra/schema/resource.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/resource.schema.js +36 -0
- package/dist/features/rbac/infra/schema/role.schema.d.ts +8 -0
- package/dist/features/rbac/infra/schema/role.schema.js +46 -0
- package/dist/features/rbac/infra/schema/scope.schema.d.ts +6 -0
- package/dist/features/rbac/infra/schema/scope.schema.js +36 -0
- package/dist/features/rbac/presentation/commands/createAction.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createAction.command.js +32 -0
- package/dist/features/rbac/presentation/commands/createGroup.command.d.ts +7 -0
- package/dist/features/rbac/presentation/commands/createGroup.command.js +54 -0
- package/dist/features/rbac/presentation/commands/createPermission.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createPermission.command.js +35 -0
- package/dist/features/rbac/presentation/commands/createResource.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createResource.command.js +32 -0
- package/dist/features/rbac/presentation/commands/createRole.command.d.ts +5 -0
- package/dist/features/rbac/presentation/commands/createRole.command.js +38 -0
- package/dist/features/rbac/presentation/commands/createScope.command.d.ts +4 -0
- package/dist/features/rbac/presentation/commands/createScope.command.js +32 -0
- package/dist/features/rbac/presentation/commands/updateAction.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateAction.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateGroup.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateGroup.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updatePermission.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updatePermission.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateResource.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateResource.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateRole.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateRole.command.js +24 -0
- package/dist/features/rbac/presentation/commands/updateScope.command.d.ts +6 -0
- package/dist/features/rbac/presentation/commands/updateScope.command.js +24 -0
- package/dist/features/rbac/presentation/index.d.ts +13 -0
- package/dist/features/rbac/presentation/index.js +29 -0
- package/dist/features/rbac/presentation/rbac.controller.d.ts +54 -0
- package/dist/features/rbac/presentation/rbac.controller.js +413 -0
- package/dist/features/rbac/presentation/responses/rbac.response.d.ts +47 -0
- package/dist/features/rbac/presentation/responses/rbac.response.js +161 -0
- package/dist/features/rbac/rbac.module.d.ts +2 -0
- package/dist/features/rbac/rbac.module.js +55 -0
- package/dist/features/users/domain/avatar.service.d.ts +4 -0
- package/dist/features/users/domain/avatar.service.js +61 -0
- package/dist/features/users/domain/index.d.ts +2 -0
- package/dist/features/users/domain/index.js +18 -0
- package/dist/features/users/domain/users.service.d.ts +46 -0
- package/dist/features/users/domain/users.service.js +291 -0
- package/dist/features/users/infra/index.d.ts +4 -0
- package/dist/features/users/infra/index.js +20 -0
- package/dist/features/users/infra/repositories/passwordHistory.repository.d.ts +5 -0
- package/dist/features/users/infra/repositories/passwordHistory.repository.js +25 -0
- package/dist/features/users/infra/repositories/user.repository.d.ts +8 -0
- package/dist/features/users/infra/repositories/user.repository.js +56 -0
- package/dist/features/users/infra/schema/passwordHistory.schema.d.ts +5 -0
- package/dist/features/users/infra/schema/passwordHistory.schema.js +29 -0
- package/dist/features/users/infra/schema/user.schema.d.ts +28 -0
- package/dist/features/users/infra/schema/user.schema.js +153 -0
- package/dist/features/users/presentation/commands/changePassword.command.d.ts +4 -0
- package/dist/features/users/presentation/commands/changePassword.command.js +29 -0
- package/dist/features/users/presentation/commands/createUser.command.d.ts +8 -0
- package/dist/features/users/presentation/commands/createUser.command.js +56 -0
- package/dist/features/users/presentation/commands/updateProfile.command.d.ts +5 -0
- package/dist/features/users/presentation/commands/updateProfile.command.js +38 -0
- package/dist/features/users/presentation/commands/updateUser.command.d.ts +5 -0
- package/dist/features/users/presentation/commands/updateUser.command.js +8 -0
- package/dist/features/users/presentation/filters/users.filters.d.ts +3 -0
- package/dist/features/users/presentation/filters/users.filters.js +62 -0
- package/dist/features/users/presentation/index.d.ts +5 -0
- package/dist/features/users/presentation/index.js +21 -0
- package/dist/features/users/presentation/responses/user.response.d.ts +25 -0
- package/dist/features/users/presentation/responses/user.response.js +95 -0
- package/dist/features/users/presentation/users.controller.d.ts +30 -0
- package/dist/features/users/presentation/users.controller.js +247 -0
- package/dist/features/users/users.module.d.ts +2 -0
- package/dist/features/users/users.module.js +42 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +149 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +5 -0
- package/dist/rlCore.module.d.ts +10 -0
- package/dist/rlCore.module.js +42 -0
- package/package.json +139 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const throttler_1 = require("@nestjs/throttler");
|
|
19
|
+
const cookie_util_1 = require("../../../core/auth/cookie.util");
|
|
20
|
+
const currentUser_decorator_1 = require("../../../core/auth/decorators/currentUser.decorator");
|
|
21
|
+
const public_decorator_1 = require("../../../core/auth/decorators/public.decorator");
|
|
22
|
+
const jwtAuth_guard_1 = require("../../../core/auth/guards/jwtAuth.guard");
|
|
23
|
+
const env_service_1 = require("../../../core/config/env.service");
|
|
24
|
+
const ip_util_1 = require("../../../core/utils/ip.util");
|
|
25
|
+
const auth_service_1 = require("../domain/auth.service");
|
|
26
|
+
const clientType_enum_1 = require("./commands/clientType.enum");
|
|
27
|
+
const login_command_1 = require("./commands/login.command");
|
|
28
|
+
const password_command_1 = require("./commands/password.command");
|
|
29
|
+
const refreshToken_command_1 = require("./commands/refreshToken.command");
|
|
30
|
+
const twoFactor_command_1 = require("./commands/twoFactor.command");
|
|
31
|
+
const sessionUser_response_1 = require("./responses/sessionUser.response");
|
|
32
|
+
function ctxFrom(req) {
|
|
33
|
+
return {
|
|
34
|
+
ipAddress: (0, ip_util_1.normalizeIp)(req.ip),
|
|
35
|
+
userAgent: req.headers["user-agent"],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
let AuthController = class AuthController {
|
|
39
|
+
constructor(auth, env) {
|
|
40
|
+
this.auth = auth;
|
|
41
|
+
this.env = env;
|
|
42
|
+
}
|
|
43
|
+
login(dto) {
|
|
44
|
+
return this.auth.login(dto);
|
|
45
|
+
}
|
|
46
|
+
setupTotp(dto) {
|
|
47
|
+
return this.auth.setupTotp(dto.pendingToken);
|
|
48
|
+
}
|
|
49
|
+
requestEmailCode(dto) {
|
|
50
|
+
return this.auth.requestEmailCode(dto.pendingToken);
|
|
51
|
+
}
|
|
52
|
+
async verify(dto, req, res) {
|
|
53
|
+
const { accessToken, refreshToken, user, backupCodes } = await this.auth.verifyTwoFactor(dto, ctxFrom(req));
|
|
54
|
+
if (dto.client === clientType_enum_1.ClientType.MOBILE) {
|
|
55
|
+
return { user, backupCodes, accessToken, refreshToken };
|
|
56
|
+
}
|
|
57
|
+
(0, cookie_util_1.setAuthCookies)(res, this.env, { accessToken, refreshToken });
|
|
58
|
+
return { user, backupCodes };
|
|
59
|
+
}
|
|
60
|
+
async refresh(dto, req, res) {
|
|
61
|
+
const cookies = req.cookies;
|
|
62
|
+
const raw = dto.refreshToken ?? cookies?.[cookie_util_1.REFRESH_COOKIE];
|
|
63
|
+
const tokens = await this.auth.refresh(raw, ctxFrom(req));
|
|
64
|
+
if (dto.refreshToken) {
|
|
65
|
+
return { ok: true, ...tokens };
|
|
66
|
+
}
|
|
67
|
+
(0, cookie_util_1.setAuthCookies)(res, this.env, tokens);
|
|
68
|
+
return { ok: true };
|
|
69
|
+
}
|
|
70
|
+
async logout(dto, req, res) {
|
|
71
|
+
const cookies = req.cookies;
|
|
72
|
+
await this.auth.logout(dto.refreshToken ?? cookies?.[cookie_util_1.REFRESH_COOKIE]);
|
|
73
|
+
(0, cookie_util_1.clearAuthCookies)(res, this.env);
|
|
74
|
+
return { ok: true };
|
|
75
|
+
}
|
|
76
|
+
profile(user) {
|
|
77
|
+
return user;
|
|
78
|
+
}
|
|
79
|
+
myPermissions(user) {
|
|
80
|
+
return { roles: user.roles, permissions: user.permissions };
|
|
81
|
+
}
|
|
82
|
+
async regenerateBackup(userId, dto) {
|
|
83
|
+
const backupCodes = await this.auth.regenerateBackupCodes(userId, dto.code);
|
|
84
|
+
return { backupCodes };
|
|
85
|
+
}
|
|
86
|
+
async forgotPassword(dto) {
|
|
87
|
+
await this.auth.forgotPassword(dto.email);
|
|
88
|
+
return { ok: true };
|
|
89
|
+
}
|
|
90
|
+
inspectPasswordToken(token) {
|
|
91
|
+
return this.auth.inspectPasswordToken(token);
|
|
92
|
+
}
|
|
93
|
+
async resetPassword(dto) {
|
|
94
|
+
await this.auth.resetPassword(dto.token, dto.newPassword);
|
|
95
|
+
return { ok: true };
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports.AuthController = AuthController;
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, public_decorator_1.Public)(),
|
|
101
|
+
(0, throttler_1.Throttle)({ default: { limit: 10, ttl: 60_000 } }),
|
|
102
|
+
(0, common_1.Post)("login"),
|
|
103
|
+
(0, swagger_1.ApiOperation)({ summary: "Login (passo 1): valida email+senha e exige 2FA" }),
|
|
104
|
+
__param(0, (0, common_1.Body)()),
|
|
105
|
+
__metadata("design:type", Function),
|
|
106
|
+
__metadata("design:paramtypes", [login_command_1.LoginCommand]),
|
|
107
|
+
__metadata("design:returntype", Promise)
|
|
108
|
+
], AuthController.prototype, "login", null);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, public_decorator_1.Public)(),
|
|
111
|
+
(0, common_1.Post)("2fa/setup"),
|
|
112
|
+
(0, swagger_1.ApiOperation)({ summary: "Gera segredo/QR TOTP no primeiro acesso" }),
|
|
113
|
+
__param(0, (0, common_1.Body)()),
|
|
114
|
+
__metadata("design:type", Function),
|
|
115
|
+
__metadata("design:paramtypes", [twoFactor_command_1.PendingTokenCommand]),
|
|
116
|
+
__metadata("design:returntype", Promise)
|
|
117
|
+
], AuthController.prototype, "setupTotp", null);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, public_decorator_1.Public)(),
|
|
120
|
+
(0, throttler_1.Throttle)({ default: { limit: 5, ttl: 60_000 } }),
|
|
121
|
+
(0, common_1.Post)("2fa/email"),
|
|
122
|
+
(0, swagger_1.ApiOperation)({ summary: "Fallback: envia código 2FA por email" }),
|
|
123
|
+
__param(0, (0, common_1.Body)()),
|
|
124
|
+
__metadata("design:type", Function),
|
|
125
|
+
__metadata("design:paramtypes", [twoFactor_command_1.PendingTokenCommand]),
|
|
126
|
+
__metadata("design:returntype", Promise)
|
|
127
|
+
], AuthController.prototype, "requestEmailCode", null);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, public_decorator_1.Public)(),
|
|
130
|
+
(0, throttler_1.Throttle)({ default: { limit: 10, ttl: 60_000 } }),
|
|
131
|
+
(0, common_1.Post)("2fa/verify"),
|
|
132
|
+
(0, swagger_1.ApiOperation)({
|
|
133
|
+
summary: "Login (passo 2): valida código 2FA e emite tokens",
|
|
134
|
+
}),
|
|
135
|
+
(0, swagger_1.ApiOkResponse)({ type: sessionUser_response_1.VerifyTwoFactorResponse }),
|
|
136
|
+
__param(0, (0, common_1.Body)()),
|
|
137
|
+
__param(1, (0, common_1.Req)()),
|
|
138
|
+
__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
139
|
+
__metadata("design:type", Function),
|
|
140
|
+
__metadata("design:paramtypes", [twoFactor_command_1.VerifyTwoFactorCommand, Object, Object]),
|
|
141
|
+
__metadata("design:returntype", Promise)
|
|
142
|
+
], AuthController.prototype, "verify", null);
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, public_decorator_1.Public)(),
|
|
145
|
+
(0, common_1.Post)("refresh"),
|
|
146
|
+
(0, swagger_1.ApiOperation)({ summary: "Rotaciona o refresh token (detecta reuso)" }),
|
|
147
|
+
__param(0, (0, common_1.Body)()),
|
|
148
|
+
__param(1, (0, common_1.Req)()),
|
|
149
|
+
__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
150
|
+
__metadata("design:type", Function),
|
|
151
|
+
__metadata("design:paramtypes", [refreshToken_command_1.RefreshTokenCommand, Object, Object]),
|
|
152
|
+
__metadata("design:returntype", Promise)
|
|
153
|
+
], AuthController.prototype, "refresh", null);
|
|
154
|
+
__decorate([
|
|
155
|
+
(0, public_decorator_1.Public)(),
|
|
156
|
+
(0, common_1.Post)("logout"),
|
|
157
|
+
(0, common_1.HttpCode)(200),
|
|
158
|
+
(0, swagger_1.ApiOperation)({
|
|
159
|
+
summary: "Logout: revoga o refresh token e limpa cookies (funciona mesmo com access token expirado)",
|
|
160
|
+
}),
|
|
161
|
+
__param(0, (0, common_1.Body)()),
|
|
162
|
+
__param(1, (0, common_1.Req)()),
|
|
163
|
+
__param(2, (0, common_1.Res)({ passthrough: true })),
|
|
164
|
+
__metadata("design:type", Function),
|
|
165
|
+
__metadata("design:paramtypes", [refreshToken_command_1.RefreshTokenCommand, Object, Object]),
|
|
166
|
+
__metadata("design:returntype", Promise)
|
|
167
|
+
], AuthController.prototype, "logout", null);
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
|
170
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
171
|
+
(0, common_1.Get)("profile"),
|
|
172
|
+
(0, swagger_1.ApiOperation)({ summary: "Dados do usuário autenticado + permissões" }),
|
|
173
|
+
(0, swagger_1.ApiOkResponse)({ type: sessionUser_response_1.SessionUserResponse }),
|
|
174
|
+
__param(0, (0, currentUser_decorator_1.CurrentUser)()),
|
|
175
|
+
__metadata("design:type", Function),
|
|
176
|
+
__metadata("design:paramtypes", [Object]),
|
|
177
|
+
__metadata("design:returntype", Object)
|
|
178
|
+
], AuthController.prototype, "profile", null);
|
|
179
|
+
__decorate([
|
|
180
|
+
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
|
181
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
182
|
+
(0, common_1.Get)("my-permissions"),
|
|
183
|
+
(0, swagger_1.ApiOperation)({
|
|
184
|
+
summary: "Lista os códigos de permissão e papéis do usuário",
|
|
185
|
+
}),
|
|
186
|
+
__param(0, (0, currentUser_decorator_1.CurrentUser)()),
|
|
187
|
+
__metadata("design:type", Function),
|
|
188
|
+
__metadata("design:paramtypes", [Object]),
|
|
189
|
+
__metadata("design:returntype", Object)
|
|
190
|
+
], AuthController.prototype, "myPermissions", null);
|
|
191
|
+
__decorate([
|
|
192
|
+
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
|
193
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
194
|
+
(0, common_1.Post)("2fa/backup/regenerate"),
|
|
195
|
+
(0, swagger_1.ApiOperation)({
|
|
196
|
+
summary: "Regenera os códigos de backup (confirma com código TOTP)",
|
|
197
|
+
}),
|
|
198
|
+
__param(0, (0, currentUser_decorator_1.CurrentUser)("id")),
|
|
199
|
+
__param(1, (0, common_1.Body)()),
|
|
200
|
+
__metadata("design:type", Function),
|
|
201
|
+
__metadata("design:paramtypes", [String, twoFactor_command_1.RegenerateBackupCommand]),
|
|
202
|
+
__metadata("design:returntype", Promise)
|
|
203
|
+
], AuthController.prototype, "regenerateBackup", null);
|
|
204
|
+
__decorate([
|
|
205
|
+
(0, public_decorator_1.Public)(),
|
|
206
|
+
(0, throttler_1.Throttle)({ default: { limit: 5, ttl: 60_000 } }),
|
|
207
|
+
(0, common_1.Post)("forgot-password"),
|
|
208
|
+
(0, common_1.HttpCode)(200),
|
|
209
|
+
(0, swagger_1.ApiOperation)({ summary: "Solicita email de redefinição de senha" }),
|
|
210
|
+
__param(0, (0, common_1.Body)()),
|
|
211
|
+
__metadata("design:type", Function),
|
|
212
|
+
__metadata("design:paramtypes", [password_command_1.ForgotPasswordCommand]),
|
|
213
|
+
__metadata("design:returntype", Promise)
|
|
214
|
+
], AuthController.prototype, "forgotPassword", null);
|
|
215
|
+
__decorate([
|
|
216
|
+
(0, public_decorator_1.Public)(),
|
|
217
|
+
(0, throttler_1.Throttle)({ default: { limit: 20, ttl: 60_000 } }),
|
|
218
|
+
(0, common_1.Get)("password-token/:token"),
|
|
219
|
+
(0, swagger_1.ApiOperation)({
|
|
220
|
+
summary: "Verifica a validade do link de senha sem consumi-lo",
|
|
221
|
+
}),
|
|
222
|
+
__param(0, (0, common_1.Param)("token")),
|
|
223
|
+
__metadata("design:type", Function),
|
|
224
|
+
__metadata("design:paramtypes", [String]),
|
|
225
|
+
__metadata("design:returntype", Promise)
|
|
226
|
+
], AuthController.prototype, "inspectPasswordToken", null);
|
|
227
|
+
__decorate([
|
|
228
|
+
(0, public_decorator_1.Public)(),
|
|
229
|
+
(0, common_1.Post)("reset-password"),
|
|
230
|
+
(0, common_1.HttpCode)(200),
|
|
231
|
+
(0, swagger_1.ApiOperation)({ summary: "Redefine a senha usando o token do email" }),
|
|
232
|
+
__param(0, (0, common_1.Body)()),
|
|
233
|
+
__metadata("design:type", Function),
|
|
234
|
+
__metadata("design:paramtypes", [password_command_1.ResetPasswordCommand]),
|
|
235
|
+
__metadata("design:returntype", Promise)
|
|
236
|
+
], AuthController.prototype, "resetPassword", null);
|
|
237
|
+
exports.AuthController = AuthController = __decorate([
|
|
238
|
+
(0, swagger_1.ApiTags)("Auth"),
|
|
239
|
+
(0, common_1.Controller)({ path: "auth", version: "1" }),
|
|
240
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService,
|
|
241
|
+
env_service_1.EnvService])
|
|
242
|
+
], AuthController);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientType = void 0;
|
|
4
|
+
var ClientType;
|
|
5
|
+
(function (ClientType) {
|
|
6
|
+
ClientType["WEB"] = "web";
|
|
7
|
+
ClientType["MOBILE"] = "mobile";
|
|
8
|
+
})(ClientType || (exports.ClientType = ClientType = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoginCommand = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class LoginCommand {
|
|
16
|
+
}
|
|
17
|
+
exports.LoginCommand = LoginCommand;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, swagger_1.ApiProperty)({ example: "admin@admin.com" }),
|
|
20
|
+
(0, class_validator_1.IsEmail)(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], LoginCommand.prototype, "email", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, swagger_1.ApiProperty)({ example: "admin@123" }),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
(0, class_validator_1.MinLength)(1),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], LoginCommand.prototype, "password", void 0);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ResetPasswordCommand = exports.ForgotPasswordCommand = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const password_constants_1 = require("../../../../core/utils/password.constants");
|
|
16
|
+
class ForgotPasswordCommand {
|
|
17
|
+
}
|
|
18
|
+
exports.ForgotPasswordCommand = ForgotPasswordCommand;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, swagger_1.ApiProperty)(),
|
|
21
|
+
(0, class_validator_1.IsEmail)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], ForgotPasswordCommand.prototype, "email", void 0);
|
|
24
|
+
class ResetPasswordCommand {
|
|
25
|
+
}
|
|
26
|
+
exports.ResetPasswordCommand = ResetPasswordCommand;
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, swagger_1.ApiProperty)(),
|
|
29
|
+
(0, class_validator_1.IsString)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], ResetPasswordCommand.prototype, "token", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, swagger_1.ApiProperty)(),
|
|
34
|
+
(0, class_validator_1.IsString)(),
|
|
35
|
+
(0, class_validator_1.Matches)(password_constants_1.STRONG_PASSWORD_REGEX, { message: password_constants_1.WEAK_PASSWORD_MESSAGE }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], ResetPasswordCommand.prototype, "newPassword", void 0);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RefreshTokenCommand = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class RefreshTokenCommand {
|
|
16
|
+
}
|
|
17
|
+
exports.RefreshTokenCommand = RefreshTokenCommand;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, swagger_1.ApiProperty)({
|
|
20
|
+
required: false,
|
|
21
|
+
description: "Refresh token do cliente mobile. No web vem pelo cookie.",
|
|
22
|
+
}),
|
|
23
|
+
(0, class_validator_1.IsOptional)(),
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], RefreshTokenCommand.prototype, "refreshToken", void 0);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ClientType } from "./clientType.enum";
|
|
2
|
+
export declare class PendingTokenCommand {
|
|
3
|
+
pendingToken: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class VerifyTwoFactorCommand extends PendingTokenCommand {
|
|
6
|
+
code: string;
|
|
7
|
+
method?: "totp" | "email" | "backup";
|
|
8
|
+
client?: ClientType;
|
|
9
|
+
}
|
|
10
|
+
export declare class RegenerateBackupCommand {
|
|
11
|
+
code: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RegenerateBackupCommand = exports.VerifyTwoFactorCommand = exports.PendingTokenCommand = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const clientType_enum_1 = require("./clientType.enum");
|
|
16
|
+
class PendingTokenCommand {
|
|
17
|
+
}
|
|
18
|
+
exports.PendingTokenCommand = PendingTokenCommand;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, swagger_1.ApiProperty)({ description: "pendingToken retornado pelo /auth/login" }),
|
|
21
|
+
(0, class_validator_1.IsString)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], PendingTokenCommand.prototype, "pendingToken", void 0);
|
|
24
|
+
class VerifyTwoFactorCommand extends PendingTokenCommand {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.client = clientType_enum_1.ClientType.WEB;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.VerifyTwoFactorCommand = VerifyTwoFactorCommand;
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiProperty)({
|
|
33
|
+
description: "Código TOTP, código de email (6 dígitos) ou backup (XXXX-XXXX)",
|
|
34
|
+
}),
|
|
35
|
+
(0, class_validator_1.IsString)(),
|
|
36
|
+
(0, class_validator_1.Length)(6, 9),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], VerifyTwoFactorCommand.prototype, "code", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)({
|
|
41
|
+
required: false,
|
|
42
|
+
enum: ["totp", "email", "backup"],
|
|
43
|
+
description: "Método usado (default: totp/email auto-detectado)",
|
|
44
|
+
}),
|
|
45
|
+
(0, class_validator_1.IsOptional)(),
|
|
46
|
+
(0, class_validator_1.IsIn)(["totp", "email", "backup"]),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], VerifyTwoFactorCommand.prototype, "method", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, swagger_1.ApiProperty)({
|
|
51
|
+
required: false,
|
|
52
|
+
enum: clientType_enum_1.ClientType,
|
|
53
|
+
default: clientType_enum_1.ClientType.WEB,
|
|
54
|
+
description: "mobile recebe os tokens no corpo; web recebe cookies httpOnly",
|
|
55
|
+
}),
|
|
56
|
+
(0, class_validator_1.IsOptional)(),
|
|
57
|
+
(0, class_validator_1.IsEnum)(clientType_enum_1.ClientType),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], VerifyTwoFactorCommand.prototype, "client", void 0);
|
|
60
|
+
class RegenerateBackupCommand {
|
|
61
|
+
}
|
|
62
|
+
exports.RegenerateBackupCommand = RegenerateBackupCommand;
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, swagger_1.ApiProperty)({ description: "Código TOTP atual (6 dígitos)" }),
|
|
65
|
+
(0, class_validator_1.IsString)(),
|
|
66
|
+
(0, class_validator_1.Length)(6, 6),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], RegenerateBackupCommand.prototype, "code", void 0);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./auth.controller";
|
|
2
|
+
export * from "./commands/clientType.enum";
|
|
3
|
+
export * from "./commands/login.command";
|
|
4
|
+
export * from "./commands/password.command";
|
|
5
|
+
export * from "./commands/refreshToken.command";
|
|
6
|
+
export * from "./commands/twoFactor.command";
|
|
7
|
+
export * from "./strategies/jwt.strategy";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth.controller"), exports);
|
|
18
|
+
__exportStar(require("./commands/clientType.enum"), exports);
|
|
19
|
+
__exportStar(require("./commands/login.command"), exports);
|
|
20
|
+
__exportStar(require("./commands/password.command"), exports);
|
|
21
|
+
__exportStar(require("./commands/refreshToken.command"), exports);
|
|
22
|
+
__exportStar(require("./commands/twoFactor.command"), exports);
|
|
23
|
+
__exportStar(require("./strategies/jwt.strategy"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthenticatedUser } from "../../../../core/auth/authenticatedUser.interface";
|
|
2
|
+
export declare class SessionUserResponse implements AuthenticatedUser {
|
|
3
|
+
id: string;
|
|
4
|
+
email: string;
|
|
5
|
+
name: string;
|
|
6
|
+
lastName?: string | null;
|
|
7
|
+
avatar?: string | null;
|
|
8
|
+
roles: string[];
|
|
9
|
+
permissions: string[];
|
|
10
|
+
twoFactorEnabled: boolean;
|
|
11
|
+
passwordExpired: boolean;
|
|
12
|
+
mustChangePassword: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class VerifyTwoFactorResponse {
|
|
15
|
+
user: SessionUserResponse;
|
|
16
|
+
backupCodes?: string[];
|
|
17
|
+
accessToken?: string;
|
|
18
|
+
refreshToken?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VerifyTwoFactorResponse = exports.SessionUserResponse = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class SessionUserResponse {
|
|
15
|
+
}
|
|
16
|
+
exports.SessionUserResponse = SessionUserResponse;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, swagger_1.ApiProperty)({ format: "uuid" }),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], SessionUserResponse.prototype, "id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, swagger_1.ApiProperty)({ example: "admin@admin.com" }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], SessionUserResponse.prototype, "email", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, swagger_1.ApiProperty)(),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], SessionUserResponse.prototype, "name", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], SessionUserResponse.prototype, "lastName", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, swagger_1.ApiProperty)({ type: String, required: false, nullable: true }),
|
|
35
|
+
__metadata("design:type", Object)
|
|
36
|
+
], SessionUserResponse.prototype, "avatar", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiProperty)({ type: [String] }),
|
|
39
|
+
__metadata("design:type", Array)
|
|
40
|
+
], SessionUserResponse.prototype, "roles", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, swagger_1.ApiProperty)({
|
|
43
|
+
type: [String],
|
|
44
|
+
description: "Códigos de permissão (resource:action:scope)",
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", Array)
|
|
47
|
+
], SessionUserResponse.prototype, "permissions", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, swagger_1.ApiProperty)(),
|
|
50
|
+
__metadata("design:type", Boolean)
|
|
51
|
+
], SessionUserResponse.prototype, "twoFactorEnabled", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, swagger_1.ApiProperty)({ description: "Senha passou da validade — front força troca" }),
|
|
54
|
+
__metadata("design:type", Boolean)
|
|
55
|
+
], SessionUserResponse.prototype, "passwordExpired", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, swagger_1.ApiProperty)({ description: "Senha provisória: precisa trocar no 1º acesso" }),
|
|
58
|
+
__metadata("design:type", Boolean)
|
|
59
|
+
], SessionUserResponse.prototype, "mustChangePassword", void 0);
|
|
60
|
+
class VerifyTwoFactorResponse {
|
|
61
|
+
}
|
|
62
|
+
exports.VerifyTwoFactorResponse = VerifyTwoFactorResponse;
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, swagger_1.ApiProperty)({ type: SessionUserResponse }),
|
|
65
|
+
__metadata("design:type", SessionUserResponse)
|
|
66
|
+
], VerifyTwoFactorResponse.prototype, "user", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, swagger_1.ApiProperty)({
|
|
69
|
+
type: [String],
|
|
70
|
+
required: false,
|
|
71
|
+
description: "Só na primeira configuração do 2FA",
|
|
72
|
+
}),
|
|
73
|
+
__metadata("design:type", Array)
|
|
74
|
+
], VerifyTwoFactorResponse.prototype, "backupCodes", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, swagger_1.ApiProperty)({
|
|
77
|
+
type: String,
|
|
78
|
+
required: false,
|
|
79
|
+
description: "Apenas para client=mobile",
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], VerifyTwoFactorResponse.prototype, "accessToken", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, swagger_1.ApiProperty)({
|
|
85
|
+
type: String,
|
|
86
|
+
required: false,
|
|
87
|
+
description: "Apenas para client=mobile",
|
|
88
|
+
}),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
|
+
], VerifyTwoFactorResponse.prototype, "refreshToken", void 0);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Strategy } from "passport-jwt";
|
|
2
|
+
import { AuthenticatedUser } from "../../../../core/auth/authenticatedUser.interface";
|
|
3
|
+
import { EnvService } from "../../../../core/config/env.service";
|
|
4
|
+
import { AuthService } from "../../domain/auth.service";
|
|
5
|
+
import { AccessTokenPayload } from "../../domain/jwtPayload.interface";
|
|
6
|
+
import { UsersService } from "../../../users/domain/users.service";
|
|
7
|
+
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
|
|
8
|
+
validate(...args: any[]): unknown;
|
|
9
|
+
};
|
|
10
|
+
export declare class JwtStrategy extends JwtStrategy_base {
|
|
11
|
+
private readonly env;
|
|
12
|
+
private readonly users;
|
|
13
|
+
private readonly auth;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
constructor(env: EnvService, users: UsersService, auth: AuthService);
|
|
16
|
+
validate(payload: AccessTokenPayload): Promise<AuthenticatedUser>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|