UNPKG

@wikiccu/nest-auth

Version:

A comprehensive authentication package for NestJS applications with Prisma and PostgreSQL

246 lines 10.9 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UpdateUserDto = exports.CreateUserDto = exports.LogoutDto = exports.RefreshTokenDto = exports.ResendVerificationDto = exports.VerifyEmailDto = exports.ChangePasswordDto = exports.ResetPasswordDto = exports.ForgotPasswordDto = exports.LoginDto = exports.RegisterDto = void 0; const class_validator_1 = require("class-validator"); const swagger_1 = require("@nestjs/swagger"); class RegisterDto { email; password; username; firstName; lastName; } exports.RegisterDto = RegisterDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'User email address' }), (0, class_validator_1.IsEmail)({}, { message: 'Please provide a valid email address' }), __metadata("design:type", String) ], RegisterDto.prototype, "email", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'User password', minLength: 8 }), (0, class_validator_1.IsString)(), (0, class_validator_1.MinLength)(8, { message: 'Password must be at least 8 characters long' }), (0, class_validator_1.MaxLength)(128, { message: 'Password must not exceed 128 characters' }), __metadata("design:type", String) ], RegisterDto.prototype, "password", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Username (optional)' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'Username must not exceed 50 characters' }), __metadata("design:type", String) ], RegisterDto.prototype, "username", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'First name' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'First name must not exceed 50 characters' }), __metadata("design:type", String) ], RegisterDto.prototype, "firstName", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Last name' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'Last name must not exceed 50 characters' }), __metadata("design:type", String) ], RegisterDto.prototype, "lastName", void 0); class LoginDto { email; password; rememberMe; } exports.LoginDto = LoginDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'User email address' }), (0, class_validator_1.IsEmail)({}, { message: 'Please provide a valid email address' }), __metadata("design:type", String) ], LoginDto.prototype, "email", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'User password' }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], LoginDto.prototype, "password", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Remember me option' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsBoolean)(), __metadata("design:type", Boolean) ], LoginDto.prototype, "rememberMe", void 0); class ForgotPasswordDto { email; } exports.ForgotPasswordDto = ForgotPasswordDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'User email address' }), (0, class_validator_1.IsEmail)({}, { message: 'Please provide a valid email address' }), __metadata("design:type", String) ], ForgotPasswordDto.prototype, "email", void 0); class ResetPasswordDto { token; newPassword; } exports.ResetPasswordDto = ResetPasswordDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'Reset token received via email' }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], ResetPasswordDto.prototype, "token", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'New password', minLength: 8 }), (0, class_validator_1.IsString)(), (0, class_validator_1.MinLength)(8, { message: 'Password must be at least 8 characters long' }), (0, class_validator_1.MaxLength)(128, { message: 'Password must not exceed 128 characters' }), __metadata("design:type", String) ], ResetPasswordDto.prototype, "newPassword", void 0); class ChangePasswordDto { currentPassword; newPassword; } exports.ChangePasswordDto = ChangePasswordDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'Current password' }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], ChangePasswordDto.prototype, "currentPassword", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'New password', minLength: 8 }), (0, class_validator_1.IsString)(), (0, class_validator_1.MinLength)(8, { message: 'Password must be at least 8 characters long' }), (0, class_validator_1.MaxLength)(128, { message: 'Password must not exceed 128 characters' }), __metadata("design:type", String) ], ChangePasswordDto.prototype, "newPassword", void 0); class VerifyEmailDto { token; } exports.VerifyEmailDto = VerifyEmailDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'Email verification token' }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], VerifyEmailDto.prototype, "token", void 0); class ResendVerificationDto { email; } exports.ResendVerificationDto = ResendVerificationDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'User email address' }), (0, class_validator_1.IsEmail)({}, { message: 'Please provide a valid email address' }), __metadata("design:type", String) ], ResendVerificationDto.prototype, "email", void 0); class RefreshTokenDto { refreshToken; } exports.RefreshTokenDto = RefreshTokenDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'Refresh token' }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], RefreshTokenDto.prototype, "refreshToken", void 0); class LogoutDto { refreshToken; } exports.LogoutDto = LogoutDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'Refresh token to revoke' }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], LogoutDto.prototype, "refreshToken", void 0); class CreateUserDto { email; password; username; firstName; lastName; roles; } exports.CreateUserDto = CreateUserDto; __decorate([ (0, swagger_1.ApiProperty)({ description: 'User email address' }), (0, class_validator_1.IsEmail)({}, { message: 'Please provide a valid email address' }), __metadata("design:type", String) ], CreateUserDto.prototype, "email", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'User password', minLength: 8 }), (0, class_validator_1.IsString)(), (0, class_validator_1.MinLength)(8, { message: 'Password must be at least 8 characters long' }), (0, class_validator_1.MaxLength)(128, { message: 'Password must not exceed 128 characters' }), __metadata("design:type", String) ], CreateUserDto.prototype, "password", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Username' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'Username must not exceed 50 characters' }), __metadata("design:type", String) ], CreateUserDto.prototype, "username", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'First name' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'First name must not exceed 50 characters' }), __metadata("design:type", String) ], CreateUserDto.prototype, "firstName", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Last name' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'Last name must not exceed 50 characters' }), __metadata("design:type", String) ], CreateUserDto.prototype, "lastName", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'User roles' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)({ each: true }), __metadata("design:type", Array) ], CreateUserDto.prototype, "roles", void 0); class UpdateUserDto { email; username; firstName; lastName; roles; } exports.UpdateUserDto = UpdateUserDto; __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'User email address' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsEmail)({}, { message: 'Please provide a valid email address' }), __metadata("design:type", String) ], UpdateUserDto.prototype, "email", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Username' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'Username must not exceed 50 characters' }), __metadata("design:type", String) ], UpdateUserDto.prototype, "username", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'First name' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'First name must not exceed 50 characters' }), __metadata("design:type", String) ], UpdateUserDto.prototype, "firstName", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'Last name' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)(), (0, class_validator_1.MaxLength)(50, { message: 'Last name must not exceed 50 characters' }), __metadata("design:type", String) ], UpdateUserDto.prototype, "lastName", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ description: 'User roles' }), (0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)({ each: true }), __metadata("design:type", Array) ], UpdateUserDto.prototype, "roles", void 0); //# sourceMappingURL=auth.dto.js.map