import { Controller, Get, Query } from '@nestjs/common'; import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; import { IsPublic } from '@tria-plc/api-common/modules/auth/decorators/public.decorator'; import { VerifaydaCallbackDto } from './verifayda.dto'; /** * Plain acknowledgement endpoint for the Fayda redirect_uri when it points at * the API instead of the web app (e.g. MOBILE clients or connectivity checks). * Registered at /callback (excluded from the global /api prefix in main.ts). * It does NOT consume the verification session — the client must still call * GET /api/fayda/verification/complete with the echoed code+state. */ @ApiTags('Fayda Verification') @Controller('callback') export class FaydaCallbackController { @Get() @IsPublic() @ApiOperation({ summary: 'Acknowledge a Fayda redirect (returns OK, echoes code/state)' }) @ApiOkResponse({ schema: { example: { status: 'ok', code: '...', state: '...' } }, }) ok(@Query() query: VerifaydaCallbackDto) { return { status: 'ok', ...(query.code ? { code: query.code } : {}), ...(query.state ? { state: query.state } : {}), ...(query.error ? { error: query.error } : {}), ...(query.error_description ? { error_description: query.error_description } : {}), }; } }