Socket
Socket
Sign inDemoInstall

tough-cookie

Package Overview
Dependencies
1
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.0 to 0.9.1

lib/.cookie.js.swn

16

lib/cookie.js

@@ -523,3 +523,3 @@ /*

if (this.domain)
if (this.domain && !this.hostOnly)
str += '; Domain='+this.domain;

@@ -775,4 +775,15 @@ if (this.path)

this.getCookies.apply(this,args);
}
};
CookieJar.prototype.getSetCookieStrings = function(/*..., cb*/) {
var args = Array.prototype.slice.call(arguments,0);
var cb = args.pop();
var next = function(err,cookies) {
if (err) cb(err);
else cb(null, cookies.map(function(c){return c.toString()}));
};
args.push(next);
this.getCookies.apply(this,args);
};
module.exports = {

@@ -788,2 +799,3 @@ CookieJar: CookieJar,

pathMatch: pathMatch,
getPublicSuffix: pubsuffix.getPublicSuffix,
};

2

package.json

@@ -6,3 +6,3 @@ {

"keywords": "HTTP cookie cookies set-cookie cookiejar jar RFC6265 RFC2965",
"version": "0.9.0",
"version": "0.9.1",
"homepage": "https://github.com/goinstant/node-cookie",

@@ -9,0 +9,0 @@ "repository": {

@@ -1,3 +0,5 @@

[RFC6265](http://tools.ietf.org/html/rfc6265) Cookies for Node.js
[RFC6265](http://tools.ietf.org/html/rfc6265) Cookies and CookieJar for Node.js
![Tough Cookie](http://www.goinstant.com.s3.amazonaws.com/tough-cookie.jpg)
# Synopsis

@@ -83,2 +85,11 @@

getPublicSuffix(hostname)
-------------------------
Returns the public suffix of this hostname. The public suffix is the shortest domain-name upon which a cookie can be set. Returns `null` if the hostname cannot have cookies set for it.
For example: `www.example.com` and `www.subdomain.example.com` both have public suffix `example.com`.
For further information, see http://publicsuffix.org/. This module derives its list from that site.
Cookie

@@ -221,4 +232,9 @@ ======

Accepts the same options as `.getCookies()` but passes a string suitable for a Cookie header rather than an array to the callback.
Accepts the same options as `.getCookies()` but passes a string suitable for a Cookie header rather than an array to the callback. Simply maps the `Cookie` array via `.cookieString()`.
.getSetCookieStrings(...)
---------------------
Accepts the same options as `.getCookies()` but passes an array of strings suitable for Set-Cookie headers (rather than an array of `Cookie`s) to the callback. Simply maps the cookie array via `.toString()`.
# TODO

@@ -225,0 +241,0 @@

@@ -169,2 +169,19 @@ /*

},
"formatting a host-only cookie": {
topic: function() {
var c = new Cookie();
c.key = 'a';
c.value = 'b';
c.hostOnly = true;
c.domain = 'shouldnt-stringify.example.com';
c.path = '/should-stringify';
return c;
},
"validates": function(c) {
assert.ok(c.validate());
},
"to string": function(c) {
assert.equal(c.toString(), 'a=b; Path=/should-stringify');
},
},
}).addBatch({

@@ -481,2 +498,13 @@ "TTL with max-age": function() {

},
"Setting sub-domain cookie": {
topic: function() {
var cj = new CookieJar();
var c = Cookie.parse("a=b; Domain=www.example.com; Path=/");
cj.setCookie(c, 'http://example.com/index.html', this.callback);
},
"fails": function(err,c) {
assert.ok(err.message.match(/domain/i));
assert.ok(!c);
},
},
"Setting HttpOnly cookie over non-HTTP API": {

@@ -605,3 +633,44 @@ topic: function() {

},
"then retrieving for http://example.com as a set-cookie header": {
topic: function(cj,results) {
cj.getSetCookieStrings('http://example.com',this.callback);
},
"get a single string": function(cookieHeaders) {
assert.length(cookieHeaders, 3);
assert.equal(cookieHeaders[0], "a=1; Domain=example.com; Path=/");
assert.equal(cookieHeaders[1], "b=2; Domain=example.com; Path=/; HttpOnly");
assert.equal(cookieHeaders[2], "e=5; Path=/");
},
},
},
"Repeated names": {
topic: function() {
var cb = this.callback;
var cj = new CookieJar();
var ex = 'http://www.example.com/';
var sc = cj.setCookie;
var tasks = [];
tasks.push(sc.bind(cj,'aaaa=xxxx',ex));
tasks.push(sc.bind(cj,'aaaa=1111; Domain=www.example.com',ex));
tasks.push(sc.bind(cj,'aaaa=2222; Domain=example.com',ex));
tasks.push(sc.bind(cj,'aaaa=3333; Domain=www.example.com; Path=/pathA',ex));
async.series(tasks,function(err,results) {
cb(err,{cj:cj, cookies:results});
});
},
"all got set": function(err,t) {
assert.length(t.cookies,4);
},
"then getting 'em back": {
topic: function(t) {
var cj = t.cj;
cj.getCookies('http://www.example.com/pathA',this.callback);
},
"there's just three": function (err,cookies) {
var vals = cookies.map(function(c) {return c.value});
// may break with sorting; sorting should put 3333 first due to longest path:
assert.deepEqual(vals, ['1111','2222','3333']);
}
},
},
"CookieJar setCookie errors": {

@@ -608,0 +677,0 @@ "public-suffix domain": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc