33 Alg ,
44 AuthorizationRequestOpts ,
55 AuthorizationResponse ,
6+ AuthorizationServerOpts ,
67 AuthzFlowType ,
78 CodeChallengeMethod ,
89 CredentialConfigurationSupported ,
@@ -274,8 +275,9 @@ export class OpenID4VCIClient {
274275 code ?: string ; // Directly pass in a code from an auth response
275276 redirectUri ?: string ;
276277 additionalRequestParams ?: Record < string , any > ;
278+ asOpts ?: AuthorizationServerOpts ;
277279 } ) : Promise < AccessTokenResponse > {
278- const { pin, clientId } = opts ?? { } ;
280+ const { pin, clientId = this . _state . clientId ?? this . _state . authorizationRequestOpts ?. clientId } = opts ?? { } ;
279281 let { redirectUri } = opts ?? { } ;
280282 if ( opts ?. authorizationResponse ) {
281283 this . _state . authorizationCodeResponse = { ...toAuthorizationResponsePayload ( opts . authorizationResponse ) } ;
@@ -289,6 +291,23 @@ export class OpenID4VCIClient {
289291 }
290292 this . assertIssuerData ( ) ;
291293
294+ const asOpts : AuthorizationServerOpts = { ...opts ?. asOpts } ;
295+ const kid = asOpts . clientOpts ?. kid ?? this . _state . kid ?? this . _state . authorizationRequestOpts ?. requestObjectOpts ?. kid ;
296+ const clientAssertionType =
297+ asOpts . clientOpts ?. clientAssertionType ??
298+ ( kid && clientId && typeof asOpts . clientOpts ?. signCallbacks === 'function'
299+ ? 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
300+ : undefined ) ;
301+ if ( clientId ) {
302+ asOpts . clientOpts = {
303+ ...asOpts . clientOpts ,
304+ clientId,
305+ ...( kid && { kid } ) ,
306+ ...( clientAssertionType && { clientAssertionType } ) ,
307+ signCallbacks : asOpts . clientOpts ?. signCallbacks ?? this . _state . authorizationRequestOpts ?. requestObjectOpts ?. signCallbacks ,
308+ } ;
309+ }
310+
292311 if ( clientId ) {
293312 this . _state . clientId = clientId ;
294313 }
@@ -312,7 +331,7 @@ export class OpenID4VCIClient {
312331 ...( ! this . _state . pkce . disabled && { codeVerifier : this . _state . pkce . codeVerifier } ) ,
313332 code,
314333 redirectUri,
315- asOpts : { clientId : this . clientId } ,
334+ asOpts,
316335 ...( opts ?. additionalRequestParams && { additionalParams : opts . additionalRequestParams } ) ,
317336 } ) ;
318337
0 commit comments