summaryrefslogtreecommitdiff
path: root/together/node_modules/cookiejar
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-08-21 17:31:56 +0200
committerMinteck <contact@minteck.org>2022-08-21 17:31:56 +0200
commita2df9a69dcc14cb70118cda2ded499055e7ee358 (patch)
tree6dd283e4e9452d38bce81ddaaae49b5335755842 /together/node_modules/cookiejar
parent84dd0735820b16b60f600284d35183d76547a71f (diff)
downloadpluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz
pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2
pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip
m. update
Diffstat (limited to 'together/node_modules/cookiejar')
-rw-r--r--together/node_modules/cookiejar/LICENSE9
-rw-r--r--together/node_modules/cookiejar/cookiejar.js276
-rw-r--r--together/node_modules/cookiejar/package.json26
-rw-r--r--together/node_modules/cookiejar/readme.md60
4 files changed, 371 insertions, 0 deletions
diff --git a/together/node_modules/cookiejar/LICENSE b/together/node_modules/cookiejar/LICENSE
new file mode 100644
index 0000000..58a23ec
--- /dev/null
+++ b/together/node_modules/cookiejar/LICENSE
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+Copyright (c) 2013 Bradley Meck
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/together/node_modules/cookiejar/cookiejar.js b/together/node_modules/cookiejar/cookiejar.js
new file mode 100644
index 0000000..8f7db4e
--- /dev/null
+++ b/together/node_modules/cookiejar/cookiejar.js
@@ -0,0 +1,276 @@
+/* jshint node: true */
+(function () {
+ "use strict";
+
+ function CookieAccessInfo(domain, path, secure, script) {
+ if (this instanceof CookieAccessInfo) {
+ this.domain = domain || undefined;
+ this.path = path || "/";
+ this.secure = !!secure;
+ this.script = !!script;
+ return this;
+ }
+ return new CookieAccessInfo(domain, path, secure, script);
+ }
+ CookieAccessInfo.All = Object.freeze(Object.create(null));
+ exports.CookieAccessInfo = CookieAccessInfo;
+
+ function Cookie(cookiestr, request_domain, request_path) {
+ if (cookiestr instanceof Cookie) {
+ return cookiestr;
+ }
+ if (this instanceof Cookie) {
+ this.name = null;
+ this.value = null;
+ this.expiration_date = Infinity;
+ this.path = String(request_path || "/");
+ this.explicit_path = false;
+ this.domain = request_domain || null;
+ this.explicit_domain = false;
+ this.secure = false; //how to define default?
+ this.noscript = false; //httponly
+ if (cookiestr) {
+ this.parse(cookiestr, request_domain, request_path);
+ }
+ return this;
+ }
+ return new Cookie(cookiestr, request_domain, request_path);
+ }
+ exports.Cookie = Cookie;
+
+ Cookie.prototype.toString = function toString() {
+ var str = [this.name + "=" + this.value];
+ if (this.expiration_date !== Infinity) {
+ str.push("expires=" + (new Date(this.expiration_date)).toGMTString());
+ }
+ if (this.domain) {
+ str.push("domain=" + this.domain);
+ }
+ if (this.path) {
+ str.push("path=" + this.path);
+ }
+ if (this.secure) {
+ str.push("secure");
+ }
+ if (this.noscript) {
+ str.push("httponly");
+ }
+ return str.join("; ");
+ };
+
+ Cookie.prototype.toValueString = function toValueString() {
+ return this.name + "=" + this.value;
+ };
+
+ var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g;
+ Cookie.prototype.parse = function parse(str, request_domain, request_path) {
+ if (this instanceof Cookie) {
+ var parts = str.split(";").filter(function (value) {
+ return !!value;
+ });
+ var i;
+
+ var pair = parts[0].match(/([^=]+)=([\s\S]*)/);
+ if (!pair) {
+ console.warn("Invalid cookie header encountered. Header: '"+str+"'");
+ return;
+ }
+
+ var key = pair[1];
+ var value = pair[2];
+ if ( typeof key !== 'string' || key.length === 0 || typeof value !== 'string' ) {
+ console.warn("Unable to extract values from cookie header. Cookie: '"+str+"'");
+ return;
+ }
+
+ this.name = key;
+ this.value = value;
+
+ for (i = 1; i < parts.length; i += 1) {
+ pair = parts[i].match(/([^=]+)(?:=([\s\S]*))?/);
+ key = pair[1].trim().toLowerCase();
+ value = pair[2];
+ switch (key) {
+ case "httponly":
+ this.noscript = true;
+ break;
+ case "expires":
+ this.expiration_date = value ?
+ Number(Date.parse(value)) :
+ Infinity;
+ break;
+ case "path":
+ this.path = value ?
+ value.trim() :
+ "";
+ this.explicit_path = true;
+ break;
+ case "domain":
+ this.domain = value ?
+ value.trim() :
+ "";
+ this.explicit_domain = !!this.domain;
+ break;
+ case "secure":
+ this.secure = true;
+ break;
+ }
+ }
+
+ if (!this.explicit_path) {
+ this.path = request_path || "/";
+ }
+ if (!this.explicit_domain) {
+ this.domain = request_domain;
+ }
+
+ return this;
+ }
+ return new Cookie().parse(str, request_domain, request_path);
+ };
+
+ Cookie.prototype.matches = function matches(access_info) {
+ if (access_info === CookieAccessInfo.All) {
+ return true;
+ }
+ if (this.noscript && access_info.script ||
+ this.secure && !access_info.secure ||
+ !this.collidesWith(access_info)) {
+ return false;
+ }
+ return true;
+ };
+
+ Cookie.prototype.collidesWith = function collidesWith(access_info) {
+ if ((this.path && !access_info.path) || (this.domain && !access_info.domain)) {
+ return false;
+ }
+ if (this.path && access_info.path.indexOf(this.path) !== 0) {
+ return false;
+ }
+ if (this.explicit_path && access_info.path.indexOf( this.path ) !== 0) {
+ return false;
+ }
+ var access_domain = access_info.domain && access_info.domain.replace(/^[\.]/,'');
+ var cookie_domain = this.domain && this.domain.replace(/^[\.]/,'');
+ if (cookie_domain === access_domain) {
+ return true;
+ }
+ if (cookie_domain) {
+ if (!this.explicit_domain) {
+ return false; // we already checked if the domains were exactly the same
+ }
+ var wildcard = access_domain.indexOf(cookie_domain);
+ if (wildcard === -1 || wildcard !== access_domain.length - cookie_domain.length) {
+ return false;
+ }
+ return true;
+ }
+ return true;
+ };
+
+ function CookieJar() {
+ var cookies, cookies_list, collidable_cookie;
+ if (this instanceof CookieJar) {
+ cookies = Object.create(null); //name: [Cookie]
+
+ this.setCookie = function setCookie(cookie, request_domain, request_path) {
+ var remove, i;
+ cookie = new Cookie(cookie, request_domain, request_path);
+ //Delete the cookie if the set is past the current time
+ remove = cookie.expiration_date <= Date.now();
+ if (cookies[cookie.name] !== undefined) {
+ cookies_list = cookies[cookie.name];
+ for (i = 0; i < cookies_list.length; i += 1) {
+ collidable_cookie = cookies_list[i];
+ if (collidable_cookie.collidesWith(cookie)) {
+ if (remove) {
+ cookies_list.splice(i, 1);
+ if (cookies_list.length === 0) {
+ delete cookies[cookie.name];
+ }
+ return false;
+ }
+ cookies_list[i] = cookie;
+ return cookie;
+ }
+ }
+ if (remove) {
+ return false;
+ }
+ cookies_list.push(cookie);
+ return cookie;
+ }
+ if (remove) {
+ return false;
+ }
+ cookies[cookie.name] = [cookie];
+ return cookies[cookie.name];
+ };
+ //returns a cookie
+ this.getCookie = function getCookie(cookie_name, access_info) {
+ var cookie, i;
+ cookies_list = cookies[cookie_name];
+ if (!cookies_list) {
+ return;
+ }
+ for (i = 0; i < cookies_list.length; i += 1) {
+ cookie = cookies_list[i];
+ if (cookie.expiration_date <= Date.now()) {
+ if (cookies_list.length === 0) {
+ delete cookies[cookie.name];
+ }
+ continue;
+ }
+
+ if (cookie.matches(access_info)) {
+ return cookie;
+ }
+ }
+ };
+ //returns a list of cookies
+ this.getCookies = function getCookies(access_info) {
+ var matches = [], cookie_name, cookie;
+ for (cookie_name in cookies) {
+ cookie = this.getCookie(cookie_name, access_info);
+ if (cookie) {
+ matches.push(cookie);
+ }
+ }
+ matches.toString = function toString() {
+ return matches.join(":");
+ };
+ matches.toValueString = function toValueString() {
+ return matches.map(function (c) {
+ return c.toValueString();
+ }).join('; ');
+ };
+ return matches;
+ };
+
+ return this;
+ }
+ return new CookieJar();
+ }
+ exports.CookieJar = CookieJar;
+
+ //returns list of cookies that were set correctly. Cookies that are expired and removed are not returned.
+ CookieJar.prototype.setCookies = function setCookies(cookies, request_domain, request_path) {
+ cookies = Array.isArray(cookies) ?
+ cookies :
+ cookies.split(cookie_str_splitter);
+ var successful = [],
+ i,
+ cookie;
+ cookies = cookies.map(function(item){
+ return new Cookie(item, request_domain, request_path);
+ });
+ for (i = 0; i < cookies.length; i += 1) {
+ cookie = cookies[i];
+ if (this.setCookie(cookie, request_domain, request_path)) {
+ successful.push(cookie);
+ }
+ }
+ return successful;
+ };
+}());
diff --git a/together/node_modules/cookiejar/package.json b/together/node_modules/cookiejar/package.json
new file mode 100644
index 0000000..8633831
--- /dev/null
+++ b/together/node_modules/cookiejar/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "cookiejar",
+ "version": "2.1.3",
+ "author": {
+ "name": "bradleymeck"
+ },
+ "main": "cookiejar.js",
+ "description": "simple persistent cookiejar system",
+ "files": [
+ "cookiejar.js"
+ ],
+ "license": "MIT",
+ "jshintConfig": {
+ "node": true
+ },
+ "scripts": {
+ "test": "node tests/test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/bmeck/node-cookiejar.git"
+ },
+ "devDependencies": {
+ "jshint": "^2.9.4"
+ }
+}
diff --git a/together/node_modules/cookiejar/readme.md b/together/node_modules/cookiejar/readme.md
new file mode 100644
index 0000000..71a9f23
--- /dev/null
+++ b/together/node_modules/cookiejar/readme.md
@@ -0,0 +1,60 @@
+# CookieJar
+
+[![NPM version](http://img.shields.io/npm/v/cookiejar.svg)](https://www.npmjs.org/package/cookiejar)
+[![devDependency Status](https://david-dm.org/bmeck/node-cookiejar/dev-status.svg)](https://david-dm.org/bmeck/node-cookiejar?type=dev)
+
+Simple robust cookie library
+
+## Exports
+
+### CookieAccessInfo(domain,path,secure,script)
+
+class to determine matching qualities of a cookie
+
+##### Properties
+
+* String domain - domain to match
+* String path - path to match
+* Boolean secure - access is secure (ssl generally)
+* Boolean script - access is from a script
+
+
+### Cookie(cookiestr_or_cookie, request_domain, request_path)
+
+It turns input into a Cookie (singleton if given a Cookie),
+the `request_domain` argument is used to default the domain if it is not explicit in the cookie string,
+the `request_path` argument is used to set the path if it is not explicit in a cookie String.
+
+Explicit domains/paths will cascade, implied domains/paths must *exactly* match (see http://en.wikipedia.org/wiki/HTTP_cookie#Domain_and_Pat).
+
+##### Properties
+
+* String name - name of the cookie
+* String value - string associated with the cookie
+* String domain - domain to match (on a cookie a '.' at the start means a wildcard matching anything ending in the rest)
+* Boolean explicit_domain - if the domain was explicitly set via the cookie string
+* String path - base path to match (matches any path starting with this '/' is root)
+* Boolean explicit_path - if the path was explicitly set via the cookie string
+* Boolean noscript - if it should be kept from scripts
+* Boolean secure - should it only be transmitted over secure means
+* Number expiration_date - number of millis since 1970 at which this should be removed
+
+##### Methods
+
+* `String toString()` - the __set-cookie:__ string for this cookie
+* `String toValueString()` - the __cookie:__ string for this cookie
+* `Cookie parse(cookiestr, request_domain, request_path)` - parses the string onto this cookie or a new one if called directly
+* `Boolean matches(access_info)` - returns true if the access_info allows retrieval of this cookie
+* `Boolean collidesWith(cookie)` - returns true if the cookies cannot exist in the same space (domain and path match)
+
+
+### CookieJar()
+
+class to hold numerous cookies from multiple domains correctly
+
+##### Methods
+
+* `Cookie setCookie(cookie, request_domain, request_path)` - modify (or add if not already-existing) a cookie to the jar
+* `Cookie[] setCookies(cookiestr_or_list, request_domain, request_path)` - modify (or add if not already-existing) a large number of cookies to the jar
+* `Cookie getCookie(cookie_name,access_info)` - get a cookie with the name and access_info matching
+* `Cookie[] getCookies(access_info)` - grab all cookies matching this access_info