import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsIn, IsOptional, IsString } from 'class-validator'; export class StartVerificationDto { @ApiPropertyOptional({ enum: ['LOGIN', 'VERIFY'], default: 'VERIFY', description: 'Reason for verification. VERIFY returns the verified identity attributes; LOGIN resolves/creates a user and returns a JWT.', }) @IsOptional() @IsIn(['LOGIN', 'VERIFY']) purpose?: 'LOGIN' | 'VERIFY'; @ApiPropertyOptional({ enum: ['WEB', 'MOBILE'], default: 'WEB', description: 'Client platform. Selects which OAuth redirect_uri is sent to eSignet: WEB uses FAYDA_WEB_REDIRECT_URI, MOBILE uses FAYDA_REDIRECT_URI. Both land on the same /complete endpoint with identical handling.', }) @IsOptional() @IsIn(['WEB', 'MOBILE']) platform?: 'WEB' | 'MOBILE'; @ApiPropertyOptional({ type: Boolean, default: false, description: 'Set to true when the user opts in to full account registration (checkbox). ' + 'When true, the /complete response includes a short-lived token and promptPasswordSetup=true ' + 'so the frontend can immediately prompt for a password via POST /v1/auth/set-fayda-password.', }) @IsOptional() wantsPasswordSetup?: boolean; } export class CompleteVerificationResultDto { @ApiProperty({ enum: ['LOGIN', 'VERIFY'] }) purpose!: 'LOGIN' | 'VERIFY'; @ApiProperty() verified!: boolean; @ApiPropertyOptional({ description: 'JWT. LOGIN: session token for the authenticated user. VERIFY: short-lived token for calling /v1/auth/set-fayda-password.' }) token?: string; @ApiPropertyOptional() refreshToken?: string; @ApiPropertyOptional({ description: 'Authenticated user summary (LOGIN flow only; same shape as /auth/login).', }) user?: { id: string; email: string; role: string; passengerId?: string; agentId?: string; }; @ApiPropertyOptional({ description: 'Verified full name from Fayda (VERIFY flow).' }) fullName?: string; @ApiPropertyOptional({ description: 'Verified email from Fayda (VERIFY flow).' }) email?: string; @ApiPropertyOptional({ description: 'Verified phone number from Fayda (VERIFY flow).' }) phoneNumber?: string; @ApiPropertyOptional({ description: 'Verified date of birth from Fayda, ISO yyyy-MM-dd (VERIFY flow).', }) birthdate?: string; @ApiPropertyOptional({ description: 'Verified gender from Fayda (VERIFY flow).' }) gender?: string; @ApiPropertyOptional({ description: 'Whether the verified identity was saved to IAM. False if the IAM write failed.' }) userDataSaved?: boolean; @ApiPropertyOptional({ description: 'IAM user ID of the verified identity (VERIFY flow).' }) iamUserId?: string; @ApiPropertyOptional({ description: 'True when the IAM account has not yet set a password (VERIFY flow).' }) requiresPassword?: boolean; @ApiPropertyOptional({ description: 'True when the user opted in to immediate password setup (wantsPasswordSetup=true at start) ' + 'AND they have not yet set a password. Frontend should navigate to the set-password screen.', }) promptPasswordSetup?: boolean; } export class VerifaydaCallbackDto { @ApiPropertyOptional() @IsOptional() @IsString() code?: string; @ApiPropertyOptional() @IsOptional() @IsString() state?: string; @ApiPropertyOptional() @IsOptional() @IsString() error?: string; @ApiPropertyOptional() @IsOptional() @IsString() error_description?: string; } export class VerificationStatusDto { @ApiProperty() verified!: boolean; @ApiPropertyOptional() verifiedAt?: Date; @ApiPropertyOptional() fullName?: string; }