@@ -344,28 +344,34 @@ const WEBFORMS_SCOPES = [
344
344
const scope = [ ...ROOM_SCOPES , ...CLICK_SCOPES , ...MONITOR_SCOPES , ...ADMIN_SCOPES , ...SCOPES , ...WEBFORMS_SCOPES , ...MAESTRO_SCOPES ] ;
345
345
346
346
// Configure passport for DocusignStrategy
347
- let docusignStrategy = new DocusignStrategy ( {
348
- production : dsConfig . production ,
349
- clientID : dsConfig . dsClientId ,
350
- scope : scope . join ( ' ' ) ,
351
- clientSecret : dsConfig . dsClientSecret ,
352
- callbackURL : hostUrl + '/ds/callback' ,
353
- state : true // automatic CSRF protection.
354
- // See https://github.com/jaredhanson/passport-oauth2/blob/master/lib/state/session.js
347
+ const docusignStrategyOptions = {
348
+ production : dsConfig . production ,
349
+ clientID : dsConfig . dsClientId ,
350
+ scope : scope . join ( ' ' ) ,
351
+ clientSecret : dsConfig . dsClientSecret ,
352
+ callbackURL : hostUrl + '/ds/callback' ,
353
+ state : true // automatic CSRF protection.
354
+ // See https://github.com/jaredhanson/passport-oauth2/blob/master/lib/state/session.js
355
+ } ;
356
+ function processDsResult ( accessToken , refreshToken , params , profile , done ) {
357
+ // The params arg will be passed additional parameters of the grant.
358
+ // See https://github.com/jaredhanson/passport-oauth2/pull/84
359
+ //
360
+ // Here we're just assigning the tokens to the account object
361
+ // We store the data in DSAuthCodeGrant.getDefaultAccountInfo
362
+ let user = profile ;
363
+ user . accessToken = accessToken ;
364
+ user . refreshToken = refreshToken ;
365
+ user . expiresIn = params . expires_in ;
366
+ user . tokenExpirationTimestamp = moment ( ) . add ( user . expiresIn , 's' ) ; // The dateTime when the access token will expire
367
+ return done ( null , user ) ;
368
+ }
369
+ const docusignStrategy = new DocusignStrategy ( docusignStrategyOptions , processDsResult ) ;
370
+ const docusignStrategyPKCE = new DocusignStrategy ( {
371
+ ...docusignStrategyOptions ,
372
+ pkce : true
355
373
} ,
356
- function _processDsResult ( accessToken , refreshToken , params , profile , done ) {
357
- // The params arg will be passed additional parameters of the grant.
358
- // See https://github.com/jaredhanson/passport-oauth2/pull/84
359
- //
360
- // Here we're just assigning the tokens to the account object
361
- // We store the data in DSAuthCodeGrant.getDefaultAccountInfo
362
- let user = profile ;
363
- user . accessToken = accessToken ;
364
- user . refreshToken = refreshToken ;
365
- user . expiresIn = params . expires_in ;
366
- user . tokenExpirationTimestamp = moment ( ) . add ( user . expiresIn , 's' ) ; // The dateTime when the access token will expire
367
- return done ( null , user ) ;
368
- }
374
+ processDsResult
369
375
) ;
370
376
371
377
/**
@@ -378,4 +384,5 @@ if (!dsConfig.allowSilentAuthentication) {
378
384
return { prompt : 'login' } ;
379
385
} ;
380
386
}
381
- passport . use ( docusignStrategy ) ;
387
+ passport . use ( 'docusign' , docusignStrategy ) ;
388
+ passport . use ( 'docusign_pkce' , docusignStrategyPKCE ) ;
0 commit comments