Git Product home page Git Product logo

node-cookiejar's Introduction

CookieJar

NPM version devDependency Status

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

node-cookiejar's People

Contributors

andyburke avatar bfarias-godaddy avatar bmeck avatar clement avatar coreyjewett avatar cwholt avatar danielmcq avatar edmeral avatar esrefdurna avatar finesse avatar fjakobs avatar keithamus avatar missinglink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-cookiejar's Issues

Please use tags when release new version

Hi,
we are going to include your module in Debian and Ubuntu.

But we have some problem here.. our automatic systems check for tags in github when look for a new release.

It seems you do not provide a tag for version 1.3.2. Could you please make it? and use them in the future?

Thanks in advance.

L.

Hitting global namespace instead of using exports correctly

exports.CookieAccessInfo=CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) {

this will add CookieAccessInfo to the global namespace!

var CookieAccessInfo=exports.CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) {

this is the way to go man.

I don't have time to PR the changes sorry.

Don't use prepublish to actually do prepublish related tasks

See npm/npm#3059 - prepublish also runs during npm install inside package's folder, so essentially every time someone clones from git, and runs npm install so they can dev, they get an error, like so:

> [email protected] prepublish /Users/dominykas/devel/experiments/tmp/node-cookiejar
> jshint cookiejar.js && git tag $npm_package_version && git push origin master && git push origin --tags

fatal: tag '2.0.3' already exists

You can use in-publish to circumvent this: https://www.npmjs.com/package/in-publish

Expired cookies are removed

For CookieAccessInfo.All I'd expect to get all the well-formed cookies, even the expired ones.

Use cases:

  • The package is used in test frameworks like chai and this makes it impossible to test for expired cookies.
  • Also using the jar to collect cookies for response, this makes it impossible to explicitly send a 'clear cookies' response as they are not added to the jar.

What license is your software?

Hi there. Unfortunately I can't package your module without knowing the license, so from a distribution packaging point of view it would be great if you could clarify this. Including a copy of your chosen license (eg, MIT) in a file called LICENSE would also be very helpful.

Thanks!

No key value pair found breaks parsing

Hi,

I'm using cookiejar as part of the popular scraping package x-ray. For some links, cookiejar will break with an error TypeError: Cannot read property '1' of null with the stack trace referring to https://github.com/bmeck/node-cookiejar/blob/master/cookiejar.js#L72. It breaks even when used within a try/except block so I can't do much to prevent this problem in my code. Can you give me some advice on how to fix this issue or help me make cookiejar throw a relevant error that I can catch downstream?

There's a reproducible example here:
matthewmueller/x-ray#234

Push to NPM please?

Hi!

This project is a dependency of Faye, and right now, the Mocha test suite is reporting global leaks because of cookiejar. It looks like these issues were fixed a year ago in this commit (4ecfd5d).

Would you please bump the version and get it on NPM?

Thanks!

Add tag for versions

It would be great if releases would not just bump the version in package.json, but also have an associated tag in git for them. This would make reviewing changes a lot nicer, and improve also the information provided by automated systems such as dependabot.

It seems that there are some tags already, but not for all versions. Maybe the release procedure could include making the tag, possibly by using npm version (patch|minor|major) instead of manually touching package.json?

Value of cookie is not decoded

If the cookie's value contains an equal sign, it will be URL-encoded:

sample=e30%3D; Path=/

This library should decode the value as part of parsing.

Cookie matches() fails when no port is specified

Although the specs are ambiguous about this (RFC-2965: HTTP State Management Mechanism, Google's Browser Security Handbook, or google), common browsers (I tested on Safari 5, Chrome 22, Firefox 10 on Mac) are considering a cookie from host with no port definition to be applicable for any port on the same host. This is true for the two different situations:

  1. a cookie that was received with no port should match on any specific port.
  2. a general cookie (.something.com) should match on any port

Because of the ambivalence in the specs, perhaps we should add a configurable flag for choosing the behavior (different ports = different cookie vs. different ports = same cookie).

In any case, for a site (http://www.something.com:80) running on port 80, a specific cookie on port 80 (www.something.com:80) should behave just like a specific cookie with no port (www.something.com), which is similar to a general cookie (.something.com) and vice versus.

A small change in collidesWith() is required for this. I would love to code the fix and make a pull request.

NPM publish

Hey, can you please npm publish issue #6 is plaguing me in superagent and I can't nag them to update until you publish.

Publish the 2.0.0 inside npm registry

Hi,

SuperAgent npm package depends of 2.0.0 node-cookiejar.
When I look on the repo seems that version 2.0.0 is pretty stable right now.

Do you thing will be possible to publish the 2.0.0 version on npm registry?

Provide facility for retrieving all cookies; a wildcard CookieAccessInfo

Hey @bmeck, thanks for the awesome project! We use it inside of the chai-http plugin and it works great!

One thing that would be really useful for our users - given that chai-http is a test framework - is to get cookies irrespective of access settings (See this issue for more). Perhaps having a sentinel of Cookie.CookieAccessInfo.All could be used to flag to cookie.match() to automatically return true?

Any thoughts on this would be much appreciated. If you like the idea I'm happy to PR it ๐Ÿ˜„

New release

Hi,

Can you publish a new release of cookiejar on npm and tag it please ?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.