Skip to content

Commit

Permalink
fix: make kid and validityPeriod optional for the new API version
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Shynbuiev <[email protected]>
  • Loading branch information
yshyn-iohk committed Jan 16, 2025
1 parent d8d016c commit 8363d1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,20 @@ class IssueControllerImpl(
.fromOption(request.jwtVcPropertiesV1.map(_.claims).orElse(request.claims))
.orElseFail(ErrorResponse.badRequest(detail = Some("Missing request parameter: claims")))
kid = request.jwtVcPropertiesV1
.map(_.issuingKid)
.flatMap(_.issuingKid)
.orElse(request.issuingKid) // TODO: should it be Option[KeyId]?
validityPeriod = request.jwtVcPropertiesV1
.flatMap(_.validityPeriod)
.orElse(request.validityPeriod)
record <- credentialService
.createJWTIssueCredentialRecord(
pairwiseIssuerDID = offerContext.pairwiseIssuerDID,
pairwiseHolderDID = offerContext.pairwiseHolderDID,
kidIssuer = request.issuingKid,
kidIssuer = kid,
thid = DidCommID(),
credentialSchemaRef = Some(credentialSchemaRef),
claims = claims,
validityPeriod = request.validityPeriod,
validityPeriod = validityPeriod,
automaticIssuance = request.automaticIssuance.orElse(Some(true)),
issuingDID = issuingDID.asCanonical,
goalCode = offerContext.goalCode,
Expand All @@ -148,6 +151,9 @@ class IssueControllerImpl(
kid = request.sdJwtVcPropertiesV1
.flatMap(_.issuingKid)
.orElse(request.issuingKid) // TODO: should it be Option[KeyId]?
validityPeriod = request.sdJwtVcPropertiesV1
.flatMap(_.validityPeriod)
.orElse(request.validityPeriod)
record <- credentialService
.createSDJWTIssueCredentialRecord(
pairwiseIssuerDID = offerContext.pairwiseIssuerDID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ case class JwtVCPropertiesV1(
issuingKid: Option[KeyId],
@description(JwtVCPropertiesV1.annotations.validityPeriod.description)
@encodedExample(JwtVCPropertiesV1.annotations.validityPeriod.example)
validityPeriod: Double,
validityPeriod: Option[Double],
@description(JwtVCPropertiesV1.annotations.claims.description)
@encodedExample(JwtVCPropertiesV1.annotations.claims.example)
claims: zio.json.ast.Json,
Expand Down Expand Up @@ -247,6 +247,9 @@ case class SDJWTVCPropertiesV1(
@description(annotations.issuingKid.description)
@encodedExample(annotations.issuingKid.example)
issuingKid: Option[KeyId],
@description(SDJWTVCPropertiesV1.annotations.validityPeriod.description)
@encodedExample(SDJWTVCPropertiesV1.annotations.validityPeriod.example)
validityPeriod: Option[Double],
@description(SDJWTVCPropertiesV1.annotations.credentialSchema.description)
@encodedExample(SDJWTVCPropertiesV1.annotations.credentialSchema.example)
credentialSchema: CredentialSchemaRef,
Expand All @@ -263,6 +266,11 @@ object SDJWTVCPropertiesV1 {
given decoder: JsonDecoder[SDJWTVCPropertiesV1] = DeriveJsonDecoder.gen

object annotations {
object validityPeriod
extends Annotation[Double](
description = "The validity period in seconds of the verifiable credential that will be issued.",
example = 3600
)
object issuingDID
extends Annotation[String](
description = """
Expand Down

0 comments on commit 8363d1e

Please sign in to comment.