Skip to content

Commit

Permalink
feat(pollux): Moving the check when accepting the credential to crea… (
Browse files Browse the repository at this point in the history
…#391)

* feat(pollux): Moving the check when accepting the creadential to creat VP

* feat(pollux): pr comments addressed
  • Loading branch information
mineme0110 authored Feb 23, 2023
1 parent c96f804 commit 2765845
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,8 @@ private class PresentationServiceImpl(
.getValidIssuedCredentials(credentialsToUse.map(UUID.fromString))
.mapError(RepositoryError.apply)

_ <- ZIO.cond(
issuedValidCredentials.forall(_.subjectId == prover.did.value),
(),
PresentationError.HolderBindingError(
s"Presenting credential with different subject than the prover DID is not supported"
)
)
issuedRawCredentials = issuedValidCredentials.map(_.issuedCredentialRaw.map(IssuedCredentialRaw(_))).flatten
issuedRawCredentials = issuedValidCredentials.flatMap(_.issuedCredentialRaw.map(IssuedCredentialRaw(_)))

issuedCredentials <- ZIO.fromEither(
Either.cond(
issuedRawCredentials.nonEmpty,
Expand Down Expand Up @@ -363,6 +357,14 @@ private class PresentationServiceImpl(
issuedValidCredentials <- credentialRepository
.getValidIssuedCredentials(credentialsToUse.map(UUID.fromString))
.mapError(RepositoryError.apply)
_ <- ZIO.cond(
(issuedValidCredentials.map(_.subjectId).toSet.size == 1),
(),
PresentationError.HolderBindingError(
s"Creating a Verifiable Presentation for credential with different subject DID is not supported, found : ${issuedValidCredentials
.map(_.subjectId)}"
)
)
issuedRawCredentials = issuedValidCredentials.flatMap(_.issuedCredentialRaw.map(IssuedCredentialRaw(_)))
issuedCredentials <- ZIO.fromEither(
Either.cond(
Expand Down

0 comments on commit 2765845

Please sign in to comment.