@@ -201,6 +201,61 @@ describe('Backchannel', () => {
201201 interval : 5 ,
202202 } ) ;
203203 } ) ;
204+
205+ it ( 'should pass requested_expiry to /bc-authorize' , async ( ) => {
206+ let receivedRequestedExpiry = 0 ;
207+ nock ( `https://${ opts . domain } ` )
208+ . post ( '/bc-authorize' )
209+ . reply ( 201 , ( uri , requestBody , cb ) => {
210+ receivedRequestedExpiry = JSON . parse (
211+ querystring . parse ( requestBody as any ) [ 'requested_expiry' ] as string
212+ ) ;
213+ cb ( null , {
214+ auth_req_id : 'test-auth-req-id' ,
215+ expires_in : 300 ,
216+ interval : 5 ,
217+ } ) ;
218+ } ) ;
219+
220+ await backchannel . authorize ( {
221+ userId : 'auth0|test-user-id' ,
222+ binding_message : 'Test binding message' ,
223+ scope : 'openid' ,
224+ requested_expiry : '999' ,
225+ } ) ;
226+
227+ expect ( receivedRequestedExpiry ) . toBe ( 999 ) ;
228+ } ) ;
229+
230+ it ( 'should pass request_expiry as requested_expiry and retain the request_expiry param for backwards compatibility' , async ( ) => {
231+ let receivedRequestedExpiry = 0 ;
232+ let receivedRequestExpiry = 0 ;
233+ nock ( `https://${ opts . domain } ` )
234+ . post ( '/bc-authorize' )
235+ . reply ( 201 , ( uri , requestBody , cb ) => {
236+ receivedRequestedExpiry = JSON . parse (
237+ querystring . parse ( requestBody as any ) [ 'requested_expiry' ] as string
238+ ) ;
239+ receivedRequestExpiry = JSON . parse (
240+ querystring . parse ( requestBody as any ) [ 'request_expiry' ] as string
241+ ) ;
242+ cb ( null , {
243+ auth_req_id : 'test-auth-req-id' ,
244+ expires_in : 300 ,
245+ interval : 5 ,
246+ } ) ;
247+ } ) ;
248+
249+ await backchannel . authorize ( {
250+ userId : 'auth0|test-user-id' ,
251+ binding_message : 'Test binding message' ,
252+ scope : 'openid' ,
253+ request_expiry : '999' ,
254+ } ) ;
255+
256+ expect ( receivedRequestedExpiry ) . toBe ( 999 ) ;
257+ expect ( receivedRequestExpiry ) . toBe ( 999 ) ;
258+ } ) ;
204259 } ) ;
205260
206261 describe ( '#backchannelGrant' , ( ) => {
0 commit comments