Skip to content

Commit

Permalink
bug: credential preview attributes mismatch schema attributes
Browse files Browse the repository at this point in the history
Signed-off-by: annelein <anneleinvanreijen@gmail.com>
  • Loading branch information
Annelein committed Feb 7, 2022
1 parent beff6b0 commit ea2aa64
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ export class CredentialService {
}),
})

// Check if credential preview attributes match the schema attributes
const schema = await this.ledgerService.getSchema(credOffer.schema_id)
const credAttributes = credentialTemplate.preview.attributes
const schemaAttribute = schema.attrNames

credAttributes.forEach((credAtrr) => {
if (schemaAttribute.indexOf(credAtrr.name) === -1) {
throw new AriesFrameworkError(`The credential preview attributes do not match the schema attributes`)
}
})

const credentialOfferMessage = new OfferCredentialMessage({
comment,
offerAttachments: [offerAttachment],
Expand Down Expand Up @@ -297,6 +308,17 @@ export class CredentialService {
}),
})

// Check if credential preview attributes match the schema attributes
const schema = await this.ledgerService.getSchema(credOffer.schema_id)
const credAttributes = credentialTemplate.preview.attributes
const schemaAttribute = schema.attrNames

credAttributes.forEach((credAtrr) => {
if (schemaAttribute.indexOf(credAtrr.name) === -1) {
throw new AriesFrameworkError(`The credential preview attributes do not match the schema attributes`)
}
})

// Create and link credential to attacment
const credentialPreview = linkedAttachments
? CredentialUtils.createAndLinkAttachmentsToPreview(linkedAttachments, preview)
Expand Down

0 comments on commit ea2aa64

Please sign in to comment.