From 2afdda6ae8f9c32ed18ec45a03f67c4c8947ad9f Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 26 Jun 2023 15:40:07 -0400 Subject: [PATCH 1/2] fix: JWTJsonPayload fields are optional except --- .../iohk/atala/prism/walletsdk/pollux/JWTJsonPayload.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/JWTJsonPayload.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/JWTJsonPayload.kt index 1055fa21b..9b21f1e6a 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/JWTJsonPayload.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/JWTJsonPayload.kt @@ -5,9 +5,9 @@ import kotlinx.serialization.json.JsonElement @Serializable data class JWTJsonPayload( - val iss: String, - val sub: String, - val nbf: Long, - val exp: Long, + val iss: String? = null, + val sub: String? = null, + val nbf: Long? = null, + val exp: Long? = null, val vc: JsonElement ) From 3de1b01b79e8fdfc799acb46bbf948a7a97e24d1 Mon Sep 17 00:00:00 2001 From: Cristian G Date: Tue, 27 Jun 2023 09:42:10 -0400 Subject: [PATCH 2/2] fix: JWT json fields enforced mandatory when they should be optional --- .../walletsdk/domain/models/JWTCredentialPayload.kt | 12 ++++++------ .../walletsdk/domain/models/VerifiableCredential.kt | 2 +- .../domain/models/W3CVerifiableCredential.kt | 2 +- .../iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTCredentialPayload.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTCredentialPayload.kt index 24ad992cf..50f4157b4 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTCredentialPayload.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTCredentialPayload.kt @@ -43,13 +43,13 @@ import kotlin.jvm.JvmOverloads */ @Serializable data class JWTCredentialPayload( - val iss: DID, + val iss: DID?, val sub: String?, @SerialName(VC) val verifiableCredential: JWTVerifiableCredential, - val nbf: String, + val nbf: String?, val exp: String?, - val jti: String + val jti: String? ) : VerifiableCredential { /** @@ -60,7 +60,7 @@ data class JWTCredentialPayload( override val credentialType: CredentialType, override val context: Array = arrayOf(), override val type: Array = arrayOf(), - override val issuer: DID, + override val issuer: DID?, override val credentialSchema: VerifiableCredentialTypeContainer? = null, override val credentialSubject: String, override val credentialStatus: VerifiableCredentialTypeContainer? = null, @@ -125,7 +125,7 @@ data class JWTCredentialPayload( } override val id: String - get() = jti + get() = jti ?: "" override val credentialType: CredentialType get() = CredentialType.JWT override val context: Array @@ -144,7 +144,7 @@ data class JWTCredentialPayload( get() = verifiableCredential.evidence override val termsOfUse: VerifiableCredentialTypeContainer? get() = verifiableCredential.termsOfUse - override val issuer: DID + override val issuer: DID? get() = verifiableCredential.issuer override val issuanceDate: String get() = verifiableCredential.issuanceDate diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/VerifiableCredential.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/VerifiableCredential.kt index d80db4028..3c3dad3f4 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/VerifiableCredential.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/VerifiableCredential.kt @@ -44,7 +44,7 @@ sealed interface VerifiableCredential { val refreshService: VerifiableCredentialTypeContainer? val evidence: VerifiableCredentialTypeContainer? val termsOfUse: VerifiableCredentialTypeContainer? - val issuer: DID + val issuer: DID? val issuanceDate: String // TODO(Date) val expirationDate: String? // TODO(Date) val validFrom: VerifiableCredentialTypeContainer? diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CVerifiableCredential.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CVerifiableCredential.kt index 9379a22a0..a2fa5fdde 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CVerifiableCredential.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CVerifiableCredential.kt @@ -19,7 +19,7 @@ data class W3CVerifiableCredential @JvmOverloads constructor( override val credentialType: CredentialType = CredentialType.W3C, override val context: Array, override val type: Array, - override val issuer: DID, + override val issuer: DID?, override val issuanceDate: String, override val expirationDate: String? = null, override val credentialSchema: VerifiableCredentialTypeContainer? = null, diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt index da8cedb55..0bb8c2248 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt @@ -48,14 +48,14 @@ class PolluxImpl(val castor: Castor) : Pollux { val verifiableCredentialJson = Json.decodeFromString(decodedBase64CredentialJson) return JWTCredentialPayload( - iss = DID(verifiableCredentialJson.iss), - exp = verifiableCredentialJson.exp.toString(), - nbf = verifiableCredentialJson.nbf.toString(), + iss = if (verifiableCredentialJson.iss != null) DID(verifiableCredentialJson.iss) else null, + exp = if (verifiableCredentialJson.exp != null) verifiableCredentialJson.exp.toString() else null, + nbf = if (verifiableCredentialJson.nbf != null) verifiableCredentialJson.nbf.toString() else null, jti = jwtString, verifiableCredential = JWTCredentialPayload.JWTVerifiableCredential( credentialType = CredentialType.JWT, - issuer = DID(verifiableCredentialJson.iss), - credentialSubject = verifiableCredentialJson.sub, + issuer = if (verifiableCredentialJson.iss != null) DID(verifiableCredentialJson.iss) else null, + credentialSubject = verifiableCredentialJson.sub ?: "", id = jwtString, issuanceDate = verifiableCredentialJson.nbf.toString(), expirationDate = verifiableCredentialJson.exp.toString(),