Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiple attributes in proof request fixes #550

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api-gateway/src/dtos/create-schema.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class CreateSchemaDto {
attributeName: 'name',
schemaDataType: 'string',
displayName: 'Name',
isRequired: 'true'
isRequired: true
}
]
})
Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/ecosystem/dtos/request-schema.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class RequestSchemaDto {
attributeName: 'name',
schemaDataType: 'string',
displayName: 'Name',
isRequired: 'true'
isRequired: true
}
]
})
Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/verification/dto/request-proof.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ProofRequestAttribute {

@ValidateIf((obj) => obj.attributeNames === undefined)
@IsNotEmpty()
@IsString({each:true})
@IsString()
attributeName?: string;

@ValidateIf((obj) => obj.attributeName === undefined)
Expand Down
3 changes: 2 additions & 1 deletion apps/verification/src/interfaces/verification.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 16 additions & 6 deletions apps/verification/src/verification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -515,20 +518,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) => {

const attributeElement = attribute.attributeName;
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 [
attributeReferent,
{
name: attributeElement,
[attributeKey]: attributeElement,
restrictions: [
{
cred_def_id: proofRequestpayload.attributes[index].credDefId ? proofRequestpayload.attributes[index].credDefId : undefined,
Expand All @@ -541,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
}
]
};
}

Expand Down