├── index.js ├── bower.json ├── package.json ├── LICENSE.md ├── angular-cookies.min.js ├── README.md ├── angular-cookies.min.js.map └── angular-cookies.js /index.js: -------------------------------------------------------------------------------- 1 | require('./angular-cookies'); 2 | module.exports = 'ngCookies'; 3 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-cookies", 3 | "version": "1.8.3", 4 | "license": "MIT", 5 | "main": "./angular-cookies.js", 6 | "ignore": [], 7 | "dependencies": { 8 | "angular": "1.8.3" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-cookies", 3 | "version": "1.8.3", 4 | "description": "AngularJS module for cookies", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/angular/angular.js.git" 12 | }, 13 | "keywords": [ 14 | "angular", 15 | "framework", 16 | "browser", 17 | "cookies", 18 | "client-side" 19 | ], 20 | "author": "Angular Core Team ", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/angular/angular.js/issues" 24 | }, 25 | "homepage": "http://angularjs.org", 26 | "jspm": { 27 | "shim": { 28 | "angular-cookies": { 29 | "deps": ["angular"] 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Angular 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /angular-cookies.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.8.3 3 | (c) 2010-2020 Google LLC. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(n,e){'use strict';function m(d,k,l){var a=l.baseHref(),h=d[0];return function(f,b,c){var d,g;c=c||{};g=c.expires;d=e.isDefined(c.path)?c.path:a;e.isUndefined(b)&&(g="Thu, 01 Jan 1970 00:00:00 GMT",b="");e.isString(g)&&(g=new Date(g));b=encodeURIComponent(f)+"="+encodeURIComponent(b);b=b+(d?";path="+d:"")+(c.domain?";domain="+c.domain:"");b+=g?";expires="+g.toUTCString():"";b+=c.secure?";secure":"";b+=c.samesite?";samesite="+c.samesite:"";c=b.length+1;4096 4096 bytes)!");h.cookie=b}}e.module("ngCookies",["ng"]).info({angularVersion:"1.8.3"}).provider("$cookies",[function(){var d=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(k,l){return{get:function(a){return k()[a]},getObject:function(a){return(a=this.get(a))?e.fromJson(a):a},getAll:function(){return k()},put:function(a,h,f){l(a,h,f?e.extend({},d,f):d)},putObject:function(a,d,f){this.put(a,e.toJson(d),f)},remove:function(a,h){l(a,void 0,h?e.extend({},d,h):d)}}}]}]);m.$inject= 8 | ["$document","$log","$browser"];e.module("ngCookies").provider("$$cookieWriter",function(){this.$get=m})})(window,window.angular); 9 | //# sourceMappingURL=angular-cookies.min.js.map 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # packaged angular-cookies 2 | 3 | **This package contains the legacy AngularJS (version 1.x). AngularJS support has officially ended 4 | as of January 2022. 5 | [See what ending support means](https://docs.angularjs.org/misc/version-support-status) and 6 | [read the end of life announcement](https://goo.gle/angularjs-end-of-life).** 7 | 8 | **[See `@angular/core` for the actively supported Angular](https://npmjs.com/@angular/core).** 9 | 10 | ## Install 11 | 12 | You can install this package either with `npm` or with `bower`. 13 | 14 | ### npm 15 | 16 | ```shell 17 | npm install angular-cookies 18 | ``` 19 | 20 | Then add `ngCookies` as a dependency for your app: 21 | 22 | ```javascript 23 | angular.module('myApp', [require('angular-cookies')]); 24 | ``` 25 | 26 | ### bower 27 | 28 | ```shell 29 | bower install angular-cookies 30 | ``` 31 | 32 | Add a ` 36 | ``` 37 | 38 | Then add `ngCookies` as a dependency for your app: 39 | 40 | ```javascript 41 | angular.module('myApp', ['ngCookies']); 42 | ``` 43 | 44 | ## Documentation 45 | 46 | Documentation is available on the 47 | [AngularJS docs site](http://docs.angularjs.org/api/ngCookies). 48 | 49 | ## License 50 | 51 | The MIT License 52 | 53 | Copyright (c) 2022 Google LLC 54 | 55 | Permission is hereby granted, free of charge, to any person obtaining a copy 56 | of this software and associated documentation files (the "Software"), to deal 57 | in the Software without restriction, including without limitation the rights 58 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 59 | copies of the Software, and to permit persons to whom the Software is 60 | furnished to do so, subject to the following conditions: 61 | 62 | The above copyright notice and this permission notice shall be included in 63 | all copies or substantial portions of the Software. 64 | 65 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 66 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 67 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 68 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 69 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 70 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 71 | THE SOFTWARE. 72 | -------------------------------------------------------------------------------- /angular-cookies.min.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file":"angular-cookies.min.js", 4 | "lineCount":8, 5 | "mappings":"A;;;;;aAKC,SAAQ,CAACA,CAAD,CAASC,CAAT,CAAkB,CAqM3BC,QAASA,EAAc,CAACC,CAAD,CAAYC,CAAZ,CAAkBC,CAAlB,CAA4B,CACjD,IAAIC,EAAaD,CAAAE,SAAA,EAAjB,CACIC,EAAcL,CAAA,CAAU,CAAV,CAoClB,OAAO,SAAQ,CAACM,CAAD,CAAOC,CAAP,CAAcC,CAAd,CAAuB,CAlCW,IAC3CC,CAD2C,CACrCC,CACVF,EAAA,CAiCoDA,CAjCpD,EAAqB,EACrBE,EAAA,CAAUF,CAAAE,QACVD,EAAA,CAAOX,CAAAa,UAAA,CAAkBH,CAAAC,KAAlB,CAAA,CAAkCD,CAAAC,KAAlC,CAAiDN,CACpDL,EAAAc,YAAA,CAAoBL,CAApB,CAAJ,GACEG,CACA,CADU,+BACV,CAAAH,CAAA,CAAQ,EAFV,CAIIT,EAAAe,SAAA,CAAiBH,CAAjB,CAAJ,GACEA,CADF,CACY,IAAII,IAAJ,CAASJ,CAAT,CADZ,CAIIK,EAAAA,CAAMC,kBAAA,CAsB6BV,CAtB7B,CAANS,CAAiC,GAAjCA,CAAuCC,kBAAA,CAAmBT,CAAnB,CAE3CQ,EAAA,CADAA,CACA,EADON,CAAA,CAAO,QAAP,CAAkBA,CAAlB,CAAyB,EAChC,GAAOD,CAAAS,OAAA,CAAiB,UAAjB,CAA8BT,CAAAS,OAA9B,CAA+C,EAAtD,CACAF,EAAA,EAAOL,CAAA,CAAU,WAAV,CAAwBA,CAAAQ,YAAA,EAAxB,CAAgD,E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WA,QAAQ,CAACN,CAAD,CAAM5B,CAAN,CAAaC,CAAb,CAAsB,CACvC,IAAA+B,IAAA,CAASJ,CAAT,CAAcrC,CAAA4C,OAAA,CAAenC,CAAf,CAAd,CAAqCC,CAArC,CADuC,CAvEpC,CAsFLmC,OAAQA,QAAQ,CAACR,CAAD,CAAM3B,CAAN,CAAe,CAC7ByB,CAAA,CAAeE,CAAf,CAAoBS,IAAAA,EAApB,CAA2CpC,CAtHxC,CAAUV,CAAA0C,OAAA,CAAe,EAAf,CAAmBV,CAAnB,CAsH8BtB,CAtH9B,CAAV,CAAkDsB,CAsHrD,CAD6B,CAtF1B,CADiF,CAA9E,CAvEiD,CAAzC,CARxB,CAmOA/B,EAAA8C,QAAA;AAAyB,CAAC,WAAD,CAAc,MAAd,CAAsB,UAAtB,CAEzB/C,EAAA2B,OAAA,CAAe,WAAf,CAAAG,SAAA,CAAqC,gBAArC,CAAoEkB,QAA+B,EAAG,CACpG,IAAAf,KAAA,CAAYhC,CADwF,CAAtG,CAlP2B,CAA1B,CAAD,CAuPGF,MAvPH,CAuPWA,MAAAC,QAvPX;", 6 | "sources":["angular-cookies.js"], 7 | "names":["window","angular","$$CookieWriter","$document","$log","$browser","cookiePath","baseHref","rawDocument","name","value","options","path","expires","isDefined","isUndefined","isString","Date","str","encodeURIComponent","domain","toUTCString","secure","samesite","cookieLength","length","warn","cookie","module","info","angularVersion","provider","$CookiesProvider","defaults","$get","$$cookieReader","$$cookieWriter","get","key","getObject","fromJson","getAll","put","extend","putObject","toJson","remove","undefined","$inject","$$CookieWriterProvider"] 8 | } 9 | -------------------------------------------------------------------------------- /angular-cookies.js: -------------------------------------------------------------------------------- 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 | 19 | angular.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 `` 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 `` 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 | *
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 | *
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 | */ 203 | function $$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 | 248 | angular.module('ngCookies').provider('$$cookieWriter', /** @this */ function $$CookieWriterProvider() { 249 | this.$get = $$CookieWriter; 250 | }); 251 | 252 | 253 | })(window, window.angular); 254 | --------------------------------------------------------------------------------