1- import {
2- type CallbackContext,
3- HashAlgorithm,
4- Oauth2ErrorCodes,
5- Oauth2ServerErrorResponseError,
6- } from '@openid4vc/oauth2'
7- import { decodeBase64, encodeToBase64Url, URL, zHttpsUrl } from '@openid4vc/utils'
1+ import { type CallbackContext, Oauth2ErrorCodes, Oauth2ServerErrorResponseError } from '@openid4vc/oauth2'
2+ import { URL, zHttpsUrl } from '@openid4vc/utils'
83import type { Openid4vpAuthorizationRequest } from '../authorization-request/z-authorization-request'
94import {
105 isOpenid4vpAuthorizationRequestDcApi,
@@ -14,6 +9,7 @@ import {
149import type { VerifiedJarRequest } from '../jar/handle-jar-request/verify-jar-request'
1510import type { ClientMetadata } from '../models/z-client-metadata'
1611import type { Openid4vpVersionNumber } from '../version'
12+ import { calculateX509HashClientIdPrefixValue } from './x509-hash'
1713import {
1814 type ClientIdPrefix,
1915 type LegacyClientIdScheme,
@@ -507,9 +503,10 @@ export async function validateOpenid4vpClientId(
507503 }
508504 }
509505 } else if (clientIdPrefix === 'x509_hash') {
510- const x509Hash = encodeToBase64Url(
511- await options.callbacks.hash(decodeBase64(jar.signer.x5c[0]), HashAlgorithm.Sha256)
512- )
506+ const x509Hash = await calculateX509HashClientIdPrefixValue({
507+ hash: options.callbacks.hash,
508+ x509Certificate: jar.signer.x5c[0],
509+ })
513510
514511 if (x509Hash !== clientIdIdentifier) {
515512 throw new Oauth2ServerErrorResponseError({
0 commit comments