@@ -40,24 +40,24 @@ public DPoPProof CreateProofToken(DPoPProofRequest request)
4040
4141 // jwk: representing the public key chosen by the client, in JSON Web Key (JWK) [RFC7517] format,
4242 // as defined in Section 4.1.3 of [RFC7515]. MUST NOT contain a private key.
43- object jwk ;
43+ Dictionary < string , object > jwk ;
4444 if ( string . Equals ( jsonWebKey . Kty , JsonWebAlgorithmsKeyTypes . EllipticCurve ) )
4545 {
46- jwk = new
46+ jwk = new Dictionary < string , object >
4747 {
48- kty = jsonWebKey . Kty ,
49- x = jsonWebKey . X ,
50- y = jsonWebKey . Y ,
51- crv = jsonWebKey . Crv
48+ { " kty" , jsonWebKey . Kty } ,
49+ { "x" , jsonWebKey . X } ,
50+ { "y" , jsonWebKey . Y } ,
51+ { " crv" , jsonWebKey . Crv }
5252 } ;
5353 }
5454 else if ( string . Equals ( jsonWebKey . Kty , JsonWebAlgorithmsKeyTypes . RSA ) )
5555 {
56- jwk = new
56+ jwk = new Dictionary < string , object >
5757 {
58- kty = jsonWebKey . Kty ,
59- e = jsonWebKey . E ,
60- n = jsonWebKey . N
58+ { " kty" , jsonWebKey . Kty } ,
59+ { "e" , jsonWebKey . E } ,
60+ { "n" , jsonWebKey . N }
6161 } ;
6262 }
6363 else
@@ -71,12 +71,12 @@ public DPoPProof CreateProofToken(DPoPProofRequest request)
7171 { JwtClaimTypes . JsonWebKey , jwk } ,
7272 } ;
7373
74- var payload = new Dictionary < string , object >
74+ var payload = new DPoPProofPayload
7575 {
76- { JwtClaimTypes . JwtId , CryptoRandom . CreateUniqueId ( ) } ,
77- { JwtClaimTypes . DPoPHttpMethod , request . Method } ,
78- { JwtClaimTypes . DPoPHttpUrl , request . Url } ,
79- { JwtClaimTypes . IssuedAt , DateTimeOffset . UtcNow . ToUnixTimeSeconds ( ) } ,
76+ JwtId = CryptoRandom . CreateUniqueId ( ) ,
77+ DPoPHttpMethod = request . Method ,
78+ DPoPHttpUrl = request . Url ,
79+ IssuedAt = DateTimeOffset . UtcNow . ToUnixTimeSeconds ( )
8080 } ;
8181
8282 if ( ! string . IsNullOrWhiteSpace ( request . AccessToken ) )
@@ -87,17 +87,17 @@ public DPoPProof CreateProofToken(DPoPProofRequest request)
8787 var hash = sha256 . ComputeHash ( Encoding . ASCII . GetBytes ( request . AccessToken ) ) ;
8888 var ath = Base64Url . Encode ( hash ) ;
8989
90- payload . Add ( JwtClaimTypes . DPoPAccessTokenHash , ath ) ;
90+ payload . DPoPAccessTokenHash = ath ;
9191 }
9292
9393 if ( ! string . IsNullOrEmpty ( request . DPoPNonce ) )
9494 {
95- payload . Add ( JwtClaimTypes . Nonce , request . DPoPNonce ! ) ;
95+ payload . Nonce = request . DPoPNonce ! ;
9696 }
9797
9898 var handler = new JsonWebTokenHandler ( ) { SetDefaultTimesOnTokenCreation = false } ;
9999 var key = new SigningCredentials ( jsonWebKey , jsonWebKey . Alg ) ;
100- var proofToken = handler . CreateToken ( JsonSerializer . Serialize ( payload ) , key , header ) ;
100+ var proofToken = handler . CreateToken ( JsonSerializer . Serialize ( payload , SourceGenerationContext . Default . DPoPProofPayload ) , key , header ) ;
101101
102102 return new DPoPProof { ProofToken = proofToken ! } ;
103103 }
0 commit comments