@@ -46,6 +46,17 @@ type MakeRequestData =
4646 | OAuthInvalidateRequestData
4747 | OAuthRefreshRequestData ;
4848
49+ interface OAuth2Response extends Response {
50+ /**
51+ * @deprecated 'responseText' is deprecated. This is a legacy AJAX API.
52+ */
53+ responseText : string ;
54+ /**
55+ * @deprecated 'responseJSON' is deprecated. This is a legacy AJAX API.
56+ */
57+ responseJSON : string ;
58+ }
59+
4960/**
5061 Authenticator that conforms to OAuth 2
5162 ([RFC 6749](http://tools.ietf.org/html/rfc6749)), specifically the _"Resource
@@ -369,7 +380,7 @@ export default class OAuth2PasswordGrantAuthenticator extends BaseAuthenticator
369380 url : string ,
370381 data : MakeRequestData ,
371382 headers : Record < string , string > = { }
372- ) : Promise < OAuthResponseSuccess & { responseText : string } & { responseJSON : string } > {
383+ ) : Promise < OAuthResponseSuccess > {
373384 headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ;
374385
375386 const clientId = this . get ( 'clientId' ) ;
@@ -403,15 +414,13 @@ export default class OAuth2PasswordGrantAuthenticator extends BaseAuthenticator
403414 try {
404415 let json = JSON . parse ( text ) ;
405416 if ( ! response . ok ) {
406- // @TODO : migrate the old AJAX API.
407- ( response as any ) . responseJSON = json ;
417+ ( response as OAuth2Response ) . responseJSON = json ;
408418 reject ( response ) ;
409419 } else {
410420 resolve ( json ) ;
411421 }
412422 } catch ( SyntaxError ) {
413- // @TODO : migrate the old AJAX API.
414- ( response as any ) . responseText = text ;
423+ ( response as OAuth2Response ) . responseText = text ;
415424 reject ( response ) ;
416425 }
417426 } ) ;
0 commit comments