File size: 1,061 Bytes
add3ead
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { ApiProperty } from '@nestjs/swagger';
import {
  IsEmail,
  IsString,
  IsNotEmpty,
  IsBoolean,
  IsOptional,
  Length,
  Matches,
} from 'class-validator';

export class VerifyRecoveryCodeDto {
  @ApiProperty({
    example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
    description: 'Pending 2FA token from login',
  })
  @IsString()
  @IsNotEmpty()
  pending2faToken: string;

  @ApiProperty({ example: 'ABCD-EFGH', description: 'Recovery code' })
  @IsString()
  @IsNotEmpty()
  @Length(9, 9, { message: 'Recovery code must be in format XXXX-XXXX' })
  @Matches(/^[A-Z0-9]{4}-[A-Z0-9]{4}$/, {
    message: 'Invalid recovery code format',
  })
  code: string;

  @ApiProperty({
    example: true,
    description: 'Remember this device for 30 days (skip 2FA on this device)',
    required: false,
  })
  @IsBoolean()
  @IsOptional()
  trustDevice?: boolean;
}

export class RegenerateRecoveryCodesDto {
  @ApiProperty({
    example: 'admin@streamflix.com',
    description: 'Super admin email',
  })
  @IsEmail()
  @IsNotEmpty()
  email: string;
}