Skip to content

Commit

Permalink
Updated OOB Proof Verification endpoint (#533)
Browse files Browse the repository at this point in the history
* fix: removed the unnecessary logger from the agent-service module (#419)

Signed-off-by: KulkarniShashank <[email protected]>

* WIP:OOB Proof Request

Signed-off-by: ankita_patidar <[email protected]>

* WIP:OOB Proof Request

Signed-off-by: ankita_patidar <[email protected]>

* fix:OOB Credential Offer restore changes

Signed-off-by: ankita_patidar <[email protected]>

* fix:add email as optional

Signed-off-by: ankita_patidar <[email protected]>

* fix:take response from presentation request payload

Signed-off-by: ankita_patidar <[email protected]>

* fix: resolved sonar lint checks

Signed-off-by: bhavanakarwade <[email protected]>

* fix: dco error

Signed-off-by: bhavanakarwade <[email protected]>

* fix: dco error

Signed-off-by: bhavanakarwade <[email protected]>

* expose agent format of proof request to API endpoint, disabled send offer by email

Signed-off-by: ankita_patidar <[email protected]>

* update OOB verification input

Signed-off-by: ankita_patidar <[email protected]>

* added few more allowed restrictions, corrected API description

Signed-off-by: ankita_patidar <[email protected]>

* added few more allowed restrictions

Signed-off-by: ankita_patidar <[email protected]>

---------

Signed-off-by: KulkarniShashank <[email protected]>
Signed-off-by: ankita_patidar <[email protected]>
Signed-off-by: bhavanakarwade <[email protected]>
Signed-off-by: Ankita Patidar <[email protected]>
Co-authored-by: Nishad Shirsat <[email protected]>
Co-authored-by: Nishad <[email protected]>
Co-authored-by: Shashank Kulkarni <[email protected]>
Co-authored-by: bhavanakarwade <[email protected]>
Co-authored-by: bhavanakarwade <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
6 people authored and KulkarniShashank committed Sep 11, 2024
1 parent ecf3943 commit 22e9bce
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 41 deletions.
3 changes: 3 additions & 0 deletions apps/agent-service/src/interface/agent-service.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ interface IRequestedPredicatesName {
interface IRequestedRestriction {
cred_def_id?: string;
schema_id?: string;
schema_issuer_did?: string;
schema_name?: string;
issuer_did?: string;
}

export interface IAgentSpinUpSatus {
Expand Down
87 changes: 52 additions & 35 deletions apps/api-gateway/src/verification/dto/request-proof.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { IsArray, IsBoolean, IsEmail, IsEnum, IsNotEmpty, IsNumberString, IsObject, IsOptional, IsString } from 'class-validator';
import { IsArray, IsBoolean, IsEmail, IsEnum, IsNotEmpty, IsNumberString, IsObject, IsOptional, IsString, IsUUID } from 'class-validator';
import { toLowerCase, trim } from '@credebl/common/cast.helper';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { AutoAccept } from '@credebl/enum/enum';
import { IProofFormats } from '../interfaces/verification.interface';

export class ProofRequestAttribute {
@IsString()
Expand Down Expand Up @@ -135,46 +136,62 @@ export class OutOfBandRequestProof extends ProofPayload {
autoAcceptProof: string;
}

export class SendProofRequestPayload {

interface IProofFormats {
indy: IndyProof
}
@ApiPropertyOptional()
@IsString({ message: 'protocolVersion must be in string' })
@IsNotEmpty({ message: 'please provide valid protocol version' })
@IsOptional()
protocolVersion: string;

interface IndyProof {
name: string;
version: string;
requested_attributes: IRequestedAttributes;
requested_predicates: IRequestedPredicates;
}
@ApiPropertyOptional()
@IsOptional()
@IsString({ message: 'comment must be in string' })
comment: string;

interface IRequestedAttributes {
[key: string]: IRequestedAttributesName;
}
@ApiProperty()
@IsString()
@Transform(({ value }) => trim(value))
@Transform(({ value }) => toLowerCase(value))
@IsNotEmpty({ message: 'connectionId is required.' })
connectionId: string;

interface IRequestedAttributesName {
name: string;
restrictions: IRequestedRestriction[]
}
@ApiProperty({
'example': [
{
indy: {
name: 'Verify national identity',
version: '1.0',
// eslint-disable-next-line camelcase
requested_attributes: {},
// eslint-disable-next-line camelcase
requested_predicates: {}
}
}
]
})
@IsObject({ each: true })
@IsNotEmpty({ message: 'please provide valid proofFormat' })
proofFormats: IProofFormats;

interface IRequestedPredicates {
[key: string]: IRequestedPredicatesName;
}
@ApiPropertyOptional()
@IsString({ message: 'auto accept proof must be in string' })
@IsNotEmpty({ message: 'please provide from valid auto accept proof options' })
@IsOptional()
@IsEnum(AutoAccept, {
message: `Invalid auto accept proof. It should be one of: ${Object.values(AutoAccept).join(', ')}`
})
autoAcceptProof: AutoAccept;

interface IRequestedPredicatesName {
name: string;
restrictions: IRequestedRestriction[]
}
@ApiPropertyOptional()
@IsOptional()
@IsString({ message: 'label must be in string' })
label: string;

interface IRequestedRestriction {
cred_def_id?: string;
schema_id?: string;
@ApiPropertyOptional()
@IsOptional()
@IsUUID()
@IsNotEmpty({ message: 'please provide valid parentThreadId' })
parentThreadId: string;
}

export interface ISendProofRequestPayload {
protocolVersion?: string;
comment?: string;
connectionId?: string;
proofFormats: IProofFormats;
autoAcceptProof?: string;
label?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,42 @@ interface ITags {
state: string;
threadId: string;
}

export interface IProofFormats {
indy: IndyProof
}

interface IndyProof {
name: string;
version: string;
requested_attributes: IRequestedAttributes;
requested_predicates: IRequestedPredicates;
}

interface IRequestedAttributes {
[key: string]: IRequestedAttributesName;
}

interface IRequestedAttributesName {
name?: string;
names?: string;
restrictions: IRequestedRestriction[]
}

interface IRequestedPredicates {
[key: string]: IRequestedPredicatesName;
}

interface IRequestedPredicatesName {
name: string;
restrictions: IRequestedRestriction[]
}

interface IRequestedRestriction {
cred_def_id?: string;
schema_id?: string;
schema_issuer_did?: string;
schema_name?: string;
issuer_did?: string;
schema_version?: string;
}
6 changes: 3 additions & 3 deletions apps/api-gateway/src/verification/verification.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Controller, Logger, Post, Body, Get, Query, HttpStatus, Res, UseGuards,
import { ApiResponseDto } from '../dtos/apiResponse.dto';
import { UnauthorizedErrorDto } from '../dtos/unauthorized-error.dto';
import { ForbiddenErrorDto } from '../dtos/forbidden-error.dto';
import { ISendProofRequestPayload, OutOfBandRequestProof, RequestProofDto } from './dto/request-proof.dto';
import { SendProofRequestPayload, RequestProofDto } from './dto/request-proof.dto';
import { VerificationService } from './verification.service';
import IResponseType, { IResponse } from '@credebl/common/interfaces/response.interface';
import { Response } from 'express';
Expand Down Expand Up @@ -249,14 +249,14 @@ export class VerificationController {
@ApiResponse({ status: HttpStatus.CREATED, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiBody({ type: OutOfBandRequestProof })
@ApiBody({ type: SendProofRequestPayload })
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.VERIFIER)
@ApiBearerAuth()
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
async sendOutOfBandPresentationRequest(
@Res() res: Response,
@User() user: IUserRequest,
@Body() outOfBandRequestProof: ISendProofRequestPayload,
@Body() outOfBandRequestProof: SendProofRequestPayload,
@Param('orgId') orgId: string
): Promise<Response> {
user.orgId = orgId;
Expand Down
4 changes: 2 additions & 2 deletions apps/api-gateway/src/verification/verification.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, Inject} from '@nestjs/common';
import { ClientProxy} from '@nestjs/microservices';
import { BaseService } from 'libs/service/base.service';
import { ISendProofRequestPayload, RequestProofDto } from './dto/request-proof.dto';
import { SendProofRequestPayload, RequestProofDto } from './dto/request-proof.dto';
import { IUserRequest } from '@credebl/user-request/user-request.interface';
import { WebhookPresentationProofDto } from './dto/webhook-proof.dto';
import { IProofPresentationDetails, IProofPresentationList } from '@credebl/common/interfaces/verification.interface';
Expand Down Expand Up @@ -70,7 +70,7 @@ export class VerificationService extends BaseService {
* @param outOfBandRequestProof
* @returns Get out-of-band requested proof presentation details
*/
sendOutOfBandPresentationRequest(outOfBandRequestProof: ISendProofRequestPayload, user: IUserRequest): Promise<object> {
sendOutOfBandPresentationRequest(outOfBandRequestProof: SendProofRequestPayload, user: IUserRequest): Promise<object> {
const payload = { outOfBandRequestProof, user };
return this.sendNatsMessage(this.verificationServiceProxy, 'send-out-of-band-proof-request', payload);
}
Expand Down
7 changes: 6 additions & 1 deletion apps/verification/src/interfaces/verification.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ interface IRequestedAttributes {
}

interface IRequestedAttributesName {
name: string;
name?: string;
names?: string;
restrictions: IRequestedRestriction[]
}

Expand All @@ -81,6 +82,10 @@ interface IRequestedPredicatesName {
interface IRequestedRestriction {
cred_def_id?: string;
schema_id?: string;
schema_issuer_did?: string;
schema_name?: string;
issuer_did?: string;
schema_version?: string;
}

export interface ISendProofRequestPayload {
Expand Down

0 comments on commit 22e9bce

Please sign in to comment.