@@ -46,6 +46,17 @@ type MakeRequestData =
46
46
| OAuthInvalidateRequestData
47
47
| OAuthRefreshRequestData ;
48
48
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
+
49
60
/**
50
61
Authenticator that conforms to OAuth 2
51
62
([RFC 6749](http://tools.ietf.org/html/rfc6749)), specifically the _"Resource
@@ -369,7 +380,7 @@ export default class OAuth2PasswordGrantAuthenticator extends BaseAuthenticator
369
380
url : string ,
370
381
data : MakeRequestData ,
371
382
headers : Record < string , string > = { }
372
- ) : Promise < OAuthResponseSuccess & { responseText : string } & { responseJSON : string } > {
383
+ ) : Promise < OAuthResponseSuccess > {
373
384
headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ;
374
385
375
386
const clientId = this . get ( 'clientId' ) ;
@@ -403,15 +414,13 @@ export default class OAuth2PasswordGrantAuthenticator extends BaseAuthenticator
403
414
try {
404
415
let json = JSON . parse ( text ) ;
405
416
if ( ! response . ok ) {
406
- // @TODO : migrate the old AJAX API.
407
- ( response as any ) . responseJSON = json ;
417
+ ( response as OAuth2Response ) . responseJSON = json ;
408
418
reject ( response ) ;
409
419
} else {
410
420
resolve ( json ) ;
411
421
}
412
422
} catch ( SyntaxError ) {
413
- // @TODO : migrate the old AJAX API.
414
- ( response as any ) . responseText = text ;
423
+ ( response as OAuth2Response ) . responseText = text ;
415
424
reject ( response ) ;
416
425
}
417
426
} ) ;
0 commit comments