Skip to content

Commit

Permalink
feat: Default Object As Issuer (hyperledger#1349)
Browse files Browse the repository at this point in the history
Signed-off-by: Bassam Riman <[email protected]>
  • Loading branch information
CryptoKnightIOG authored Sep 12, 2024
1 parent 3576832 commit d29eebb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d29eebb

Please sign in to comment.