@@ -35,7 +35,7 @@ fun String?.toJWTKeyID(): JWTKeyID? = this?.let { JWTKeyID(it)}
3535@Serializable
3636data class JOSEHeader <T : JWSAlgorithm >(
3737 @SerialName(" alg" ) @Serializable(JWSAlgorithmSerializer ::class ) val algorithm : T ,
38- @SerialName(" typ" ) @Serializable(JOSETypeSerializer ::class ) val type : JOSEType ,
38+ @SerialName(" typ" ) @Serializable(JOSETypeSerializer ::class ) val type : JOSEType ? = null ,
3939 @SerialName(" kid" ) val keyID : JWTKeyID ? = null ,
4040) {
4141 fun toJSON (): String {
@@ -104,6 +104,7 @@ class JWT<T: JWSAlgorithm> private constructor(
104104 prettyPrint = true
105105 }
106106
107+ internal fun es256WithoutTypeHeader (claims : JWTClaimSetBuilder .() -> Unit ): JWT <JWSES256Algorithm > = buildJWT(JOSEHeader (JWSES256Algorithm ), claims)
107108 fun es256 (keyID : JWTKeyID ? = null, claims : JWTClaimSetBuilder .() -> Unit ): JWT <JWSES256Algorithm > = buildJWT(JOSEHeader (JWSES256Algorithm , JOSEType .JWT , keyID), claims)
108109 fun es256k (keyID : JWTKeyID ? = null, claims : JWTClaimSetBuilder .() -> Unit ): JWT <JWSES256KAlgorithm > = buildJWT(JOSEHeader (JWSES256KAlgorithm , JOSEType .JWT , keyID), claims)
109110 fun es384 (keyID : JWTKeyID ? = null, claims : JWTClaimSetBuilder .() -> Unit ): JWT <JWSES384Algorithm > = buildJWT(JOSEHeader (JWSES384Algorithm , JOSEType .JWT , keyID), claims)
@@ -131,7 +132,9 @@ class JWT<T: JWSAlgorithm> private constructor(
131132
132133 val h = Either .catch {
133134 format.decodeFromString(JOSEHeader .serializer(PolymorphicSerializer (JWSAlgorithm ::class )), jwtDecodeString(parts[0 ]))
134- }.mapLeft { KJWTVerificationError .AlgorithmMismatch }.bind()
135+ }.mapLeft {
136+ println (it)
137+ KJWTVerificationError .AlgorithmMismatch }.bind()
135138 val claims = Either .catch { format.parseToJsonElement(jwtDecodeString(parts[1 ])) }.mapLeft { KJWTVerificationError .InvalidJWT }.bind()
136139 val claimsMap = Either .catch { (claims as JsonObject ) }.mapLeft { KJWTVerificationError .EmptyClaims }.bind()
137140
0 commit comments