@angular-wave/angular.ts 0.0.65 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-js.js +6 -0
  5. package/src/animations/animate-swap.js +3 -0
  6. package/src/animations/animation.js +1 -1
  7. package/src/core/compile/compile.js +16 -4
  8. package/src/core/controller/controller.js +5 -5
  9. package/src/core/di/injector.js +133 -259
  10. package/src/core/di/injector.md +3 -3
  11. package/src/core/di/injector.spec.js +30 -24
  12. package/src/core/di/internal-injector.js +286 -0
  13. package/src/core/filter/filter.js +5 -0
  14. package/src/core/parser/parse.js +1 -12
  15. package/src/core/parser/parse.spec.js +96 -110
  16. package/src/core/sce/sce.js +6 -1
  17. package/src/core/timeout/timeout.js +110 -111
  18. package/src/directive/input/input.js +32 -726
  19. package/src/directive/input/input.md +706 -0
  20. package/src/directive/select/select.js +48 -122
  21. package/src/directive/select/select.md +74 -0
  22. package/src/directive/show-hide/show-hide.js +13 -224
  23. package/src/directive/show-hide/show-hide.md +257 -0
  24. package/src/filters/limit-to.spec.js +1 -1
  25. package/src/filters/order-by.spec.js +1 -1
  26. package/src/index.js +6 -2
  27. package/src/loader.js +8 -4
  28. package/src/public.js +1 -7
  29. package/src/router/services.js +9 -4
  30. package/src/router/state/state-builder.js +6 -7
  31. package/src/router/state/state-registry.js +5 -0
  32. package/src/router/state/state-service.js +1 -1
  33. package/src/router/state/views.js +2 -1
  34. package/src/router/state-provider.js +1 -1
  35. package/src/router/template-factory.js +15 -14
  36. package/src/router/url/url-service.js +4 -4
  37. package/src/services/anchor-scroll.js +2 -2
  38. package/src/services/browser.js +2 -9
  39. package/src/services/cache-factory.js +0 -67
  40. package/src/services/cache-factory.md +75 -0
  41. package/src/services/cookie-reader.js +36 -55
  42. package/src/services/http/http.js +73 -586
  43. package/src/services/http/http.md +413 -0
  44. package/src/services/http-backend/http-backend.js +19 -44
  45. package/src/services/template-request.js +1 -9
  46. package/src/shared/jqlite/jqlite.js +4 -69
  47. package/src/types.js +8 -12
  48. package/types/animations/animate-js.d.ts +1 -1
  49. package/types/animations/animate-swap.d.ts +4 -7
  50. package/types/animations/animation.d.ts +1 -1
  51. package/types/core/compile/compile.d.ts +7 -7
  52. package/types/core/controller/controller.d.ts +1 -6
  53. package/types/core/di/injector.d.ts +13 -7
  54. package/types/core/di/internal-injector.d.ts +91 -0
  55. package/types/core/exception-handler.d.ts +1 -1
  56. package/types/core/filter/filter.d.ts +1 -1
  57. package/types/core/parser/parse.d.ts +1 -1
  58. package/types/core/sce/sce.d.ts +1 -1
  59. package/types/core/timeout/timeout.d.ts +16 -26
  60. package/types/directive/input/input.d.ts +19 -124
  61. package/types/directive/select/select.d.ts +7 -74
  62. package/types/directive/show-hide/show-hide.d.ts +11 -224
  63. package/types/loader.d.ts +4 -4
  64. package/types/router/services.d.ts +8 -1
  65. package/types/router/state/state-builder.d.ts +1 -2
  66. package/types/router/state/state-registry.d.ts +2 -2
  67. package/types/router/state/state-service.d.ts +2 -2
  68. package/types/router/state-provider.d.ts +2 -2
  69. package/types/router/template-factory.d.ts +16 -16
  70. package/types/router/url/url-service.d.ts +4 -4
  71. package/types/services/anchor-scroll.d.ts +1 -1
  72. package/types/services/browser.d.ts +0 -10
  73. package/types/services/cache-factory.d.ts +0 -67
  74. package/types/services/cookie-reader.d.ts +2 -10
  75. package/types/services/http/http.d.ts +53 -61
  76. package/types/services/http-backend/http-backend.d.ts +8 -31
  77. package/types/services/template-request.d.ts +1 -9
  78. package/types/shared/jqlite/jqlite.d.ts +9 -9
  79. package/types/types.d.ts +5 -38
@@ -23,6 +23,7 @@ import {
23
23
  uppercase,
24
24
  isPromiseLike,
25
25
  } from "../../shared/utils";
26
+ import { getCookies } from "../cookie-reader";
26
27
 
27
28
  const APPLICATION_JSON = "application/json";
