Commit 0a403424 authored by bingchuan's avatar bingchuan

[dev] version 1.8.2

parent aa8ce930
/** /**
* @license AngularJS v1.5.7 * @license AngularJS v1.8.2
* (c) 2010-2016 Google, Inc. http://angularjs.org * (c) 2010-2020 Google LLC. http://angularjs.org
* License: MIT * License: MIT
*/ */
(function(window, angular) {'use strict'; (function(window, angular) {'use strict';
/** /**
* @ngdoc module * @ngdoc module
* @name ngCookies * @name ngCookies
* @description * @description
* *
* # ngCookies
*
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies. * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
* *
*
* <div doc-module-components="ngCookies"></div>
*
* See {@link ngCookies.$cookies `$cookies`} for usage. * See {@link ngCookies.$cookies `$cookies`} for usage.
*/ */
angular.module('ngCookies', ['ng']). angular.module('ngCookies', ['ng']).
info({ angularVersion: '1.8.2' }).
/** /**
* @ngdoc provider * @ngdoc provider
* @name $cookiesProvider * @name $cookiesProvider
* @description * @description
* Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service. * Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service.
* */ * */
provider('$cookies', [function $CookiesProvider() { provider('$cookies', [/** @this */function $CookiesProvider() {
/** /**
* @ngdoc property * @ngdoc property
* @name $cookiesProvider#defaults * @name $cookiesProvider#defaults
...@@ -47,10 +43,24 @@ angular.module('ngCookies', ['ng']). ...@@ -47,10 +43,24 @@ angular.module('ngCookies', ['ng']).
* or a Date object indicating the exact date/time this cookie will expire. * or a Date object indicating the exact date/time this cookie will expire.
* - **secure** - `{boolean}` - If `true`, then the cookie will only be available through a * - **secure** - `{boolean}` - If `true`, then the cookie will only be available through a
* secured connection. * secured connection.
* - **samesite** - `{string}` - prevents the browser from sending the cookie along with cross-site requests.
* Accepts the values `lax` and `strict`. See the [OWASP Wiki](https://www.owasp.org/index.php/SameSite)
* for more info. Note that as of May 2018, not all browsers support `SameSite`,
* so it cannot be used as a single measure against Cross-Site-Request-Forgery (CSRF) attacks.
* *
* Note: By default, the address that appears in your `<base>` tag will be used as the path. * Note: By default, the address that appears in your `<base>` tag will be used as the path.
* This is important so that cookies will be visible for all routes when html5mode is enabled. * This is important so that cookies will be visible for all routes when html5mode is enabled.
* *
* @example
*
* ```js
* angular.module('cookiesProviderExample', ['ngCookies'])
* .config(['$cookiesProvider', function($cookiesProvider) {
* // Setting default options
* $cookiesProvider.defaults.domain = 'foo.com';
* $cookiesProvider.defaults.secure = true;
* }]);
* ```
**/ **/
var defaults = this.defaults = {}; var defaults = this.defaults = {};
...@@ -66,7 +76,7 @@ angular.module('ngCookies', ['ng']). ...@@ -66,7 +76,7 @@ angular.module('ngCookies', ['ng']).
* Provides read/write access to browser's cookies. * Provides read/write access to browser's cookies.
* *
* <div class="alert alert-info"> * <div class="alert alert-info">
* Up until Angular 1.3, `$cookies` exposed properties that represented the * Up until AngularJS 1.3, `$cookies` exposed properties that represented the
* current browser cookie values. In version 1.4, this behavior has changed, and * current browser cookie values. In version 1.4, this behavior has changed, and
* `$cookies` now provides a standard api of getters, setters etc. * `$cookies` now provides a standard api of getters, setters etc.
* </div> * </div>
...@@ -179,87 +189,7 @@ angular.module('ngCookies', ['ng']). ...@@ -179,87 +189,7 @@ angular.module('ngCookies', ['ng']).
}]; }];
}]); }]);
angular.module('ngCookies').
/**
* @ngdoc service
* @name $cookieStore
* @deprecated
* @requires $cookies
*
* @description
* Provides a key-value (string-object) storage, that is backed by session cookies.
* Objects put or retrieved from this storage are automatically serialized or
* deserialized by angular's toJson/fromJson.
*
* Requires the {@link ngCookies `ngCookies`} module to be installed.
*
* <div class="alert alert-danger">
* **Note:** The $cookieStore service is **deprecated**.
* Please use the {@link ngCookies.$cookies `$cookies`} service instead.
* </div>
*
* @example
*
* ```js
* angular.module('cookieStoreExample', ['ngCookies'])
* .controller('ExampleController', ['$cookieStore', function($cookieStore) {
* // Put cookie
* $cookieStore.put('myFavorite','oatmeal');
* // Get cookie
* var favoriteCookie = $cookieStore.get('myFavorite');
* // Removing a cookie
* $cookieStore.remove('myFavorite');
* }]);
* ```
*/
factory('$cookieStore', ['$cookies', function($cookies) {
return {
/** /**
* @ngdoc method
* @name $cookieStore#get
*
* @description
* Returns the value of given cookie key
*
* @param {string} key Id to use for lookup.
* @returns {Object} Deserialized cookie value, undefined if the cookie does not exist.
*/
get: function(key) {
return $cookies.getObject(key);
},
/**
* @ngdoc method
* @name $cookieStore#put
*
* @description
* Sets a value for given cookie key
*
* @param {string} key Id for the `value`.
* @param {Object} value Value to be stored.
*/
put: function(key, value) {
$cookies.putObject(key, value);
},
/**
* @ngdoc method
* @name $cookieStore#remove
*
* @description
* Remove given cookie
*
* @param {string} key Id of the key-value pair to delete.
*/
remove: function(key) {
$cookies.remove(key);
}
};
}]);
/**
* @name $$cookieWriter * @name $$cookieWriter
* @requires $document * @requires $document
* *
...@@ -270,7 +200,7 @@ angular.module('ngCookies'). ...@@ -270,7 +200,7 @@ angular.module('ngCookies').
* @param {string=} value Cookie value (if undefined, cookie will be deleted) * @param {string=} value Cookie value (if undefined, cookie will be deleted)
* @param {Object=} options Object with options that need to be stored for the cookie. * @param {Object=} options Object with options that need to be stored for the cookie.
*/ */
function $$CookieWriter($document, $log, $browser) { function $$CookieWriter($document, $log, $browser) {
var cookiePath = $browser.baseHref(); var cookiePath = $browser.baseHref();
var rawDocument = $document[0]; var rawDocument = $document[0];
...@@ -292,6 +222,7 @@ function $$CookieWriter($document, $log, $browser) { ...@@ -292,6 +222,7 @@ function $$CookieWriter($document, $log, $browser) {
str += options.domain ? ';domain=' + options.domain : ''; str += options.domain ? ';domain=' + options.domain : '';
str += expires ? ';expires=' + expires.toUTCString() : ''; str += expires ? ';expires=' + expires.toUTCString() : '';
str += options.secure ? ';secure' : ''; str += options.secure ? ';secure' : '';
str += options.samesite ? ';samesite=' + options.samesite : '';
// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum: // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
// - 300 cookies // - 300 cookies
...@@ -299,9 +230,9 @@ function $$CookieWriter($document, $log, $browser) { ...@@ -299,9 +230,9 @@ function $$CookieWriter($document, $log, $browser) {
// - 4096 bytes per cookie // - 4096 bytes per cookie
var cookieLength = str.length + 1; var cookieLength = str.length + 1;
if (cookieLength > 4096) { if (cookieLength > 4096) {
$log.warn("Cookie '" + name + $log.warn('Cookie \'' + name +
"' possibly not set or overflowed because it was too large (" + '\' possibly not set or overflowed because it was too large (' +
cookieLength + " > 4096 bytes)!"); cookieLength + ' > 4096 bytes)!');
} }
return str; return str;
...@@ -310,13 +241,13 @@ function $$CookieWriter($document, $log, $browser) { ...@@ -310,13 +241,13 @@ function $$CookieWriter($document, $log, $browser) {
return function(name, value, options) { return function(name, value, options) {
rawDocument.cookie = buildCookieString(name, value, options); rawDocument.cookie = buildCookieString(name, value, options);
}; };
} }
$$CookieWriter.$inject = ['$document', '$log', '$browser']; $$CookieWriter.$inject = ['$document', '$log', '$browser'];
angular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() { angular.module('ngCookies').provider('$$cookieWriter', /** @this */ function $$CookieWriterProvider() {
this.$get = $$CookieWriter; this.$get = $$CookieWriter;
}); });
})(window, window.angular); })(window, window.angular);
{ {
"name": "angular-cookies", "name": "angular-cookies",
"version": "1.5.7", "version": "1.8.2",
"license": "MIT", "license": "MIT",
"main": "./angular-cookies.js", "main": "./angular-cookies.js",
"ignore": [], "ignore": [],
"dependencies": { "dependencies": {
"angular": "1.5.7" "angular": "1.8.2"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment