@@ -616,23 +616,23 @@ describe('AuthorizationCodeGrantType integration', () => {
616
616
617
617
describe ( 'with PKCE' , function ( ) {
618
618
it ( 'should throw an error if the `code_verifier` is invalid with S256 code challenge method' , ( ) => {
619
- var codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
620
- var authorizationCode = {
619
+ const codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
620
+ const authorizationCode = {
621
621
authorizationCode : 12345 ,
622
622
client : { id : 'foobar' } ,
623
623
expiresAt : new Date ( new Date ( ) . getTime ( ) * 2 ) ,
624
624
user : { } ,
625
625
codeChallengeMethod : 'S256' ,
626
- codeChallenge : stringUtil . base64URLEncode ( crypto . createHash ( 'sha256' ) . update ( codeVerifier ) . digest ( ) )
626
+ codeChallenge : stringUtil . base64URLEncode ( crypto . createHash ( 'sha256' ) . update ( codeVerifier ) . digest ( ) ) ,
627
627
} ;
628
- var client : any = { id : 'foobar' , isPublic : true } ;
629
- var model = {
630
- getAuthorizationCode : function ( ) { return authorizationCode ; } ,
631
- revokeAuthorizationCode : function ( ) { } ,
632
- saveToken : function ( ) { }
628
+ const client : any = { id : 'foobar' , isPublic : true } ;
629
+ const model = {
630
+ getAuthorizationCode ( ) { return authorizationCode ; } ,
631
+ revokeAuthorizationCode ( ) { } ,
632
+ saveToken ( ) { } ,
633
633
} ;
634
- var grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model : model } ) ;
635
- var request = new Request ( { body : { code : 12345 , code_verifier : 'foo' } , headers : { } , method : 'POST' , query : { } } ) ;
634
+ const grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model } ) ;
635
+ const request = new Request ( { body : { code : 12345 , code_verifier : 'foo' } , headers : { } , method : 'POST' , query : { } } ) ;
636
636
637
637
return grantType . getAuthorizationCode ( request , client )
638
638
. then ( ( ) => {
@@ -645,23 +645,23 @@ describe('AuthorizationCodeGrantType integration', () => {
645
645
} ) ;
646
646
647
647
it ( 'should throw an error if the `code_verifier` is invalid with plain code challenge method' , ( ) => {
648
- var codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
649
- var authorizationCode = {
648
+ const codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
649
+ const authorizationCode = {
650
650
authorizationCode : 12345 ,
651
651
client : { id : 'foobar' } ,
652
652
expiresAt : new Date ( new Date ( ) . getTime ( ) * 2 ) ,
653
653
user : { } ,
654
654
codeChallengeMethod : 'plain' ,
655
- codeChallenge : codeVerifier
655
+ codeChallenge : codeVerifier ,
656
656
} ;
657
- var client : any = { id : 'foobar' , isPublic : true } ;
658
- var model = {
659
- getAuthorizationCode : function ( ) { return authorizationCode ; } ,
660
- revokeAuthorizationCode : function ( ) { } ,
661
- saveToken : function ( ) { }
657
+ const client : any = { id : 'foobar' , isPublic : true } ;
658
+ const model = {
659
+ getAuthorizationCode ( ) { return authorizationCode ; } ,
660
+ revokeAuthorizationCode ( ) { } ,
661
+ saveToken ( ) { } ,
662
662
} ;
663
- var grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model : model } ) ;
664
- var request = new Request ( { body : { code : 12345 , code_verifier : 'foo' } , headers : { } , method : 'POST' , query : { } } ) ;
663
+ const grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model } ) ;
664
+ const request = new Request ( { body : { code : 12345 , code_verifier : 'foo' } , headers : { } , method : 'POST' , query : { } } ) ;
665
665
666
666
return grantType . getAuthorizationCode ( request , client )
667
667
. then ( ( ) => {
@@ -674,23 +674,23 @@ describe('AuthorizationCodeGrantType integration', () => {
674
674
} ) ;
675
675
676
676
it ( 'should return an auth code when `code_verifier` is valid with S256 code challenge method' , ( ) => {
677
- var codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
678
- var authorizationCode = {
677
+ const codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
678
+ const authorizationCode = {
679
679
authorizationCode : 12345 ,
680
680
client : { id : 'foobar' , isPublic : true } ,
681
681
expiresAt : new Date ( new Date ( ) . getTime ( ) * 2 ) ,
682
682
user : { } ,
683
683
codeChallengeMethod : 'S256' ,
684
- codeChallenge : stringUtil . base64URLEncode ( crypto . createHash ( 'sha256' ) . update ( codeVerifier ) . digest ( ) )
684
+ codeChallenge : stringUtil . base64URLEncode ( crypto . createHash ( 'sha256' ) . update ( codeVerifier ) . digest ( ) ) ,
685
685
} ;
686
- var client : any = { id : 'foobar' , isPublic : true } ;
687
- var model = {
688
- getAuthorizationCode : function ( ) { return authorizationCode ; } ,
689
- revokeAuthorizationCode : function ( ) { } ,
690
- saveToken : function ( ) { }
686
+ const client : any = { id : 'foobar' , isPublic : true } ;
687
+ const model = {
688
+ getAuthorizationCode ( ) { return authorizationCode ; } ,
689
+ revokeAuthorizationCode ( ) { } ,
690
+ saveToken ( ) { } ,
691
691
} ;
692
- var grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model : model } ) ;
693
- var request = new Request ( { body : { code : 12345 , code_verifier : codeVerifier } , headers : { } , method : 'POST' , query : { } } ) ;
692
+ const grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model } ) ;
693
+ const request = new Request ( { body : { code : 12345 , code_verifier : codeVerifier } , headers : { } , method : 'POST' , query : { } } ) ;
694
694
695
695
return grantType . getAuthorizationCode ( request , client )
696
696
. then ( function ( data ) {
@@ -702,23 +702,23 @@ describe('AuthorizationCodeGrantType integration', () => {
702
702
} ) ;
703
703
704
704
it ( 'should return an auth code when `code_verifier` is valid with plain code challenge method' , ( ) => {
705
- var codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
706
- var authorizationCode = {
705
+ const codeVerifier = stringUtil . base64URLEncode ( crypto . randomBytes ( 32 ) ) ;
706
+ const authorizationCode = {
707
707
authorizationCode : 12345 ,
708
708
client : { id : 'foobar' } ,
709
709
expiresAt : new Date ( new Date ( ) . getTime ( ) * 2 ) ,
710
710
user : { } ,
711
711
codeChallengeMethod : 'plain' ,
712
- codeChallenge : codeVerifier
712
+ codeChallenge : codeVerifier ,
713
713
} ;
714
- var client : any = { id : 'foobar' , isPublic : true } ;
715
- var model = {
716
- getAuthorizationCode : function ( ) { return authorizationCode ; } ,
717
- revokeAuthorizationCode : function ( ) { } ,
718
- saveToken : function ( ) { }
714
+ const client : any = { id : 'foobar' , isPublic : true } ;
715
+ const model = {
716
+ getAuthorizationCode ( ) { return authorizationCode ; } ,
717
+ revokeAuthorizationCode ( ) { } ,
718
+ saveToken ( ) { } ,
719
719
} ;
720
- var grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model : model } ) ;
721
- var request = new Request ( { body : { code : 12345 , code_verifier : codeVerifier } , headers : { } , method : 'POST' , query : { } } ) ;
720
+ const grantType = new AuthorizationCodeGrantType ( { accessTokenLifetime : 123 , model } ) ;
721
+ const request = new Request ( { body : { code : 12345 , code_verifier : codeVerifier } , headers : { } , method : 'POST' , query : { } } ) ;
722
722
723
723
return grantType . getAuthorizationCode ( request , client )
724
724
. then ( function ( data ) {
0 commit comments