1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Injectable, Injector, NgModule } from '@angular/core';
|
---|
9 | import { HttpBackend, HttpHandler } from './backend';
|
---|
10 | import { HttpClient } from './client';
|
---|
11 | import { HTTP_INTERCEPTORS, HttpInterceptorHandler, NoopInterceptor } from './interceptor';
|
---|
12 | import { JsonpCallbackContext, JsonpClientBackend, JsonpInterceptor } from './jsonp';
|
---|
13 | import { HttpXhrBackend } from './xhr';
|
---|
14 | import { HttpXsrfCookieExtractor, HttpXsrfInterceptor, HttpXsrfTokenExtractor, XSRF_COOKIE_NAME, XSRF_HEADER_NAME } from './xsrf';
|
---|
15 | /**
|
---|
16 | * An injectable `HttpHandler` that applies multiple interceptors
|
---|
17 | * to a request before passing it to the given `HttpBackend`.
|
---|
18 | *
|
---|
19 | * The interceptors are loaded lazily from the injector, to allow
|
---|
20 | * interceptors to themselves inject classes depending indirectly
|
---|
21 | * on `HttpInterceptingHandler` itself.
|
---|
22 | * @see `HttpInterceptor`
|
---|
23 | */
|
---|
24 | export class HttpInterceptingHandler {
|
---|
25 | constructor(backend, injector) {
|
---|
26 | this.backend = backend;
|
---|
27 | this.injector = injector;
|
---|
28 | this.chain = null;
|
---|
29 | }
|
---|
30 | handle(req) {
|
---|
31 | if (this.chain === null) {
|
---|
32 | const interceptors = this.injector.get(HTTP_INTERCEPTORS, []);
|
---|
33 | this.chain = interceptors.reduceRight((next, interceptor) => new HttpInterceptorHandler(next, interceptor), this.backend);
|
---|
34 | }
|
---|
35 | return this.chain.handle(req);
|
---|
36 | }
|
---|
37 | }
|
---|
38 | HttpInterceptingHandler.decorators = [
|
---|
39 | { type: Injectable }
|
---|
40 | ];
|
---|
41 | HttpInterceptingHandler.ctorParameters = () => [
|
---|
42 | { type: HttpBackend },
|
---|
43 | { type: Injector }
|
---|
44 | ];
|
---|
45 | /**
|
---|
46 | * Constructs an `HttpHandler` that applies interceptors
|
---|
47 | * to a request before passing it to the given `HttpBackend`.
|
---|
48 | *
|
---|
49 | * Use as a factory function within `HttpClientModule`.
|
---|
50 | *
|
---|
51 | *
|
---|
52 | */
|
---|
53 | export function interceptingHandler(backend, interceptors = []) {
|
---|
54 | if (!interceptors) {
|
---|
55 | return backend;
|
---|
56 | }
|
---|
57 | return interceptors.reduceRight((next, interceptor) => new HttpInterceptorHandler(next, interceptor), backend);
|
---|
58 | }
|
---|
59 | /**
|
---|
60 | * Factory function that determines where to store JSONP callbacks.
|
---|
61 | *
|
---|
62 | * Ordinarily JSONP callbacks are stored on the `window` object, but this may not exist
|
---|
63 | * in test environments. In that case, callbacks are stored on an anonymous object instead.
|
---|
64 | *
|
---|
65 | *
|
---|
66 | */
|
---|
67 | export function jsonpCallbackContext() {
|
---|
68 | if (typeof window === 'object') {
|
---|
69 | return window;
|
---|
70 | }
|
---|
71 | return {};
|
---|
72 | }
|
---|
73 | /**
|
---|
74 | * Configures XSRF protection support for outgoing requests.
|
---|
75 | *
|
---|
76 | * For a server that supports a cookie-based XSRF protection system,
|
---|
77 | * use directly to configure XSRF protection with the correct
|
---|
78 | * cookie and header names.
|
---|
79 | *
|
---|
80 | * If no names are supplied, the default cookie name is `XSRF-TOKEN`
|
---|
81 | * and the default header name is `X-XSRF-TOKEN`.
|
---|
82 | *
|
---|
83 | * @publicApi
|
---|
84 | */
|
---|
85 | export class HttpClientXsrfModule {
|
---|
86 | /**
|
---|
87 | * Disable the default XSRF protection.
|
---|
88 | */
|
---|
89 | static disable() {
|
---|
90 | return {
|
---|
91 | ngModule: HttpClientXsrfModule,
|
---|
92 | providers: [
|
---|
93 | { provide: HttpXsrfInterceptor, useClass: NoopInterceptor },
|
---|
94 | ],
|
---|
95 | };
|
---|
96 | }
|
---|
97 | /**
|
---|
98 | * Configure XSRF protection.
|
---|
99 | * @param options An object that can specify either or both
|
---|
100 | * cookie name or header name.
|
---|
101 | * - Cookie name default is `XSRF-TOKEN`.
|
---|
102 | * - Header name default is `X-XSRF-TOKEN`.
|
---|
103 | *
|
---|
104 | */
|
---|
105 | static withOptions(options = {}) {
|
---|
106 | return {
|
---|
107 | ngModule: HttpClientXsrfModule,
|
---|
108 | providers: [
|
---|
109 | options.cookieName ? { provide: XSRF_COOKIE_NAME, useValue: options.cookieName } : [],
|
---|
110 | options.headerName ? { provide: XSRF_HEADER_NAME, useValue: options.headerName } : [],
|
---|
111 | ],
|
---|
112 | };
|
---|
113 | }
|
---|
114 | }
|
---|
115 | HttpClientXsrfModule.decorators = [
|
---|
116 | { type: NgModule, args: [{
|
---|
117 | providers: [
|
---|
118 | HttpXsrfInterceptor,
|
---|
119 | { provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true },
|
---|
120 | { provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor },
|
---|
121 | { provide: XSRF_COOKIE_NAME, useValue: 'XSRF-TOKEN' },
|
---|
122 | { provide: XSRF_HEADER_NAME, useValue: 'X-XSRF-TOKEN' },
|
---|
123 | ],
|
---|
124 | },] }
|
---|
125 | ];
|
---|
126 | /**
|
---|
127 | * Configures the [dependency injector](guide/glossary#injector) for `HttpClient`
|
---|
128 | * with supporting services for XSRF. Automatically imported by `HttpClientModule`.
|
---|
129 | *
|
---|
130 | * You can add interceptors to the chain behind `HttpClient` by binding them to the
|
---|
131 | * multiprovider for built-in [DI token](guide/glossary#di-token) `HTTP_INTERCEPTORS`.
|
---|
132 | *
|
---|
133 | * @publicApi
|
---|
134 | */
|
---|
135 | export class HttpClientModule {
|
---|
136 | }
|
---|
137 | HttpClientModule.decorators = [
|
---|
138 | { type: NgModule, args: [{
|
---|
139 | /**
|
---|
140 | * Optional configuration for XSRF protection.
|
---|
141 | */
|
---|
142 | imports: [
|
---|
143 | HttpClientXsrfModule.withOptions({
|
---|
144 | cookieName: 'XSRF-TOKEN',
|
---|
145 | headerName: 'X-XSRF-TOKEN',
|
---|
146 | }),
|
---|
147 | ],
|
---|
148 | /**
|
---|
149 | * Configures the [dependency injector](guide/glossary#injector) where it is imported
|
---|
150 | * with supporting services for HTTP communications.
|
---|
151 | */
|
---|
152 | providers: [
|
---|
153 | HttpClient,
|
---|
154 | { provide: HttpHandler, useClass: HttpInterceptingHandler },
|
---|
155 | HttpXhrBackend,
|
---|
156 | { provide: HttpBackend, useExisting: HttpXhrBackend },
|
---|
157 | ],
|
---|
158 | },] }
|
---|
159 | ];
|
---|
160 | /**
|
---|
161 | * Configures the [dependency injector](guide/glossary#injector) for `HttpClient`
|
---|
162 | * with supporting services for JSONP.
|
---|
163 | * Without this module, Jsonp requests reach the backend
|
---|
164 | * with method JSONP, where they are rejected.
|
---|
165 | *
|
---|
166 | * You can add interceptors to the chain behind `HttpClient` by binding them to the
|
---|
167 | * multiprovider for built-in [DI token](guide/glossary#di-token) `HTTP_INTERCEPTORS`.
|
---|
168 | *
|
---|
169 | * @publicApi
|
---|
170 | */
|
---|
171 | export class HttpClientJsonpModule {
|
---|
172 | }
|
---|
173 | HttpClientJsonpModule.decorators = [
|
---|
174 | { type: NgModule, args: [{
|
---|
175 | providers: [
|
---|
176 | JsonpClientBackend,
|
---|
177 | { provide: JsonpCallbackContext, useFactory: jsonpCallbackContext },
|
---|
178 | { provide: HTTP_INTERCEPTORS, useClass: JsonpInterceptor, multi: true },
|
---|
179 | ],
|
---|
180 | },] }
|
---|
181 | ];
|
---|
182 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tbW9uL2h0dHAvc3JjL21vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsVUFBVSxFQUFFL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