Skip to content

Commit

Permalink
feat: add schemaId to the issuance session (#1199)
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
  • Loading branch information
yshyn-iohk committed Jun 21, 2024
1 parent 1712062 commit 97f5d83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ import org.hyperledger.identus.pollux.core.service.{
OID4VCIIssuerMetadataServiceError,
URIDereferencer
}
import org.hyperledger.identus.pollux.vc.jwt.*
import org.hyperledger.identus.pollux.vc.jwt.{
DID as PolluxDID,
DidResolver,
Issuer,
JWT,
JWTVerification,
JwtCredential,
W3cCredentialPayload
W3cCredentialPayload,
*
}
import org.hyperledger.identus.shared.models.{WalletAccessContext, WalletId}
import zio.*

import java.net.URL
import java.security.PublicKey
import java.net.{URI, URL}
import java.time.Instant
import java.util.UUID
import scala.util.Try
Expand Down Expand Up @@ -248,7 +247,7 @@ case class OIDCCredentialIssuerServiceImpl(
_ <- CredentialSchema
.validateJWTCredentialSubject(schemaId.toString(), simpleZioToCirce(claims).noSpaces, uriDereferencer)
.mapError(e => CredentialSchemaError(e))
session <- buildNewIssuanceSession(issuerId, issuingDID, claims)
session <- buildNewIssuanceSession(issuerId, issuingDID, claims, schemaId)
_ <- issuanceSessionStorage
.start(session)
.mapError(e => ServiceError(s"Failed to start issuance session: ${e.message}"))
Expand Down Expand Up @@ -278,7 +277,8 @@ case class OIDCCredentialIssuerServiceImpl(
private def buildNewIssuanceSession(
issuerId: UUID,
issuerDid: PrismDID,
claims: zio.json.ast.Json
claims: zio.json.ast.Json,
schemaId: URI
): UIO[IssuanceSession] = {
for {
id <- ZIO.random.flatMap(_.nextUUID)
Expand All @@ -290,7 +290,7 @@ case class OIDCCredentialIssuerServiceImpl(
nonce = nonce.toString,
issuerState = issuerState.toString,
claims = claims,
schemaId = None, // FIXME: populate correct value
schemaId = Some(schemaId.toString),
subjectDid = None, // FIXME: populate correct value
issuingDid = issuerDid,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object OIDCCredentialIssuerServiceSpec
MockOID4VCIIssuerMetadataService.empty,
layers
),
test("create credential-offer with valid claims") {
test("create credential-offer with valid claims and schemaId") {
val wac = ZLayer.succeed(WalletAccessContext(WalletId.random))
val claims = Json(
"credentialSubject" -> Json.Obj(
Expand All @@ -187,7 +187,8 @@ object OIDCCredentialIssuerServiceSpec
.provide(wac)
issuerState = offer.grants.get.authorization_code.issuer_state.get
session <- oidcCredentialIssuerService.getIssuanceSessionByIssuerState(issuerState)
} yield assert(session.claims)(equalTo(claims))
} yield assert(session.claims)(equalTo(claims)) &&
assert(session.schemaId)(isSome(equalTo("resource:///vc-schema-example.json")))
}.provide(
MockDIDService.empty,
MockManagedDIDService.empty,
Expand Down

0 comments on commit 97f5d83

Please sign in to comment.