|
| 1 | +diff --git a/build/shared/utils.js b/build/shared/utils.js |
| 2 | +index 36037ab98cf59f64b56d107aef9b2eb02b491c60..7eccc2ab99d396366299138df8d99376ca35696c 100644 |
| 3 | +--- a/build/shared/utils.js |
| 4 | ++++ b/build/shared/utils.js |
| 5 | +@@ -64,9 +64,10 @@ function getCreateJwtCallback(agentContext) { |
| 6 | + return jws; |
| 7 | + } |
| 8 | + else if (jwtIssuer.method === 'jwk') { |
| 9 | +- const key = (0, core_1.getJwkFromJson)(jwtIssuer.jwk).key; |
| 10 | ++ const jwk = core_1.getJwkFromJson(jwtIssuer.jwk); |
| 11 | ++ const key = jwk.key; |
| 12 | + const jws = await jwsService.createJwsCompact(agentContext, { |
| 13 | +- protectedHeaderOptions: jwt.header, |
| 14 | ++ protectedHeaderOptions: Object.assign(jwt.header, { jwk, alg: jwtIssuer.alg }), |
| 15 | + payload: core_1.JwtPayload.fromJson(jwt.payload), |
| 16 | + key, |
| 17 | + }); |
| 18 | +@@ -75,7 +76,7 @@ function getCreateJwtCallback(agentContext) { |
| 19 | + else if (jwtIssuer.method === 'x5c') { |
| 20 | + const key = core_1.X509Service.getLeafCertificate(agentContext, { certificateChain: jwtIssuer.x5c }).publicKey; |
| 21 | + const jws = await jwsService.createJwsCompact(agentContext, { |
| 22 | +- protectedHeaderOptions: jwt.header, |
| 23 | ++ protectedHeaderOptions: Object.assign(jwt.header, { jwk: undefined, alg: jwtIssuer.alg }), |
| 24 | + payload: core_1.JwtPayload.fromJson(jwt.payload), |
| 25 | + key, |
| 26 | + }); |
| 27 | +@@ -102,17 +103,19 @@ async function openIdTokenIssuerToJwtIssuer(agentContext, openId4VcTokenIssuer) |
| 28 | + const leafCertificate = core_1.X509Service.getLeafCertificate(agentContext, { |
| 29 | + certificateChain: openId4VcTokenIssuer.x5c, |
| 30 | + }); |
| 31 | ++ const jwk = (0, core_1.getJwkFromKey)(leafCertificate.publicKey); |
| 32 | ++ const alg = jwk.supportedSignatureAlgorithms[0] |
| 33 | + if (!issuer.startsWith('https://')) { |
| 34 | + throw new core_1.CredoError('The X509 certificate issuer must be a HTTPS URI.'); |
| 35 | + } |
| 36 | + if ((_b = leafCertificate.sanUriNames) === null || _b === void 0 ? void 0 : _b.includes(issuer)) { |
| 37 | +- return Object.assign(Object.assign({}, openId4VcTokenIssuer), { clientIdScheme: 'x509_san_uri' }); |
| 38 | ++ return Object.assign(Object.assign({}, openId4VcTokenIssuer), { clientIdScheme: 'x509_san_uri', alg }); |
| 39 | + } |
| 40 | + else { |
| 41 | + if (!((_c = leafCertificate.sanDnsNames) === null || _c === void 0 ? void 0 : _c.includes((0, core_1.getDomainFromUrl)(issuer)))) { |
| 42 | + throw new Error(`The 'iss' claim in the payload does not match a 'SAN-URI' or 'SAN-DNS' name in the x5c certificate.`); |
| 43 | + } |
| 44 | +- return Object.assign(Object.assign({}, openId4VcTokenIssuer), { clientIdScheme: 'x509_san_dns' }); |
| 45 | ++ return Object.assign(Object.assign({}, openId4VcTokenIssuer), { clientIdScheme: 'x509_san_dns', alg }); |
| 46 | + } |
| 47 | + } |
| 48 | + return openId4VcTokenIssuer; |
0 commit comments