@@ -108,7 +108,7 @@ export interface GetOpenid4vpClientIdOptions {
108108/**
109109 * Get the client id for an authorization request based on the response_mode, client_id, client_id_scheme and origin values.
110110 *
111- * It will return the client id scheme as used in OpenID4VP draft 29 , and optionally provide the legacyClientId if the
111+ * It will return the client id prefix as used in OpenID4VP v1 , and optionally provide the legacyClientId if the
112112 * client id was provided with a client_id_scheme
113113 */
114114export function getOpenid4vpClientId ( options : GetOpenid4vpClientIdOptions ) : {
@@ -127,7 +127,7 @@ export function getOpenid4vpClientId(options: GetOpenid4vpClientIdOptions): {
127127 clientIdPrefix : UniformClientIdPrefix
128128
129129 /**
130- * The effective client id scheme , is the client id scheme that was used in the actual request.
130+ * The effective client id prefix , is the client id prefix that was used in the actual request.
131131 *
132132 * E.g. `did` will remain as `did`
133133 */
@@ -317,7 +317,7 @@ export async function validateOpenid4vpClientId(
317317 if ( ! parserConfigWithDefaults . supportedSchemes . includes ( clientIdPrefix ) ) {
318318 throw new Oauth2ServerErrorResponseError ( {
319319 error : Oauth2ErrorCodes . InvalidRequest ,
320- error_description : `Unsupported client identifier scheme . ${ clientIdPrefix } is not supported.` ,
320+ error_description : `Unsupported client identifier prefix . ${ clientIdPrefix } is not supported.` ,
321321 } )
322322 }
323323
@@ -337,15 +337,15 @@ export async function validateOpenid4vpClientId(
337337 if ( ! jar ) {
338338 throw new Oauth2ServerErrorResponseError ( {
339339 error : Oauth2ErrorCodes . InvalidRequest ,
340- error_description : 'Using client identifier scheme "https" requires a signed JAR request.' ,
340+ error_description : 'Using client identifier prefix "https" requires a signed JAR request.' ,
341341 } )
342342 }
343343
344344 if ( jar . signer . method !== 'federation' ) {
345345 throw new Oauth2ServerErrorResponseError ( {
346346 error : Oauth2ErrorCodes . InvalidRequest ,
347347 error_description :
348- 'Something went wrong. The JWT signer method is not federation but the client identifier scheme is https.' ,
348+ 'Something went wrong. The JWT signer method is not federation but the client identifier prefix is https.' ,
349349 } )
350350 }
351351
@@ -362,14 +362,28 @@ export async function validateOpenid4vpClientId(
362362 if ( jar ) {
363363 throw new Oauth2ServerErrorResponseError ( {
364364 error : Oauth2ErrorCodes . InvalidRequest ,
365- error_description : 'Using client identifier scheme "redirect_uri" the request MUST NOT be signed.' ,
365+ error_description : 'Using client identifier prefix "redirect_uri" the request MUST NOT be signed.' ,
366366 } )
367367 }
368368
369369 if ( isOpenid4vpAuthorizationRequestDcApi ( authorizationRequestPayload ) ) {
370370 throw new Oauth2ServerErrorResponseError ( {
371371 error : Oauth2ErrorCodes . InvalidRequest ,
372- error_description : `The client identifier scheme 'redirect_uri' is not supported when using the dc_api response mode.` ,
372+ error_description : `The client identifier prefix 'redirect_uri' is not supported when using the dc_api response mode.` ,
373+ } )
374+ }
375+
376+ if ( authorizationRequestPayload . redirect_uri && authorizationRequestPayload . redirect_uri !== clientIdIdentifier ) {
377+ throw new Oauth2ServerErrorResponseError ( {
378+ error : Oauth2ErrorCodes . InvalidClient ,
379+ error_description : `When the client identifier prefix is 'redirect_uri', the client id identifier MUST match the redirect_uri.` ,
380+ } )
381+ }
382+
383+ if ( authorizationRequestPayload . response_uri && authorizationRequestPayload . redirect_uri !== clientIdIdentifier ) {
384+ throw new Oauth2ServerErrorResponseError ( {
385+ error : Oauth2ErrorCodes . InvalidClient ,
386+ error_description : `When the client identifier prefix is 'redirect_uri', the client id identifier MUST match the response_uri.` ,
373387 } )
374388 }
375389
@@ -387,15 +401,15 @@ export async function validateOpenid4vpClientId(
387401 if ( ! jar ) {
388402 throw new Oauth2ServerErrorResponseError ( {
389403 error : Oauth2ErrorCodes . InvalidRequest ,
390- error_description : 'Using client identifier scheme "did" requires a signed JAR request.' ,
404+ error_description : 'Using client identifier prefix "did" requires a signed JAR request.' ,
391405 } )
392406 }
393407
394408 if ( jar . signer . method !== 'did' ) {
395409 throw new Oauth2ServerErrorResponseError ( {
396410 error : Oauth2ErrorCodes . InvalidRequest ,
397411 error_description :
398- 'Something went wrong. The JWT signer method is not did but the client identifier scheme is did.' ,
412+ 'Something went wrong. The JWT signer method is not did but the client identifier prefix is did.' ,
399413 } )
400414 }
401415
@@ -410,7 +424,7 @@ export async function validateOpenid4vpClientId(
410424 if ( clientIdIdentifier !== did ) {
411425 throw new Oauth2ServerErrorResponseError ( {
412426 error : Oauth2ErrorCodes . InvalidRequest ,
413- error_description : `With client identifier scheme '${ clientIdPrefix } ' the JAR request must be signed by the same DID as the client identifier.` ,
427+ error_description : `With client identifier prefix '${ clientIdPrefix } ' the JAR request must be signed by the same DID as the client identifier.` ,
414428 } )
415429 }
416430
@@ -428,14 +442,14 @@ export async function validateOpenid4vpClientId(
428442 if ( ! jar ) {
429443 throw new Oauth2ServerErrorResponseError ( {
430444 error : Oauth2ErrorCodes . InvalidRequest ,
431- error_description : `Using client identifier scheme '${ clientIdPrefix } ' requires a signed JAR request.` ,
445+ error_description : `Using client identifier prefix '${ clientIdPrefix } ' requires a signed JAR request.` ,
432446 } )
433447 }
434448
435449 if ( jar . signer . method !== 'x5c' ) {
436450 throw new Oauth2ServerErrorResponseError ( {
437451 error : Oauth2ErrorCodes . InvalidRequest ,
438- error_description : `Something went wrong. The JWT signer method is not x5c but the client identifier scheme is '${ clientIdPrefix } '` ,
452+ error_description : `Something went wrong. The JWT signer method is not x5c but the client identifier prefix is '${ clientIdPrefix } '` ,
439453 } )
440454 }
441455
@@ -445,7 +459,7 @@ export async function validateOpenid4vpClientId(
445459 error : Oauth2ErrorCodes . ServerError ,
446460 } ,
447461 {
448- internalMessage : `Missing required 'getX509CertificateMetadata' callback for verification of '${ clientIdPrefix } ' client id scheme ` ,
462+ internalMessage : `Missing required 'getX509CertificateMetadata' callback for verification of '${ clientIdPrefix } ' client id prefix ` ,
449463 }
450464 )
451465 }
@@ -525,7 +539,7 @@ export async function validateOpenid4vpClientId(
525539 if ( ! jar ) {
526540 throw new Oauth2ServerErrorResponseError ( {
527541 error : Oauth2ErrorCodes . InvalidRequest ,
528- error_description : 'Using client identifier scheme "verifier_attestation" requires a signed JAR request.' ,
542+ error_description : 'Using client identifier prefix "verifier_attestation" requires a signed JAR request.' ,
529543 } )
530544 }
531545 }
0 commit comments