vendor: 8,462 bytes, lines 1-253
1/** 2 * @license AngularJS v1.8.3 3 * (c) 2010-2020 Google LLC. http://angularjs.org 4 * License: MIT 5 */ 6(function(window, angular) {'use strict'; 7 8/** 9 * @ngdoc module 10 * @name ngCookies 11 * @description 12 * 13 * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies. 14 * 15 * See {@link ngCookies.$cookies `$cookies`} for usage. 16 */ 17 18 19angular.module('ngCookies', ['ng']). 20 info({ angularVersion: '1.8.3' }). 21 /** 22 * @ngdoc provider 23 * @name $cookiesProvider 24 * @description 25 * Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service. 26 * */ 27 provider('$cookies', [/** @this */function $CookiesProvider() { 28 /** 29 * @ngdoc property 30 * @name $cookiesProvider#defaults 31 * @description 32 * 33 * Object containing default options to pass when setting cookies. 34 * 35 * The object may have following properties: 36 * 37 * - **path** - `{string}` - The cookie will be available only for this path and its 38 * sub-paths. By default, this is the URL that appears in your `<base>` tag. 39 * - **domain** - `{string}` - The cookie will be available only for this domain and 40 * its sub-domains. For security reasons the user agent will not accept the cookie 41 * if the current domain is not a sub-domain of this domain or equal to it. 42 * - **expires** - `{string|Date}` - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" 43 * or a Date object indicating the exact date/time this cookie will expire. 44 * - **secure** - `{boolean}` - If `true`, then the cookie will only be available through a 45 * secured connection. 46 * - **samesite** - `{string}` - prevents the browser from sending the cookie along with cross-site requests. 47 * Accepts the values `lax` and `strict`. See the [OWASP Wiki](https://www.owasp.org/index.php/SameSite) 48 * for more info. Note that as of May 2018, not all browsers support `SameSite`, 49 * so it cannot be used as a single measure against Cross-Site-Request-Forgery (CSRF) attacks. 50 * 51 * Note: By default, the address that appears in your `<base>` tag will be used as the path. 52 * This is important so that cookies will be visible for all routes when html5mode is enabled. 53 * 54 * @example 55 * 56 * ```js 57 * angular.module('cookiesProviderExample', ['ngCookies']) 58 * .config(['$cookiesProvider', function($cookiesProvider) { 59 * // Setting default options 60 * $cookiesProvider.defaults.domain = 'foo.com'; 61 * $cookiesProvider.defaults.secure = true; 62 * }]); 63 * ``` 64 **/ 65 var defaults = this.defaults = {}; 66 67 function calcOptions(options) { 68 return options ? angular.extend({}, defaults, options) : defaults; 69 } 70 71 /** 72 * @ngdoc service 73 * @name $cookies 74 * 75 * @description 76 * Provides read/write access to browser's cookies. 77 * 78 * <div class="alert alert-info"> 79 * Up until AngularJS 1.3, `$cookies` exposed properties that represented the 80 * current browser cookie values. In version 1.4, this behavior has changed, and 81 * `$cookies` now provides a standard api of getters, setters etc. 82 * </div> 83 * 84 * Requires the {@link ngCookies `ngCookies`} module to be installed. 85 * 86 * @example 87 * 88 * ```js 89 * angular.module('cookiesExample', ['ngCookies']) 90 * .controller('ExampleController', ['$cookies', function($cookies) { 91 * // Retrieving a cookie 92 * var favoriteCookie = $cookies.get('myFavorite'); 93 * // Setting a cookie 94 * $cookies.put('myFavorite', 'oatmeal'); 95 * }]); 96 * ``` 97 */ 98 this.$get = ['$$cookieReader', '$$cookieWriter', function($$cookieReader, $$cookieWriter) { 99 return { 100 /** 101 * @ngdoc method 102 * @name $cookies#get 103 * 104 * @description 105 * Returns the value of given cookie key 106 * 107 * @param {string} key Id to use for lookup. 108 * @returns {string} Raw cookie value. 109 */ 110 get: function(key) { 111 return $$cookieReader()[key]; 112 }, 113 114 /** 115 * @ngdoc method 116 * @name $cookies#getObject 117 * 118 * @description 119 * Returns the deserialized value of given cookie key 120 * 121 * @param {string} key Id to use for lookup. 122 * @returns {Object} Deserialized cookie value. 123 */ 124 getObject: function(key) { 125 var value = this.get(key); 126 return value ? angular.fromJson(value) : value; 127 }, 128 129 /** 130 * @ngdoc method 131 * @name $cookies#getAll 132 * 133 * @description 134 * Returns a key value object with all the cookies 135 * 136 * @returns {Object} All cookies 137 */ 138 getAll: function() { 139 return $$cookieReader(); 140 }, 141 142 /** 143 * @ngdoc method 144 * @name $cookies#put 145 * 146 * @description 147 * Sets a value for given cookie key 148 * 149 * @param {string} key Id for the `value`. 150 * @param {string} value Raw value to be stored. 151 * @param {Object=} options Options object. 152 * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} 153 */ 154 put: function(key, value, options) { 155 $$cookieWriter(key, value, calcOptions(options)); 156 }, 157 158 /** 159 * @ngdoc method 160 * @name $cookies#putObject 161 * 162 * @description 163 * Serializes and sets a value for given cookie key 164 * 165 * @param {string} key Id for the `value`. 166 * @param {Object} value Value to be stored. 167 * @param {Object=} options Options object. 168 * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} 169 */ 170 putObject: function(key, value, options) { 171 this.put(key, angular.toJson(value), options); 172 }, 173 174 /** 175 * @ngdoc method 176 * @name $cookies#remove 177 * 178 * @description 179 * Remove given cookie 180 * 181 * @param {string} key Id of the key-value pair to delete. 182 * @param {Object=} options Options object. 183 * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} 184 */ 185 remove: function(key, options) { 186 $$cookieWriter(key, undefined, calcOptions(options)); 187 } 188 }; 189 }]; 190 }]); 191 192/** 193 * @name $$cookieWriter 194 * @requires $document 195 * 196 * @description 197 * This is a private service for writing cookies 198 * 199 * @param {string} name Cookie name 200 * @param {string=} value Cookie value (if undefined, cookie will be deleted) 201 * @param {Object=} options Object with options that need to be stored for the cookie. 202 */ 203function $$CookieWriter($document, $log, $browser) { 204 var cookiePath = $browser.baseHref(); 205 var rawDocument = $document[0]; 206 207 function buildCookieString(name, value, options) { 208 var path, expires; 209 options = options || {}; 210 expires = options.expires; 211 path = angular.isDefined(options.path) ? options.path : cookiePath; 212 if (angular.isUndefined(value)) { 213 expires = 'Thu, 01 Jan 1970 00:00:00 GMT'; 214 value = ''; 215 } 216 if (angular.isString(expires)) { 217 expires = new Date(expires); 218 } 219 220 var str = encodeURIComponent(name) + '=' + encodeURIComponent(value); 221 str += path ? ';path=' + path : ''; 222 str += options.domain ? ';domain=' + options.domain : ''; 223 str += expires ? ';expires=' + expires.toUTCString() : ''; 224 str += options.secure ? ';secure' : ''; 225 str += options.samesite ? ';samesite=' + options.samesite : ''; 226 227 // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum: 228 // - 300 cookies 229 // - 20 cookies per unique domain 230 // - 4096 bytes per cookie 231 var cookieLength = str.length + 1; 232 if (cookieLength > 4096) { 233 $log.warn('Cookie \'' + name + 234 '\' possibly not set or overflowed because it was too large (' + 235 cookieLength + ' > 4096 bytes)!'); 236 } 237 238 return str; 239 } 240 241 return function(name, value, options) { 242 rawDocument.cookie = buildCookieString(name, value, options); 243 }; 244} 245 246$$CookieWriter.$inject = ['$document', '$log', '$browser']; 247 248angular.module('ngCookies').provider('$$cookieWriter', /** @this */ function $$CookieWriterProvider() { 249 this.$get = $$CookieWriter; 250}); 251 252 253})(window, window.angular);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.