@@ -13,6 +13,9 @@ import {
1313 ResponseType ,
1414} from '@sphereon/oid4vci-common' ;
1515import { formPost } from '@sphereon/oid4vci-common' ;
16+ import Debug from 'debug' ;
17+
18+ const debug = Debug ( 'sphereon:oid4vci' ) ;
1619
1720export const createAuthorizationRequestUrl = async ( {
1821 pkce,
@@ -87,24 +90,24 @@ export const createAuthorizationRequestUrl = async ({
8790 if ( ! parEndpoint && parMode === PARMode . REQUIRE ) {
8891 throw Error ( `PAR mode is set to required by Authorization Server does not support PAR!` ) ;
8992 } else if ( parEndpoint && parMode !== PARMode . NEVER ) {
90- console . log ( `USING PAR with endpoint ${ parEndpoint } ` ) ;
93+ debug ( `USING PAR with endpoint ${ parEndpoint } ` ) ;
9194 const parResponse = await formPost < PushedAuthorizationResponse > ( parEndpoint , new URLSearchParams ( queryObj ) ) ;
9295 if ( parResponse . errorBody || ! parResponse . successBody ) {
9396 throw Error ( `PAR error` ) ;
9497 }
95- console . log ( `PAR response: ${ ( parResponse . successBody , null , 2 ) } ` ) ;
98+ debug ( `PAR response: ${ ( parResponse . successBody , null , 2 ) } ` ) ;
9699 queryObj = { request_uri : parResponse . successBody . request_uri } ;
97100 }
98101
99- console . log ( `QUERY obj : ` + JSON . stringify ( queryObj , null , 2 ) ) ;
102+ debug ( `Object that will become query params : ` + JSON . stringify ( queryObj , null , 2 ) ) ;
100103 const url = convertJsonToURI ( queryObj , {
101104 baseUrl : endpointMetadata . authorization_endpoint ,
102105 uriTypeProperties : [ 'client_id' , 'request_uri' , 'redirect_uri' , 'scope' , 'authorization_details' , 'issuer_state' ] ,
103106 // arrayTypeProperties: ['authorization_details'],
104107 mode : JsonURIMode . X_FORM_WWW_URLENCODED ,
105108 // We do not add the version here, as this always needs to be form encoded
106109 } ) ;
107- console . log ( `Authorization Request URL: ${ url } ` ) ;
110+ debug ( `Authorization Request URL: ${ url } ` ) ;
108111 return url ;
109112} ;
110113
0 commit comments