1- // Get existing EdDSA (Ed25519) keypair from storage or create a new one if missing
2- // EdDSA provides better performance and security compared to ES256
1+ // Get existing ES256 keypair from storage or create a new one if missing
32async function generateDpopJkt ( ) {
43 let stored = null ;
54 try {
@@ -12,15 +11,12 @@ async function generateDpopJkt() {
1211 if ( stored ?. publicKey && stored ?. privateKey ) {
1312 publicJwk = stored . publicKey ;
1413 } else {
15- const keyPair = await crypto . subtle . generateKey ( { name : 'Ed25519 ' } , true , [
14+ const keyPair = await crypto . subtle . generateKey ( { name : 'ECDSA' , namedCurve : 'P-256 ' } , true , [
1615 'sign' ,
1716 'verify'
1817 ] ) ;
1918 const newPublicJwk = await crypto . subtle . exportKey ( 'jwk' , keyPair . publicKey ) ;
2019 const newPrivateJwk = await crypto . subtle . exportKey ( 'jwk' , keyPair . privateKey ) ;
21- // Add algorithm parameter to JWKs for JOSE compatibility
22- newPublicJwk . alg = 'EdDSA' ;
23- newPrivateJwk . alg = 'EdDSA' ;
2420 localStorage . setItem (
2521 'dpop_keypair' ,
2622 JSON . stringify ( {
@@ -38,15 +34,12 @@ async function generateDpopJkt() {
3834
3935// Explicitly rotate the DPoP keypair and return the new jkt
4036async function regenerateDpopJkt ( ) {
41- const keyPair = await crypto . subtle . generateKey ( { name : 'Ed25519 ' } , true , [
37+ const keyPair = await crypto . subtle . generateKey ( { name : 'ECDSA' , namedCurve : 'P-256 ' } , true , [
4238 'sign' ,
4339 'verify'
4440 ] ) ;
4541 const publicJwk = await crypto . subtle . exportKey ( 'jwk' , keyPair . publicKey ) ;
4642 const privateJwk = await crypto . subtle . exportKey ( 'jwk' , keyPair . privateKey ) ;
47- // Add algorithm parameter to JWKs for JOSE compatibility
48- publicJwk . alg = 'EdDSA' ;
49- privateJwk . alg = 'EdDSA' ;
5043 localStorage . setItem (
5144 'dpop_keypair' ,
5245 JSON . stringify ( {
0 commit comments