28
29
  const CONTENT_TYPE_APPLICATION_JSON = {
@@ -43,23 +44,18 @@ function serializeValue(v) {
43
44
  return v;
44
45
  }
45
46
 
47
+ /**
48
+ * Default params serializer that converts objects to strings
49
+ * according to the following rules:
50
+ *
51
+ * * `{'foo': 'bar'}` results in `foo=bar`
52
+ * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
53
+ * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
54
+ * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D` (stringified and encoded representation of an object)
55
+ *
56
+ * Note that serializer will sort the request parameters alphabetically.
57
+ */
46
58
  export function $HttpParamSerializerProvider() {
47
- /**
48
- * @ngdoc service
49
- * @name $httpParamSerializer
50
- * @description
51
- *
52
- * Default {@link $http `$http`} params serializer that converts objects to strings
53
- * according to the following rules:
54
- *
55
- * * `{'foo': 'bar'}` results in `foo=bar`
56
- * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
57
- * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
58
- * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D` (stringified and encoded representation of an object)
59
- *
60
- * Note that serializer will sort the request parameters alphabetically.
61
- */
62
-
63
59
  this.$get = function () {
64
60
  return function ngParamSerializer(params) {
65
61
  if (!params) return "";
@@ -67,7 +63,7 @@ export function $HttpParamSerializerProvider() {
67
63
  forEachSorted(params, (value, key) => {
68
64
  if (value === null || isUndefined(value) || isFunction(value)) return;
69
65
  if (Array.isArray(value)) {
70
- forEach(value, (v) => {
66
+ value.forEach((v) => {
71
67
  parts.push(
72
68
  `${encodeUriQuery(key)}=${encodeUriQuery(serializeValue(v))}`,
73
69
  );
@@ -84,51 +80,47 @@ export function $HttpParamSerializerProvider() {
84
80
  };
85
81
  }
86
82
 
83
+ /**
84
+ *
85
+ * Alternative {@link $http `$http`} params serializer that follows
86
+ * jQuery's [`param()`](http://api.jquery.com/jquery.param/) method logic.
87
+ * The serializer will also sort the params alphabetically.
88
+ *
89
+ * To use it for serializing `$http` request parameters, set it as the `paramSerializer` property:
90
+ *
91
+ * ```js
92
+ * $http({
93
+ * url: myUrl,
94
+ * method: 'GET',
95
+ * params: myParams,
96
+ * paramSerializer: '$httpParamSerializerJQLike'
97
+ * });
98
+ * ```
99
+ *
100
+ * It is also possible to set it as the default `paramSerializer` in the
101
+ * {@link $httpProvider#defaults `$httpProvider`}.
102
+ *
103
+ * Additionally, you can inject the serializer and use it explicitly, for example to serialize
104
+ * form data for submission:
105
+ *
106
+ * ```js
107
+ * .controller(function($http, $httpParamSerializerJQLike) {
108
+ * //...
109
+ *
110
+ * $http({
111
+ * url: myUrl,
112
+ * method: 'POST',
113
+ * data: $httpParamSerializerJQLike(myData),
114
+ * headers: {
115
+ * 'Content-Type': 'application/x-www-form-urlencoded'
116
+ * }
117
+ * });
118
+ *
119
+ * });
120
+ * ```
121
+ *
122
+ */
87
123
  export function $HttpParamSerializerJQLikeProvider() {
88
- /**
89
- * @ngdoc service
90
- * @name $httpParamSerializerJQLike
91
- *
92
- * @description
93
- *
94
- * Alternative {@link $http `$http`} params serializer that follows
95
- * jQuery's [`param()`](http://api.jquery.com/jquery.param/) method logic.
96
- * The serializer will also sort the params alphabetically.
97
- *
98
- * To use it for serializing `$http` request parameters, set it as the `paramSerializer` property:
99
- *
100
- * ```js
101
- * $http({
102
- * url: myUrl,
103
- * method: 'GET',
104
- * params: myParams,
105
- * paramSerializer: '$httpParamSerializerJQLike'
106
- * });
107
- * ```
108
- *
109
- * It is also possible to set it as the default `paramSerializer` in the
110
- * {@link $httpProvider#defaults `$httpProvider`}.
111
- *
112
- * Additionally, you can inject the serializer and use it explicitly, for example to serialize
113
- * form data for submission:
114
- *
115
- * ```js
116
- * .controller(function($http, $httpParamSerializerJQLike) {
117
- * //...
118
- *
119
- * $http({
120
- * url: myUrl,
121
- * method: 'POST',
122
- * data: $httpParamSerializerJQLike(myData),
123
- * headers: {
124
- * 'Content-Type': 'application/x-www-form-urlencoded'
125
- * }
126
- * });
127
- *
128
- * });
129
- * ```
130
- *
131
- */
132
124
  this.$get = function () {
133
125
  return function jQueryLikeParamSerializer(params) {
134
126
  if (!params) return "";
@@ -219,8 +211,7 @@ function parseHeaders(headers) {
219
211
  }
220
212
 
221
213
  if (isString(headers)) {
222
- forEach(
223
- headers.split("\n"),
214
+ headers.split("\n").forEach(
224
215
  /** @param {string} line */
225
216
  (line) => {
226
217
  i = line.indexOf(":");
@@ -308,10 +299,6 @@ function isSuccess(status) {
308
299
  */
309
300
  export function $HttpProvider() {
310
301
  /**
311
- * @ngdoc property
312
- * @name $httpProvider#defaults
313
- * @description
314
- *
315
302
  * Object containing default values for all {@link ng.$http $http} requests.
316
303
  *
317
304
  * - **`defaults.cache`** - {boolean|Object} - A boolean value or object created with
@@ -414,10 +401,6 @@ export function $HttpProvider() {
414
401
  };
415
402
 
416
403
  /**
417
- * @ngdoc property
418
- * @name $httpProvider#interceptors
419
- * @description
420
- *
421
404
  * Array containing service factories for all synchronous or asynchronous {@link ng.$http $http}
422
405
  * pre-processing of request or postprocessing of responses.
423
406
  *
@@ -429,10 +412,6 @@ export function $HttpProvider() {
429
412
  const interceptorFactories = (this.interceptors = []);
430
413
 
431
414
  /**
432
- * @ngdoc property
433
- * @name $httpProvider#xsrfTrustedOrigins
434
- * @description
435
- *
436
415
  * Array containing URLs whose origins are trusted to receive the XSRF token. See the
437
416
  * {@link ng.$http#security-considerations Security Considerations} sections for more details on
438
417
  * XSRF.
@@ -471,13 +450,6 @@ export function $HttpProvider() {
471
450
  const xsrfTrustedOrigins = (this.xsrfTrustedOrigins = []);
472
451
 
473
452
  /**
474
- * @ngdoc property
475
- * @name $httpProvider#xsrfWhitelistedOrigins
476
- * @description
477
- *
478
- * @deprecated
479
- * sinceVersion="1.8.1"
480
- *
481
453
  * This property is deprecated. Use {@link $httpProvider#xsrfTrustedOrigins xsrfTrustedOrigins}
482
454
  * instead.
483
455
  */
@@ -493,16 +465,25 @@ export function $HttpProvider() {
493
465
  this.$get = [
494
466
  "$browser",
495
467
  "$httpBackend",
496
- "$$cookieReader",
497
468
  "$cacheFactory",
498
469
  "$rootScope",
499
470
  "$q",
500
471
  "$injector",
501
472
  "$sce",
473
+ /**
474
+ *
475
+ * @param {*} $browser
476
+ * @param {*} $httpBackend
477
+ * @param {*} $cacheFactory
478
+ * @param {*} $rootScope
479
+ * @param {*} $q
480
+ * @param {import("../../core/di/internal-injector").InjectorService} $injector
481
+ * @param {*} $sce
482
+ * @returns
483
+ */
502
484
  function (
503
485
  $browser,
504
486
  $httpBackend,
505
- $$cookieReader,
506
487
  $cacheFactory,
507
488
  $rootScope,
508
489
  $q,
@@ -525,7 +506,7 @@ export function $HttpProvider() {
525
506
  */
526
507
  const reversedInterceptors = [];
527
508
 
528
- forEach(interceptorFactories, (interceptorFactory) => {
509
+ interceptorFactories.forEach((interceptorFactory) => {
529
510
  reversedInterceptors.unshift(
530
511
  isString(interceptorFactory)
531
512
  ? $injector.get(interceptorFactory)
@@ -539,478 +520,8 @@ export function $HttpProvider() {
539
520
  const urlIsAllowedOrigin = urlIsAllowedOriginFactory(xsrfTrustedOrigins);
540
521
 
541
522
  /**
542
- * @ngdoc service
543
- * @kind function
544
- * @name $http
545
- * @requires ng.$httpBackend
546
- * @requires $cacheFactory
547
- * @requires $rootScope
548
- * @requires $q
549
- * @requires $injector
550
- *
551
- * @description
552
- * The `$http` service is a core AngularJS service that facilitates communication with the remote
553
- * HTTP servers via the browser's [XMLHttpRequest](https://developer.mozilla.org/en/xmlhttprequest)
554
- * object or via [JSONP](http://en.wikipedia.org/wiki/JSONP).
555
- *
556
- * For unit testing applications that use `$http` service, see
557
- * {@link ngMock.$httpBackend $httpBackend mock}.
558
- *
559
- * For a higher level of abstraction, please check out the {@link ngResource.$resource
560
- * $resource} service.
561
- *
562
- * The $http API is based on the {@link ng.$q deferred/promise APIs} exposed by
563
- * the $q service. While for simple usage patterns this doesn't matter much, for advanced usage
564
- * it is important to familiarize yourself with these APIs and the guarantees they provide.
565
- *
566
- *
567
- * ## General usage
568
- * The `$http` service is a function which takes a single argument — a {@link $http#usage configuration object} —
569
- * that is used to generate an HTTP request and returns a {@link ng.$q promise} that is
570
- * resolved (request success) or rejected (request failure) with a
571
- * {@link ng.$http#$http-returns response} object.
572
- *
573
- * ```js
574
- * // Simple GET request example:
575
- * $http({
576
- * method: 'GET',
577
- * url: '/someUrl'
578
- * }).then(function successCallback(response) {
579
- * // this callback will be called asynchronously
580
- * // when the response is available
581
- * }, function errorCallback(response) {
582
- * // called asynchronously if an error occurs
583
- * // or server returns response with an error status.
584
- * });
585
- * ```
586
- *
587
- *
588
- * ## Shortcut methods
589
- *
590
- * Shortcut methods are also available. All shortcut methods require passing in the URL, and
591
- * request data must be passed in for POST/PUT requests. An optional config can be passed as the
592
- * last argument.
593
- *
594
- * ```js
595
- * $http.get('/someUrl', config).then(successCallback, errorCallback);
596
- * $http.post('/someUrl', data, config).then(successCallback, errorCallback);
597
- * ```
598
- *
599
- * Complete list of shortcut methods:
600
- *
601
- * - {@link ng.$http#get $http.get}
602
- * - {@link ng.$http#head $http.head}
603
- * - {@link ng.$http#post $http.post}
604
- * - {@link ng.$http#put $http.put}
605
- * - {@link ng.$http#delete $http.delete}
606
- * - {@link ng.$http#patch $http.patch}
607
- *
608
- *
609
- * ```
610
- * $http.get(...);
611
- * $httpBackend.flush();
612
- * ```
613
- *
614
- * ## Setting HTTP Headers
615
- *
616
- * The $http service will automatically add certain HTTP headers to all requests. These defaults
617
- * can be fully configured by accessing the `$httpProvider.defaults.headers` configuration
618
- * object, which currently contains this default configuration:
619
- *
620
- * - `$httpProvider.defaults.headers.common` (headers that are common for all requests):
621
- * - <code>Accept: application/json, text/plain, \*&#65279;/&#65279;\*</code>
622
- * - `$httpProvider.defaults.headers.post`: (header defaults for POST requests)
623
- * - `Content-Type: application/json`
624
- * - `$httpProvider.defaults.headers.put` (header defaults for PUT requests)
625
- * - `Content-Type: application/json`
626
- *
627
- * To add or overwrite these defaults, simply add or remove a property from these configuration
628
- * objects. To add headers for an HTTP method other than POST or PUT, simply add a new object
629
- * with the lowercased HTTP method name as the key, e.g.
630
- * `$httpProvider.defaults.headers.get = { 'My-Header' : 'value' }`.
631
- *
632
- * The defaults can also be set at runtime via the `$http.defaults` object in the same
633
- * fashion. For example:
634
- *
635
- * ```
636
- * module.run(function($http) {
637
- * $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w';
638
- * });
639
- * ```
640
- *
641
- * In addition, you can supply a `headers` property in the config object passed when
642
- * calling `$http(config)`, which overrides the defaults without changing them globally.
643
- *
644
- * To explicitly remove a header automatically added via $httpProvider.defaults.headers on a per request basis,
645
- * Use the `headers` property, setting the desired header to `undefined`. For example:
646
- *
647
- * ```js
648
- * let req = {
649
- * method: 'POST',
650
- * url: 'http://example.com',
651
- * headers: {
652
- * 'Content-Type': undefined
653
- * },
654
- * data: { test: 'test' }
655
- * }
656
- *
657
- * $http(req).then(function(){...}, function(){...});
658
- * ```
659
- *
660
- * ## Transforming Requests and Responses
661
- *
662
- * Both requests and responses can be transformed using transformation functions: `transformRequest`
663
- * and `transformResponse`. These properties can be a single function that returns
664
- * the transformed value (`function(data, headersGetter, status)`) or an array of such transformation functions,
665
- * which allows you to `push` or `unshift` a new transformation function into the transformation chain.
666
- *
667
- * <div class="alert alert-warning">
668
- * **Note:** AngularJS does not make a copy of the `data` parameter before it is passed into the `transformRequest` pipeline.
669
- * That means changes to the properties of `data` are not local to the transform function (since Javascript passes objects by reference).
670
- * For example, when calling `$http.get(url, $scope.myObject)`, modifications to the object's properties in a transformRequest
671
- * function will be reflected on the scope and in any templates where the object is data-bound.
672
- * To prevent this, transform functions should have no side-effects.
673
- * If you need to modify properties, it is recommended to make a copy of the data, or create new object to return.
674
- * </div>
675
- *
676
- * ### Default Transformations
677
- *
678
- * The `$httpProvider` provider and `$http` service expose `defaults.transformRequest` and
679
- * `defaults.transformResponse` properties. If a request does not provide its own transformations
680
- * then these will be applied.
681
- *
682
- * You can augment or replace the default transformations by modifying these properties by adding to or
683
- * replacing the array.
684
- *
685
- * AngularJS provides the following default transformations:
686
- *
687
- * Request transformations (`$httpProvider.defaults.transformRequest` and `$http.defaults.transformRequest`) is
688
- * an array with one function that does the following:
689
- *
690
- * - If the `data` property of the request configuration object contains an object, serialize it
691
- * into JSON format.
692
- *
693
- * Response transformations (`$httpProvider.defaults.transformResponse` and `$http.defaults.transformResponse`) is
694
- * an array with one function that does the following:
695
- *
696
- * - If XSRF prefix is detected, strip it (see Security Considerations section below).
697
- * - If the `Content-Type` is `application/json` or the response looks like JSON,
698
- * deserialize it using a JSON parser.
699
- *
700
- *
701
- * ### Overriding the Default Transformations Per Request
702
- *
703
- * If you wish to override the request/response transformations only for a single request then provide
704
- * `transformRequest` and/or `transformResponse` properties on the configuration object passed
705
- * into `$http`.
706
- *
707
- * Note that if you provide these properties on the config object the default transformations will be
708
- * overwritten. If you wish to augment the default transformations then you must include them in your
709
- * local transformation array.
710
- *
711
- * The following code demonstrates adding a new response transformation to be run after the default response
712
- * transformations have been run.
713
- *
714
- * ```js
715
- * function appendTransform(defaults, transform) {
716
- *
717
- * // We can't guarantee that the default transformation is an array
718
- * defaults = angular.isArray(defaults) ? defaults : [defaults];
719
- *
720
- * // Append the new transformation to the defaults
721
- * return defaults.concat(transform);
722
- * }
723
- *
724
- * $http({
725
- * url: '...',
726
- * method: 'GET',
727
- * transformResponse: appendTransform($http.defaults.transformResponse, function(value) {
728
- * return doTransform(value);
729
- * })
730
- * });
731
- * ```
732
- *
733
- *
734
- * ## Caching
735
- *
736
- * {@link ng.$http `$http`} responses are not cached by default. To enable caching, you must
737
- * set the config.cache value or the default cache value to TRUE or to a cache object (created
738
- * with {@link ng.$cacheFactory `$cacheFactory`}). If defined, the value of config.cache takes
739
- * precedence over the default cache value.
740
- *
741
- * In order to:
742
- * * cache all responses - set the default cache value to TRUE or to a cache object
743
- * * cache a specific response - set config.cache value to TRUE or to a cache object
744
- *
745
- * If caching is enabled, but neither the default cache nor config.cache are set to a cache object,
746
- * then the default `$cacheFactory("$http")` object is used.
747
- *
748
- * The default cache value can be set by updating the
749
- * {@link ng.$http#defaults `$http.defaults.cache`} property or the
750
- * {@link $httpProvider#defaults `$httpProvider.defaults.cache`} property.
751
- *
752
- * When caching is enabled, {@link ng.$http `$http`} stores the response from the server using
753
- * the relevant cache object. The next time the same request is made, the response is returned
754
- * from the cache without sending a request to the server.
755
- *
756
- * Take note that:
757
- *
758
- * * Only GET and JSONP requests are cached.
759
- * * The cache key is the request URL including search parameters; headers are not considered.
760
- * * Cached responses are returned asynchronously, in the same way as responses from the server.
761
- * * If multiple identical requests are made using the same cache, which is not yet populated,
762
- * one request will be made to the server and remaining requests will return the same response.
763
- * * A cache-control header on the response does not affect if or how responses are cached.
764
- *
765
- *
766
- * ## Interceptors
767
- *
768
- * Before you start creating interceptors, be sure to understand the
769
- * {@link ng.$q $q and deferred/promise APIs}.
770
- *
771
- * For purposes of global error handling, authentication, or any kind of synchronous or
772
- * asynchronous pre-processing of request or postprocessing of responses, it is desirable to be
773
- * able to intercept requests before they are handed to the server and
774
- * responses before they are handed over to the application code that
775
- * initiated these requests. The interceptors leverage the {@link ng.$q
776
- * promise APIs} to fulfill this need for both synchronous and asynchronous pre-processing.
777
- *
778
- * The interceptors are service factories that are registered with the `$httpProvider` by
779
- * adding them to the `$httpProvider.interceptors` array. The factory is called and
780
- * injected with dependencies (if specified) and returns the interceptor.
781
- *
782
- * There are two kinds of interceptors (and two kinds of rejection interceptors):
783
- *
784
- * * `request`: interceptors get called with a http {@link $http#usage config} object. The function is free to
785
- * modify the `config` object or create a new one. The function needs to return the `config`
786
- * object directly, or a promise containing the `config` or a new `config` object.
787
- * * `requestError`: interceptor gets called when a previous interceptor threw an error or
788
- * resolved with a rejection.
789
- * * `response`: interceptors get called with http `response` object. The function is free to
790
- * modify the `response` object or create a new one. The function needs to return the `response`
791
- * object directly, or as a promise containing the `response` or a new `response` object.
792
- * * `responseError`: interceptor gets called when a previous interceptor threw an error or
793
- * resolved with a rejection.
794
- *
795
- *
796
- * ```js
797
- * // register the interceptor as a service
798
- * $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) {
799
- * return {
800
- * // optional method
801
- * 'request': function(config) {
802
- * // do something on success
803
- * return config;
804
- * },
805
- *
806
- * // optional method
807
- * 'requestError': function(rejection) {
808
- * // do something on error
809
- * if (canRecover(rejection)) {
810
- * return responseOrNewPromise
811
- * }
812
- * return $q.reject(rejection);
813
- * },
814
- *
815
- *
816
- *
817
- * // optional method
818
- * 'response': function(response) {
819
- * // do something on success
820
- * return response;
821
- * },
822
- *
823
- * // optional method
824
- * 'responseError': function(rejection) {
825
- * // do something on error
826
- * if (canRecover(rejection)) {
827
- * return responseOrNewPromise
828
- * }
829
- * return $q.reject(rejection);
830
- * }
831
- * };
832
- * });
833
- *
834
- * $httpProvider.interceptors.push('myHttpInterceptor');
835
- *
836
- *
837
- * // alternatively, register the interceptor via an anonymous factory
838
- * $httpProvider.interceptors.push(function($q, dependency1, dependency2) {
839
- * return {
840
- * 'request': function(config) {
841
- * // same as above
842
- * },
843
- *
844
- * 'response': function(response) {
845
- * // same as above
846
- * }
847
- * };
848
- * });
849
- * ```
850
- *
851
- * ## Security Considerations
852
- *
853
- * When designing web applications, consider security threats from:
854
- *
855
- * - [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx)
856
- * - [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)
857
- *
858
- * Both server and the client must cooperate in order to eliminate these threats. AngularJS comes
859
- * pre-configured with strategies that address these issues, but for this to work backend server
860
- * cooperation is required.
861
- *
862
- * ### JSON Vulnerability Protection
863
- *
864
- * A [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx)
865
- * allows third party website to turn your JSON resource URL into
866
- * [JSONP](http://en.wikipedia.org/wiki/JSONP) request under some conditions. To
867
- * counter this your server can prefix all JSON requests with following string `")]}',\n"`.
868
- * AngularJS will automatically strip the prefix before processing it as JSON.
869
- *
870
- * For example if your server needs to return:
871
- * ```js
872
- * ['one','two']
873
- * ```
874
- *
875
- * which is vulnerable to attack, your server can return:
876
- * ```js
877
- * )]}',
878
- * ['one','two']
879
- * ```
880
- *
881
- * AngularJS will strip the prefix, before processing the JSON.
882
- *
883
- *
884
- * ### Cross Site Request Forgery (XSRF) Protection
885
- *
886
- * [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) is an attack technique by
887
- * which the attacker can trick an authenticated user into unknowingly executing actions on your
888
- * website. AngularJS provides a mechanism to counter XSRF. When performing XHR requests, the
889
- * $http service reads a token from a cookie (by default, `XSRF-TOKEN`) and sets it as an HTTP
890
- * header (by default `X-XSRF-TOKEN`). Since only JavaScript that runs on your domain could read
891
- * the cookie, your server can be assured that the XHR came from JavaScript running on your
892
- * domain.
893
- *
894
- * To take advantage of this, your server needs to set a token in a JavaScript readable session
895
- * cookie called `XSRF-TOKEN` on the first HTTP GET request. On subsequent XHR requests the
896
- * server can verify that the cookie matches the `X-XSRF-TOKEN` HTTP header, and therefore be
897
- * sure that only JavaScript running on your domain could have sent the request. The token must
898
- * be unique for each user and must be verifiable by the server (to prevent the JavaScript from
899
- * making up its own tokens). We recommend that the token is a digest of your site's
900
- * authentication cookie with a [salt](https://en.wikipedia.org/wiki/Salt_(cryptography&#41;)
901
- * for added security.
902
- *
903
- * The header will &mdash; by default &mdash; **not** be set for cross-domain requests. This
904
- * prevents unauthorized servers (e.g. malicious or compromised 3rd-party APIs) from gaining
905
- * access to your users' XSRF tokens and exposing them to Cross Site Request Forgery. If you
906
- * want to, you can trust additional origins to also receive the XSRF token, by adding them
907
- * to {@link ng.$httpProvider#xsrfTrustedOrigins xsrfTrustedOrigins}. This might be
908
- * useful, for example, if your application, served from `example.com`, needs to access your API
909
- * at `api.example.com`.
910
- * See {@link ng.$httpProvider#xsrfTrustedOrigins $httpProvider.xsrfTrustedOrigins} for
911
- * more details.
912
- *
913
- * <div class="alert alert-danger">
914
- * **Warning**<br />
915
- * Only trusted origins that you have control over and make sure you understand the
916
- * implications of doing so.
917
- * </div>
918
- *
919
- * The name of the cookie and the header can be specified using the `xsrfCookieName` and
920
- * `xsrfHeaderName` properties of either `$httpProvider.defaults` at config-time,
921
- * `$http.defaults` at run-time, or the per-request config object.
922
- *
923
- * In order to prevent collisions in environments where multiple AngularJS apps share the
924
- * same domain or subdomain, we recommend that each application uses a unique cookie name.
925
- *
926
- *
927
- * @param {object} config Object describing the request to be made and how it should be
928
- * processed. The object has following properties:
929
- *
930
- * - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc)
931
- * - **url** – `{string|TrustedObject}` – Absolute or relative URL of the resource that is being requested;
932
- * or an object created by a call to `$sce.trustAsResourceUrl(url)`.
933
- * - **params** – `{Object.<string|Object>}` – Map of strings or objects which will be serialized
934
- * with the `paramSerializer` and appended as GET parameters.
935
- * - **data** – `{string|Object}` – Data to be sent as the request message data.
936
- * - **headers** – `{Object}` – Map of strings or functions which return strings representing
937
- * HTTP headers to send to the server. If the return value of a function is null, the
938
- * header will not be sent. Functions accept a config object as an argument.
939
- * - **eventHandlers** - `{Object}` - Event listeners to be bound to the XMLHttpRequest object.
940
- * To bind events to the XMLHttpRequest upload object, use `uploadEventHandlers`.
941
- * The handler will be called in the context of a `$apply` block.
942
- * - **uploadEventHandlers** - `{Object}` - Event listeners to be bound to the XMLHttpRequest upload
943
- * object. To bind events to the XMLHttpRequest object, use `eventHandlers`.
944
- * The handler will be called in the context of a `$apply` block.
945
- * - **xsrfHeaderName** – `{string}` – Name of HTTP header to populate with the XSRF token.
946
- * - **xsrfCookieName** – `{string}` – Name of cookie containing the XSRF token.
947
- * - **transformRequest** –
948
- * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
949
- * transform function or an array of such functions. The transform function takes the http
950
- * request body and headers and returns its transformed (typically serialized) version.
951
- * See {@link ng.$http#overriding-the-default-transformations-per-request
952
- * Overriding the Default Transformations}
953
- * - **transformResponse** –
954
- * `{function(data, headersGetter, status)|Array.<function(data, headersGetter, status)>}` –
955
- * transform function or an array of such functions. The transform function takes the http
956
- * response body, headers and status and returns its transformed (typically deserialized) version.
957
- * See {@link ng.$http#overriding-the-default-transformations-per-request
958
- * Overriding the Default Transformations}
959
- * - **paramSerializer** - `{string|function(Object<string,string>):string}` - A function used to
960
- * prepare the string representation of request parameters (specified as an object).
961
- * If specified as string, it is interpreted as function registered with the
962
- * {@link $injector $injector}, which means you can create your own serializer
963
- * by registering it as a {@link auto.$provide#service service}.
964
- * The default serializer is the {@link $httpParamSerializer $httpParamSerializer};
965
- * alternatively, you can use the {@link $httpParamSerializerJQLike $httpParamSerializerJQLike}
966
- * - **cache** – `{boolean|Object}` – A boolean value or object created with
967
- * {@link ng.$cacheFactory `$cacheFactory`} to enable or disable caching of the HTTP response.
968
- * See {@link $http#caching $http Caching} for more information.
969
- * - **timeout** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise}
970
- * that should abort the request when resolved.
971
- *
972
- * A numerical timeout or a promise returned from {@link ng.$timeout $timeout}, will set
973
- * the `xhrStatus` in the {@link $http#$http-returns response} to "timeout", and any other
974
- * resolved promise will set it to "abort", following standard XMLHttpRequest behavior.
975
- *
976
- * - **withCredentials** - `{boolean}` - whether to set the `withCredentials` flag on the
977
- * XHR object. See [requests with credentials](https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS#Requests_with_credentials)
978
- * for more information.
979
- * - **responseType** - `{string}` - see
980
- * [XMLHttpRequest.responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype).
981
- *
982
- * @returns {HttpPromise} A {@link ng.$q `Promise}` that will be resolved (request success)
983
- * or rejected (request failure) with a response object.
984
- *
985
- * The response object has these properties:
986
- *
987
- * - **data** – `{string|Object}` – The response body transformed with
988
- * the transform functions.
989
- * - **status** – `{number}` – HTTP status code of the response.
990
- * - **headers** – `{function([headerName])}` – Header getter function.
991
- * - **config** – `{Object}` – The configuration object that was used
992
- * to generate the request.
993
- * - **statusText** – `{string}` – HTTP status text of the response.
994
- * - **xhrStatus** – `{string}` – Status of the XMLHttpRequest
995
- * (`complete`, `error`, `timeout` or `abort`).
996
- *
997
- *
998
- * A response status code between 200 and 299 is considered a success status
999
- * and will result in the success callback being called. Any response status
1000
- * code outside of that range is considered an error status and will result
1001
- * in the error callback being called.
1002
- * Also, status codes less than -1 are normalized to zero. -1 usually means
1003
- * the request was aborted, e.g. using a `config.timeout`. More information
1004
- * about the status might be available in the `xhrStatus` property.
1005
- *
1006
- * Note that if the response is a redirect, XMLHttpRequest will transparently
1007
- * follow it, meaning that the outcome (success or error) will be determined
1008
- * by the final response status code.
1009
- *
1010
- *
1011
- * @property {Array.<Object>} pendingRequests Array of config objects for currently pending
1012
- * requests. This is primarily meant to be used for debugging purposes.
1013
- *
523
+ * @property {Array.<Object>} requestConfig Array of config objects for currently pending
524
+ * requests. This is primarily meant to be used for debugging purposes.
1014
525
  */
1015
526
  function $http(requestConfig) {
1016
527
  if (!isObject(requestConfig)) {
@@ -1177,13 +688,9 @@ export function $HttpProvider() {
1177
688
  $http.pendingRequests = [];
1178
689
 
1179
690
  /**
1180
- * @ngdoc method
1181
- * @name $http#get
1182
- *
1183
- * @description
1184
691
  * Shortcut method to perform `GET` request.
1185
692
  *
1186
- * @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
693
+ * @param {string} url Absolute or relative URL of the resource that is being requested;
1187
694
  * or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1188
695
  * @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1189
696
  * @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
@@ -1191,13 +698,9 @@ export function $HttpProvider() {
1191
698
  */
1192
699
 
1193
700
  /**
1194
- * @ngdoc method
1195
- * @name $http#delete
1196
- *
1197
- * @description
1198
701
  * Shortcut method to perform `DELETE` request.
1199
702
  *
1200
- * @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
703
+ * @param {string} url Absolute or relative URL of the resource that is being requested;
1201
704
  * or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1202
705
  * @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1203
706
  * @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
@@ -1205,13 +708,9 @@ export function $HttpProvider() {
1205
708
  */
1206
709
 
1207
710
  /**
1208
- * @ngdoc method
1209
- * @name $http#head
1210
- *
1211
- * @description
1212
711
  * Shortcut method to perform `HEAD` request.
1213
712
  *
1214
- * @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
713
+ * @param {string} url Absolute or relative URL of the resource that is being requested;
1215
714
  * or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1216
715
  * @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1217
716
  * @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
@@ -1219,10 +718,6 @@ export function $HttpProvider() {
1219
718
  */
1220
719
 
1221
720
  /**
1222
- * @ngdoc method
1223
- * @name $http#jsonp
1224
- *
1225
- * @description
1226
721
  * Shortcut method to perform `JSONP` request.
1227
722
  *
1228
723
  * Note that, since JSONP requests are sensitive because the response is given full access to the browser,
@@ -1246,7 +741,7 @@ export function $HttpProvider() {
1246
741
  * If you would like to customise where and how the callbacks are stored then try overriding
1247
742
  * or decorating the {@link $jsonpCallbacks} service.
1248
743
  *
1249
- * @param {string|TrustedObject} url Absolute or relative URL of the resource that is being requested;
744
+ * @param {string} url Absolute or relative URL of the resource that is being requested;
1250
745
  * or an object created by a call to `$sce.trustAsResourceUrl(url)`.
1251
746
  * @param {Object=} config Optional configuration object. See {@link ng.$http#$http-arguments `$http()` arguments}.
1252
747
  * @returns {HttpPromise} A Promise that will be resolved or rejected with a response object.
@@ -1255,10 +750,6 @@ export function $HttpProvider() {
1255
750
  createShortMethods("get", "delete", "head");
1256
751
 
1257
752
  /**
1258
- * @ngdoc method
1259
- * @name $http#post
1260
- *
1261
- * @description
1262
753
  * Shortcut method to perform `POST` request.
1263
754
  *
1264
755
  * @param {string} url Relative or absolute URL specifying the destination of the request
@@ -1269,10 +760,6 @@ export function $HttpProvider() {
1269
760
  */
1270
761
 
1271
762
  /**
1272
- * @ngdoc method
1273
- * @name $http#put
1274
- *
1275
- * @description
1276
763
  * Shortcut method to perform `PUT` request.
1277
764
  *
1278
765
  * @param {string} url Relative or absolute URL specifying the destination of the request
@@ -1407,7 +894,7 @@ export function $HttpProvider() {
1407
894
  // send the request to the backend
1408
895
  if (isUndefined(cachedResp)) {
1409
896
  const xsrfValue = urlIsAllowedOrigin(config.url)
1410
- ? $$cookieReader()[config.xsrfCookieName || defaults.xsrfCookieName]
897
+ ? getCookies()[config.xsrfCookieName || defaults.xsrfCookieName]
1411
898
  : undefined;
1412
899
  if (xsrfValue) {
1413
900
  reqHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] =