@@ -48,6 +48,8 @@ import { Oid4vcVerificationService } from './oid4vc-verification.service';
4848import { CreateVerifierDto , UpdateVerifierDto } from './dtos/oid4vc-verifier.dto' ;
4949import { PresentationRequestDto , VerificationPresentationQueryDto } from './dtos/oid4vc-verifier-presentation.dto' ;
5050import { Oid4vpPresentationWhDto } from '../oid4vc-issuance/dtos/oid4vp-presentation-wh.dto' ;
51+ import { CreateVerificationTemplateDto , UpdateVerificationTemplateDto } from './dtos/verification-template.dto' ;
52+ import { CreateIntentBasedVerificationDto } from './dtos/create-intent-based-verification.dto' ;
5153
5254@Controller ( )
5355@UseFilters ( CustomExceptionFilter )
@@ -305,6 +307,63 @@ export class Oid4vcVerificationController {
305307 return res . status ( HttpStatus . CREATED ) . json ( finalResponse ) ;
306308 }
307309
310+ @Post ( '/orgs/:orgId/oid4vp/intent-based-verification-presentation' )
311+ @ApiOperation ( {
312+ summary : 'Create intent-based verification presentation' ,
313+ description : 'Creates a new verification presentation using an intent template for the specified organization.'
314+ } )
315+ @ApiResponse ( {
316+ status : HttpStatus . CREATED ,
317+ description : 'Verification presentation created successfully.' ,
318+ type : ApiResponseDto
319+ } )
320+ @ApiBearerAuth ( )
321+ @Roles ( OrgRoles . OWNER )
322+ @UseGuards ( AuthGuard ( 'jwt' ) , OrgRolesGuard )
323+ async createIntentBasedVerificationPresentation (
324+ @Param (
325+ 'orgId' ,
326+ new ParseUUIDPipe ( {
327+ exceptionFactory : ( ) : Error => {
328+ throw new BadRequestException ( ResponseMessages . organisation . error . invalidOrgId ) ;
329+ }
330+ } )
331+ )
332+ orgId : string ,
333+ @Query (
334+ 'verifierId' ,
335+ new ParseUUIDPipe ( {
336+ exceptionFactory : ( ) : Error => {
337+ throw new BadRequestException ( 'Invalid verifier ID' ) ;
338+ }
339+ } )
340+ )
341+ verifierId : string ,
342+ @User ( ) user : user ,
343+ @Body ( ) createIntentDto : CreateIntentBasedVerificationDto ,
344+ @Res ( ) res : Response
345+ ) : Promise < Response > {
346+ this . logger . debug (
347+ `[createIntentBasedVerificationPresentation] Called with orgId=${ orgId } , verifierId=${ verifierId } , intent=${ createIntentDto ?. intent } , user=${ user . id } `
348+ ) ;
349+
350+ const presentation = await this . oid4vcVerificationService . createIntentBasedVerificationPresentation (
351+ orgId ,
352+ verifierId ,
353+ createIntentDto ,
354+ user
355+ ) ;
356+
357+ this . logger . debug ( `[createIntentBasedVerificationPresentation] Presentation created successfully` ) ;
358+
359+ const finalResponse : IResponse = {
360+ statusCode : HttpStatus . CREATED ,
361+ message : ResponseMessages . oid4vpSession . success . create ,
362+ data : presentation
363+ } ;
364+ return res . status ( HttpStatus . CREATED ) . json ( finalResponse ) ;
365+ }
366+
308367 @Get ( '/orgs/:orgId/oid4vp/verifier-presentation' )
309368 @ApiOperation ( {
310369 summary : 'Get OID4VP verifier presentation details' ,
@@ -448,6 +507,7 @@ export class Oid4vcVerificationController {
448507 } ) ;
449508
450509 if ( webhookUrl ) {
510+ this . logger . log ( `posting webhook response to webhook url` ) ;
451511 await this . oid4vcVerificationService
452512 . _postWebhookResponse ( webhookUrl , { data : oid4vpPresentationWhDto } )
453513 . catch ( ( error ) => {
@@ -457,4 +517,205 @@ export class Oid4vcVerificationController {
457517
458518 return res . status ( HttpStatus . CREATED ) . json ( finalResponse ) ;
459519 }
520+
521+ @Post ( '/orgs/:orgId/oid4vp/verification-template' )
522+ @ApiOperation ( {
523+ summary : 'Create verification template' ,
524+ description : 'Creates a new verification template for the specified organization.'
525+ } )
526+ @ApiResponse ( {
527+ status : HttpStatus . CREATED ,
528+ description : 'Verification template created successfully.' ,
529+ type : ApiResponseDto
530+ } )
531+ @ApiBearerAuth ( )
532+ @Roles ( OrgRoles . OWNER )
533+ @UseGuards ( AuthGuard ( 'jwt' ) , OrgRolesGuard )
534+ async createVerificationTemplate (
535+ @Param (
536+ 'orgId' ,
537+ new ParseUUIDPipe ( {
538+ exceptionFactory : ( ) : Error => {
539+ throw new BadRequestException ( ResponseMessages . organisation . error . invalidOrgId ) ;
540+ }
541+ } )
542+ )
543+ orgId : string ,
544+ @User ( ) user : user ,
545+ @Body ( ) createTemplateDto : CreateVerificationTemplateDto ,
546+ @Res ( ) res : Response
547+ ) : Promise < Response > {
548+ this . logger . debug ( `[createVerificationTemplate] Called with orgId=${ orgId } , user=${ user . id } ` ) ;
549+
550+ const template = await this . oid4vcVerificationService . createVerificationTemplate ( createTemplateDto , orgId , user ) ;
551+
552+ this . logger . debug ( `[createVerificationTemplate] Template created: ${ template [ 'id' ] } ` ) ;
553+
554+ const finalResponse : IResponse = {
555+ statusCode : HttpStatus . CREATED ,
556+ message : 'Verification template created successfully' ,
557+ data : template
558+ } ;
559+ return res . status ( HttpStatus . CREATED ) . json ( finalResponse ) ;
560+ }
561+
562+ @Get ( '/orgs/:orgId/oid4vp/verification-template' )
563+ @ApiOperation ( {
564+ summary : 'Get verification template(s)' ,
565+ description : 'Retrieves verification template(s) for the specified organization.'
566+ } )
567+ @ApiQuery ( {
568+ name : 'templateId' ,
569+ required : false ,
570+ type : String ,
571+ description : 'UUID of the template (optional)'
572+ } )
573+ @ApiResponse ( {
574+ status : HttpStatus . OK ,
575+ description : 'Verification template(s) retrieved successfully.' ,
576+ type : ApiResponseDto
577+ } )
578+ @ApiBearerAuth ( )
579+ @Roles ( OrgRoles . OWNER )
580+ @UseGuards ( AuthGuard ( 'jwt' ) , OrgRolesGuard )
581+ async getVerificationTemplates (
582+ @Param (
583+ 'orgId' ,
584+ new ParseUUIDPipe ( {
585+ exceptionFactory : ( ) : Error => {
586+ throw new BadRequestException ( ResponseMessages . organisation . error . invalidOrgId ) ;
587+ }
588+ } )
589+ )
590+ orgId : string ,
591+ @Res ( ) res : Response ,
592+ @Query (
593+ 'templateId' ,
594+ new ParseUUIDPipe ( {
595+ version : '4' ,
596+ optional : true ,
597+ exceptionFactory : ( ) : Error => {
598+ throw new BadRequestException ( 'Invalid template ID' ) ;
599+ }
600+ } )
601+ )
602+ templateId ?: string
603+ ) : Promise < Response > {
604+ this . logger . debug ( `[getVerificationTemplates] Called with orgId=${ orgId } , templateId=${ templateId ?? 'all' } ` ) ;
605+
606+ const templates = await this . oid4vcVerificationService . getVerificationTemplates ( orgId , templateId ) ;
607+
608+ this . logger . debug ( `[getVerificationTemplates] Templates fetched successfully` ) ;
609+ const finalResponse : IResponse = {
610+ statusCode : HttpStatus . OK ,
611+ message : 'Verification template(s) retrieved successfully' ,
612+ data : templates
613+ } ;
614+ return res . status ( HttpStatus . OK ) . json ( finalResponse ) ;
615+ }
616+
617+ @Put ( '/orgs/:orgId/oid4vp/verification-template/:templateId' )
618+ @ApiOperation ( {
619+ summary : 'Update verification template' ,
620+ description : 'Updates an existing verification template for the specified organization.'
621+ } )
622+ @ApiResponse ( {
623+ status : HttpStatus . OK ,
624+ description : 'Verification template updated successfully.' ,
625+ type : ApiResponseDto
626+ } )
627+ @ApiBearerAuth ( )
628+ @Roles ( OrgRoles . OWNER )
629+ @UseGuards ( AuthGuard ( 'jwt' ) , OrgRolesGuard )
630+ async updateVerificationTemplate (
631+ @Param (
632+ 'orgId' ,
633+ new ParseUUIDPipe ( {
634+ exceptionFactory : ( ) : Error => {
635+ throw new BadRequestException ( ResponseMessages . organisation . error . invalidOrgId ) ;
636+ }
637+ } )
638+ )
639+ orgId : string ,
640+ @Param (
641+ 'templateId' ,
642+ new ParseUUIDPipe ( {
643+ exceptionFactory : ( ) : Error => {
644+ throw new BadRequestException ( 'Invalid template ID' ) ;
645+ }
646+ } )
647+ )
648+ templateId : string ,
649+ @User ( ) user : user ,
650+ @Body ( ) updateTemplateDto : UpdateVerificationTemplateDto ,
651+ @Res ( ) res : Response
652+ ) : Promise < Response > {
653+ this . logger . debug (
654+ `[updateVerificationTemplate] Called with orgId=${ orgId } , templateId=${ templateId } , user=${ user . id } `
655+ ) ;
656+
657+ const template = await this . oid4vcVerificationService . updateVerificationTemplate (
658+ templateId ,
659+ updateTemplateDto ,
660+ orgId ,
661+ user
662+ ) ;
663+
664+ this . logger . debug ( `[updateVerificationTemplate] Template updated: ${ template [ 'id' ] } ` ) ;
665+
666+ const finalResponse : IResponse = {
667+ statusCode : HttpStatus . OK ,
668+ message : 'Verification template updated successfully' ,
669+ data : template
670+ } ;
671+ return res . status ( HttpStatus . OK ) . json ( finalResponse ) ;
672+ }
673+
674+ @Delete ( '/orgs/:orgId/oid4vp/verification-template/:templateId' )
675+ @ApiOperation ( {
676+ summary : 'Delete verification template' ,
677+ description : 'Deletes a verification template for the specified organization.'
678+ } )
679+ @ApiResponse ( {
680+ status : HttpStatus . OK ,
681+ description : 'Verification template deleted successfully.' ,
682+ type : ApiResponseDto
683+ } )
684+ @ApiBearerAuth ( )
685+ @Roles ( OrgRoles . OWNER )
686+ @UseGuards ( AuthGuard ( 'jwt' ) , OrgRolesGuard )
687+ async deleteVerificationTemplate (
688+ @Param (
689+ 'orgId' ,
690+ new ParseUUIDPipe ( {
691+ exceptionFactory : ( ) : Error => {
692+ throw new BadRequestException ( ResponseMessages . organisation . error . invalidOrgId ) ;
693+ }
694+ } )
695+ )
696+ orgId : string ,
697+ @Param (
698+ 'templateId' ,
699+ new ParseUUIDPipe ( {
700+ exceptionFactory : ( ) : Error => {
701+ throw new BadRequestException ( 'Invalid template ID' ) ;
702+ }
703+ } )
704+ )
705+ templateId : string ,
706+ @Res ( ) res : Response
707+ ) : Promise < Response > {
708+ this . logger . debug ( `[deleteVerificationTemplate] Called with orgId=${ orgId } , templateId=${ templateId } ` ) ;
709+
710+ const template = await this . oid4vcVerificationService . deleteVerificationTemplate ( orgId , templateId ) ;
711+
712+ this . logger . debug ( `[deleteVerificationTemplate] Template deleted: ${ templateId } ` ) ;
713+
714+ const finalResponse : IResponse = {
715+ statusCode : HttpStatus . OK ,
716+ message : 'Verification template deleted successfully' ,
717+ data : template
718+ } ;
719+ return res . status ( HttpStatus . OK ) . json ( finalResponse ) ;
720+ }
460721}
0 commit comments