@@ -91,6 +91,61 @@ describe('Backchannel', () => {
9191 } ) ;
9292 } ) ;
9393
94+ it ( 'should pass requested_expiry to /bc-authorize' , async ( ) => {
95+ let receivedRequestedExpiry = 0 ;
96+ nock ( `https://${ opts . domain } ` )
97+ . post ( '/bc-authorize' )
98+ . reply ( 201 , ( uri , requestBody , cb ) => {
99+ receivedRequestedExpiry = JSON . parse (
100+ querystring . parse ( requestBody as any ) [ 'requested_expiry' ] as string
101+ ) ;
102+ cb ( null , {
103+ auth_req_id : 'test-auth-req-id' ,
104+ expires_in : 300 ,
105+ interval : 5 ,
106+ } ) ;
107+ } ) ;
108+
109+ await backchannel . authorize ( {
110+ userId : 'auth0|test-user-id' ,
111+ binding_message : 'Test binding message' ,
112+ scope : 'openid' ,
113+ requested_expiry : '999' ,
114+ } ) ;
115+
116+ expect ( receivedRequestedExpiry ) . toBe ( 999 ) ;
117+ } ) ;
118+
119+ it ( 'should pass request_expiry as requested_expiry and retain the request_expiry param for backwards compatibility' , async ( ) => {
120+ let receivedRequestedExpiry = 0 ;
121+ let receivedRequestExpiry = 0 ;
122+ nock ( `https://${ opts . domain } ` )
123+ . post ( '/bc-authorize' )
124+ . reply ( 201 , ( uri , requestBody , cb ) => {
125+ receivedRequestedExpiry = JSON . parse (
126+ querystring . parse ( requestBody as any ) [ 'requested_expiry' ] as string
127+ ) ;
128+ receivedRequestExpiry = JSON . parse (
129+ querystring . parse ( requestBody as any ) [ 'request_expiry' ] as string
130+ ) ;
131+ cb ( null , {
132+ auth_req_id : 'test-auth-req-id' ,
133+ expires_in : 300 ,
134+ interval : 5 ,
135+ } ) ;
136+ } ) ;
137+
138+ await backchannel . authorize ( {
139+ userId : 'auth0|test-user-id' ,
140+ binding_message : 'Test binding message' ,
141+ scope : 'openid' ,
142+ request_expiry : '999' ,
143+ } ) ;
144+
145+ expect ( receivedRequestedExpiry ) . toBe ( 999 ) ;
146+ expect ( receivedRequestExpiry ) . toBe ( 999 ) ;
147+ } ) ;
148+
94149 it ( 'should pass authorization_details to /bc-authorize' , async ( ) => {
95150 let receivedAuthorizationDetails : { type : string } [ ] = [ ] ;
96151 nock ( `https://${ opts . domain } ` )
0 commit comments