diff --git a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala index 30f408228d..ff8f67acc3 100644 --- a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala +++ b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala @@ -1134,7 +1134,7 @@ class CredentialServiceImpl( maybeId = None, `type` = Set("VerifiableCredential"), // TODO: This information should come from Schema registry by record.schemaId - issuer = Left(jwtIssuer.did.toString), + issuer = Right(CredentialIssuer(jwtIssuer.did.toString, `type` = "Profile")), issuanceDate = issuanceDate, maybeExpirationDate = record.validityPeriod.map(sec => issuanceDate.plusSeconds(sec.toLong)), maybeCredentialSchema = diff --git a/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImplSpec.scala b/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImplSpec.scala index 3f1fde1906..a63890f44a 100644 --- a/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImplSpec.scala +++ b/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImplSpec.scala @@ -14,6 +14,7 @@ import org.hyperledger.identus.pollux.core.model.error.CredentialServiceError import org.hyperledger.identus.pollux.core.model.error.CredentialServiceError.* import org.hyperledger.identus.pollux.core.model.schema.CredentialDefinition import org.hyperledger.identus.pollux.core.model.IssueCredentialRecord.{ProtocolState, Role} +import org.hyperledger.identus.pollux.vc.jwt.{CredentialIssuer, JWT, JwtCredential, JwtCredentialPayload} import org.hyperledger.identus.shared.models.{KeyId, UnmanagedFailureException, WalletAccessContext, WalletId} import zio.* import zio.mock.MockSpecDefault @@ -523,13 +524,27 @@ object CredentialServiceImplSpec extends MockSpecDefault with CredentialServiceS issuerRecordId, "https://test-status-list.registry" ) + decodedJWT <- credentialGenerateRecord.issueCredentialData.get.attachments.head.data match { + case MyBase64(value) => + val ba = new String(Base64.getUrlDecoder.decode(value)) + JwtCredential.decodeJwt(JWT(ba)) + case _ => ZIO.fail("Error") + } // Issuer sends credential _ <- issuerSvc.markCredentialSent(issuerRecordId) msg <- ZIO.fromEither(credentialGenerateRecord.issueCredentialData.get.makeMessage.asJson.as[Message]) // Holder receives credential issueCredential <- ZIO.fromEither(IssueCredential.readFromMessage(msg)) _ <- holderSvc.receiveCredentialIssue(issueCredential) - } yield assertTrue(true) + } yield assertTrue( + decodedJWT.issuer == + Right( + CredentialIssuer( + id = decodedJWT.iss, + `type` = "Profile" + ) + ) + ) }.provideSomeLayer( (holderDidServiceExpectations ++ issuerDidServiceExpectations).toLayer ++ (holderManagedDIDServiceExpectations ++ issuerManagedDIDServiceExpectations).toLayer diff --git a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala index e361897df7..d2590bb512 100644 --- a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala +++ b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala @@ -40,7 +40,6 @@ trait Signer { def encode(claim: Json): JWT def generateProofForJson(payload: Json, pk: PublicKey): Task[Proof] - } // works with java 7, 8, 11 & bouncycastle provider