You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JSONP is deprecated because it is prone to Cross-Site Scripting (XSS) attacks. Since JSONP works by executing arbitrary scripts in the global context, it bypasses modern Content Security Policies (CSP) and can lead to severe security vulnerabilities if the server or endpoint is compromised.
DEPRECATED: `HttpClient.jsonp`, `HttpClientJsonpModule`, and related JSONP classes/functions are deprecated. Use standard HTTP requests instead.
* @param callbackParam The callback function name.
1479
1471
*
1480
1472
* @return An `Observable` of the response object, with response body as an object.
1473
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
* then the `JSONP` request can be rejected by the configured backend.
1493
1486
*
1494
1487
* @return An `Observable` of the response object, with response body in the requested type.
1488
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
* @param callbackParam The callback function name.
1514
-
*
1508
+
*@deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
26
+
*/
24
27
JSONP_WRONG_METHOD=2810,
28
+
/**
29
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
30
+
*/
25
31
JSONP_WRONG_RESPONSE_TYPE=2811,
32
+
/**
33
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
Copy file name to clipboardExpand all lines: packages/common/http/src/jsonp.ts
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ export const JSONP_ERR_HEADERS_NOT_SUPPORTED = 'JSONP requests do not support he
60
60
*
61
61
* In the browser, this should always be the `window` object.
62
62
*
63
-
*
63
+
*@deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
64
64
*/
65
65
exportabstractclassJsonpCallbackContext{
66
66
[key: string]: (data: any)=>void;
@@ -72,7 +72,7 @@ export abstract class JsonpCallbackContext {
72
72
* Ordinarily JSONP callbacks are stored on the `window` object, but this may not exist
73
73
* in test environments. In that case, callbacks are stored on an anonymous object instead.
74
74
*
75
-
*
75
+
*@deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
76
76
*/
77
77
exportfunctionjsonpCallbackContext(): Object{
78
78
if(typeofwindow==='object'){
@@ -88,6 +88,7 @@ export function jsonpCallbackContext(): Object {
88
88
* @see {@link HttpXhrBackend}
89
89
*
90
90
* @publicApi
91
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
@@ -100,7 +101,14 @@ export class JsonpClientBackend implements HttpBackend {
100
101
constructor(
101
102
privatecallbackMap: JsonpCallbackContext,
102
103
@Inject(DOCUMENT)privatedocument: any,
103
-
){}
104
+
){
105
+
if(typeofngDevMode==='undefined'||ngDevMode){
106
+
console.warn(
107
+
'JSONP support is deprecated as it can cause XSS vulnerabilities, and will be removed '+
108
+
'in a future version of Angular. Please use standard HTTP requests instead.',
109
+
);
110
+
}
111
+
}
104
112
105
113
/**
106
114
* Get the name of the next callback method, by incrementing the global `nextRequestId`.
@@ -286,6 +294,8 @@ export class JsonpClientBackend implements HttpBackend {
286
294
287
295
/**
288
296
* Identifies requests with the method JSONP and shifts them to the `JsonpClientBackend`.
297
+
*
298
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
289
299
*/
290
300
exportfunctionjsonpInterceptorFn(
291
301
req: HttpRequest<unknown>,
@@ -306,6 +316,7 @@ export function jsonpInterceptorFn(
306
316
* @see {@link HttpInterceptor}
307
317
*
308
318
* @publicApi
319
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
Copy file name to clipboardExpand all lines: packages/common/http/src/provider.ts
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -240,6 +240,7 @@ export function withNoXsrfProtection(): HttpFeature<HttpFeatureKind.NoXsrfProtec
240
240
* Add JSONP support to the configuration of the current `HttpClient` instance.
241
241
*
242
242
* @see {@link provideHttpClient}
243
+
* @deprecated 22.1 JSONP is deprecated as it can cause XSS vulnerabilities. Use standard HTTP requests instead. Intent to remove in future versions of Angular.
0 commit comments