From 0d096c5dd5389180c2ca33b98ec1037623dc61ac Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Tue, 27 Feb 2024 18:53:05 +0530 Subject: [PATCH 1/2] fix:proof request api for attributes array Signed-off-by: pranalidhanavade --- apps/api-gateway/src/dtos/create-schema.dto.ts | 2 +- .../api-gateway/src/ecosystem/dtos/request-schema.dto.ts | 2 +- .../src/verification/dto/request-proof.dto.ts | 2 +- .../src/interfaces/verification.interface.ts | 3 ++- apps/verification/src/verification.service.ts | 9 +++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/api-gateway/src/dtos/create-schema.dto.ts b/apps/api-gateway/src/dtos/create-schema.dto.ts index fa246beec..5ba17afe9 100644 --- a/apps/api-gateway/src/dtos/create-schema.dto.ts +++ b/apps/api-gateway/src/dtos/create-schema.dto.ts @@ -50,7 +50,7 @@ export class CreateSchemaDto { attributeName: 'name', schemaDataType: 'string', displayName: 'Name', - isRequired: 'true' + isRequired: true } ] }) diff --git a/apps/api-gateway/src/ecosystem/dtos/request-schema.dto.ts b/apps/api-gateway/src/ecosystem/dtos/request-schema.dto.ts index d7d496859..708985dda 100644 --- a/apps/api-gateway/src/ecosystem/dtos/request-schema.dto.ts +++ b/apps/api-gateway/src/ecosystem/dtos/request-schema.dto.ts @@ -53,7 +53,7 @@ export class RequestSchemaDto { attributeName: 'name', schemaDataType: 'string', displayName: 'Name', - isRequired: 'true' + isRequired: true } ] }) diff --git a/apps/api-gateway/src/verification/dto/request-proof.dto.ts b/apps/api-gateway/src/verification/dto/request-proof.dto.ts index 7d04d5960..1a08db7e1 100644 --- a/apps/api-gateway/src/verification/dto/request-proof.dto.ts +++ b/apps/api-gateway/src/verification/dto/request-proof.dto.ts @@ -10,7 +10,7 @@ export class ProofRequestAttribute { @ValidateIf((obj) => obj.attributeNames === undefined) @IsNotEmpty() - @IsString({each:true}) + @IsString() attributeName?: string; @ValidateIf((obj) => obj.attributeName === undefined) diff --git a/apps/verification/src/interfaces/verification.interface.ts b/apps/verification/src/interfaces/verification.interface.ts index ff26c3ab9..d139576bd 100644 --- a/apps/verification/src/interfaces/verification.interface.ts +++ b/apps/verification/src/interfaces/verification.interface.ts @@ -2,7 +2,8 @@ import { AutoAccept } from "@credebl/enum/enum"; import { IUserRequest } from "@credebl/user-request/user-request.interface"; interface IProofRequestAttribute { - attributeName: string; + attributeName?: string; + attributeNames?:string[]; condition?: string; value?: string; credDefId?: string; diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index b8fc4c9e9..b40cfe585 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -515,20 +515,21 @@ export class VerificationService { requestedPredicates; }> { try { - let requestedAttributes = {}; + let requestedAttributes = {}; const requestedPredicates = {}; const {attributes} = proofRequestpayload; if (attributes) { - requestedAttributes = Object.fromEntries(proofRequestpayload.attributes.map((attribute, index) => { + requestedAttributes = Object.fromEntries(attributes.map((attribute, index) => { - const attributeElement = attribute.attributeName; + const attributeElement = attribute.attributeName || attribute.attributeNames; const attributeReferent = `additionalProp${index + 1}`; + const attributeKey = attribute.attributeName ? 'name' : 'names'; if (!attribute.condition && !attribute.value) { return [ attributeReferent, { - name: attributeElement, + [attributeKey]: attributeElement, restrictions: [ { cred_def_id: proofRequestpayload.attributes[index].credDefId ? proofRequestpayload.attributes[index].credDefId : undefined, From 037b92bc9ef40fdf696c3fd4386d943b88b3ce50 Mon Sep 17 00:00:00 2001 From: KulkarniShashank Date: Tue, 27 Feb 2024 22:29:10 +0530 Subject: [PATCH 2/2] fix: add restriction for predicates Signed-off-by: KulkarniShashank --- apps/verification/src/verification.service.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index bbe73f485..9322b2acd 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -348,7 +348,10 @@ export class VerificationService { ]); const imageUrl = getOrganization?.logoUrl; + const label = getOrganization?.name; + outOfBandRequestProof['imageUrl'] = imageUrl; + outOfBandRequestProof['label'] = label; const orgAgentType = await this.verificationRepository.getOrgAgentType(getAgentDetails?.orgAgentTypeId); let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); @@ -520,10 +523,10 @@ export class VerificationService { const {attributes} = proofRequestpayload; if (attributes) { requestedAttributes = Object.fromEntries(attributes.map((attribute, index) => { - const attributeElement = attribute.attributeName || attribute.attributeNames; const attributeReferent = `additionalProp${index + 1}`; const attributeKey = attribute.attributeName ? 'name' : 'names'; + if (!attribute.condition && !attribute.value) { return [ @@ -542,7 +545,13 @@ export class VerificationService { requestedPredicates[attributeReferent] = { p_type: attribute.condition, name: attributeElement, - p_value: parseInt(attribute.value) + p_value: parseInt(attribute.value), + restrictions: [ + { + cred_def_id: proofRequestpayload.attributes[index].credDefId ? proofRequestpayload.attributes[index].credDefId : undefined, + schema_id: proofRequestpayload.attributes[index].schemaId + } + ] }; }