Skip to content

Commit

Permalink
ATL-7741: Remove type DID
Browse files Browse the repository at this point in the history
Signed-off-by: Bassam Riman <[email protected]>
  • Loading branch information
CryptoKnightIOG committed Sep 10, 2024
1 parent dc50537 commit fde53c6
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ trait BackgroundJobsHelper {
case Some(Secp256k1KeyPair(publicKey, privateKey)) =>
ZIO.succeed(
JwtIssuer(
org.hyperledger.identus.pollux.vc.jwt.DID(jwtIssuerDID.toString),
jwtIssuerDID.toString,
ES256KSigner(privateKey.toJavaPrivateKey),
publicKey.toJavaPublicKey
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.hyperledger.identus.pollux.core.service.{
URIDereferencer
}
import org.hyperledger.identus.pollux.vc.jwt.{
DID as PolluxDID,
DidResolver,
Issuer,
JWT,
Expand All @@ -24,7 +23,6 @@ import org.hyperledger.identus.pollux.vc.jwt.{
W3cCredentialPayload,
*
}
import org.hyperledger.identus.pollux.vc.jwt.DID.*
import org.hyperledger.identus.shared.models.*
import zio.*

Expand Down Expand Up @@ -179,7 +177,7 @@ case class OIDCCredentialIssuerServiceImpl(
}

def buildJwtVerifiableCredential(
issuerDid: PolluxDID,
issuerDid: String,
subjectDid: Option[DID],
credentialIdentifier: Option[String],
credentialDefinition: CredentialDefinition,
Expand All @@ -194,7 +192,7 @@ case class OIDCCredentialIssuerServiceImpl(
`type` = Set(
"VerifiableCredential"
) ++ credentialDefinition.`type`, // TODO: This information should come from Schema registry by record.schemaId
issuer = Left(issuerDid.value),
issuer = Left(issuerDid),
issuanceDate = Instant.now(),
maybeExpirationDate = None, // TODO: Add expiration date
maybeCredentialSchema = None, // TODO: Add schema from schema registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.hyperledger.identus.castor.core.service.MockDIDService
import org.hyperledger.identus.iam.authentication.AuthenticatorWithAuthZ
import org.hyperledger.identus.pollux.vc.jwt.*
import org.hyperledger.identus.pollux.vc.jwt.CredentialPayload.Implicits.*
import org.hyperledger.identus.pollux.vc.jwt.DID.*
import org.hyperledger.identus.verification.controller.http.*
import sttp.client3.{basicRequest, DeserializationException, Response, UriContext}
import sttp.client3.ziojson.*
Expand All @@ -31,13 +30,13 @@ object VcVerificationControllerImplSpec extends ZIOSpecDefault with VcVerificati
test("provide incorrect recordId to endpoint") {
for {
vcVerificationController <- ZIO.service[VcVerificationController]
verifier = DID("did:prism:verifier")
verifier = "did:prism:verifier"
currentTime = OffsetDateTime.parse("2010-01-01T00:00:00Z").toOption.get
jwtCredentialPayload = W3cCredentialPayload(
`@context` = Set("https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1"),
maybeId = Some("http://example.edu/credentials/3732"),
`type` = Set("VerifiableCredential", "UniversityDegreeCredential"),
issuer = Left(issuer.did.value),
issuer = Left(issuer.did),
issuanceDate = Instant.parse("2010-01-01T00:00:00Z"),
maybeExpirationDate = Some(Instant.parse("2010-01-12T00:00:00Z")),
maybeValidFrom = Some(Instant.parse("2010-01-12T00:00:00Z")),
Expand Down Expand Up @@ -70,7 +69,7 @@ object VcVerificationControllerImplSpec extends ZIOSpecDefault with VcVerificati
),
maybeEvidence = Option.empty,
maybeTermsOfUse = Option.empty,
aud = Set(verifier.value)
aud = Set(verifier)
).toJwtCredentialPayload
signedJwtCredential = issuer.signer.encode(jwtCredentialPayload.asJson)
authenticator <- ZIO.service[AuthenticatorWithAuthZ[BaseEntity]]
Expand All @@ -88,10 +87,10 @@ object VcVerificationControllerImplSpec extends ZIOSpecDefault with VcVerificati
VcVerificationRequest(
signedJwtCredential.value,
List(
ParameterizableVcVerification(VcVerification.AudienceCheck, Some(DidParameter(verifier.value))),
ParameterizableVcVerification(VcVerification.AudienceCheck, Some(DidParameter(verifier))),
ParameterizableVcVerification(
VcVerification.IssuerIdentification,
Some(DidParameter(issuer.did.value))
Some(DidParameter(issuer.did))
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait VcVerificationControllerTestTools extends PostgresTestContainerSupport {

protected val issuer =
Issuer(
did = org.hyperledger.identus.pollux.vc.jwt.DID(issuerDidData.id.did.toString),
did = issuerDidData.id.did.toString,
signer = ES256KSigner(issuerKp.privateKey.toJavaPrivateKey),
publicKey = issuerKp.publicKey.toJavaPublicKey
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.hyperledger.identus.pollux.core.repository.{CredentialRepository, Cre
import org.hyperledger.identus.pollux.prex.{ClaimFormat, Jwt, PresentationDefinition}
import org.hyperledger.identus.pollux.sdjwt.*
import org.hyperledger.identus.pollux.vc.jwt.{Issuer as JwtIssuer, *}
import org.hyperledger.identus.pollux.vc.jwt.DID.*
import org.hyperledger.identus.shared.crypto.{Ed25519KeyPair, Ed25519PublicKey, Secp256k1KeyPair}
import org.hyperledger.identus.shared.http.{DataUrlResolver, GenericUriResolver}
import org.hyperledger.identus.shared.models.*
Expand Down Expand Up @@ -501,7 +500,7 @@ class CredentialServiceImpl(
maybeId = None,
`type` = Vector("VerifiablePresentation"),
verifiableCredential = IndexedSeq.empty,
holder = subject.did.value,
holder = subject.did,
verifier = IndexedSeq.empty ++ maybeOptions.map(_.domain),
maybeIssuanceDate = None,
maybeExpirationDate = None
Expand Down Expand Up @@ -570,7 +569,7 @@ class CredentialServiceImpl(
.orDieAsUnmanagedFailure
Secp256k1KeyPair(publicKey, privateKey) = ecKeyPair
jwtIssuer = JwtIssuer(
org.hyperledger.identus.pollux.vc.jwt.DID(jwtIssuerDID.toString),
jwtIssuerDID.toString,
ES256KSigner(privateKey.toJavaPrivateKey, keyId),
publicKey.toJavaPublicKey
)
Expand Down Expand Up @@ -611,7 +610,7 @@ class CredentialServiceImpl(
ed25519keyPair <- getEd25519SigningKeyPair(jwtIssuerDID, verificationRelationship)
} yield {
JwtIssuer(
org.hyperledger.identus.pollux.vc.jwt.DID(jwtIssuerDID.toString),
jwtIssuerDID.toString,
EdSigner(ed25519keyPair, keyId),
Ed25519PublicKey.toJavaEd25519PublicKey(ed25519keyPair.publicKey.getEncoded)
)
Expand Down Expand Up @@ -1135,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.value),
issuer = Left(jwtIssuer.did),
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 @@ -633,7 +633,7 @@ private class PresentationServiceImpl(
maybeId = None,
`type` = Vector("VerifiablePresentation"),
verifiableCredential = vcs.toVector,
holder = prover.did.value,
holder = prover.did,
verifier = Vector(options.domain),
maybeIssuanceDate = None,
maybeExpirationDate = None
Expand All @@ -645,7 +645,7 @@ private class PresentationServiceImpl(
maybeId = None,
`type` = Vector("VerifiablePresentation"),
verifiableCredential = vcs.toVector,
holder = prover.did.value,
holder = prover.did,
verifier = Vector("https://example.verifier"), // TODO Fix this
maybeIssuanceDate = None,
maybeExpirationDate = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CredentialStatusListRepositoryInMemory(

val id = UUID.randomUUID()
val issued = Instant.now()
val issuerDid = jwtIssuer.did.value
val issuerDid = jwtIssuer.did
val canonical = PrismDID.fromString(issuerDid).fold(e => throw RuntimeException(e), _.asCanonical)

val embeddedProofCredential = for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSp
Some(Seq(aIssueCredentialRecord.id.value)),
PresentationRecord.ProtocolState.RequestPending
)
issuer = createIssuer(DID("did:prism:issuer"))
issuer = createIssuer("did:prism:issuer")
aPresentationPayload <- svc.createJwtPresentationPayloadFromRecord(aRecord.id, issuer, Instant.now())
} yield {
assertTrue(aPresentationPayload.toJwtPresentationPayload.iss == "did:prism:issuer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait PresentationServiceSpecHelper {
CredentialRepositoryInMemory.layer
) ++ defaultWalletLayer

def createIssuer(did: DID): Issuer = {
def createIssuer(did: String): Issuer = {

val keyPair = KmpSecp256k1KeyOps.generateKeyPair
val javaSKey = keyPair.privateKey.toJavaPrivateKey
Expand Down
Loading

0 comments on commit fde53c6

Please sign in to comment.