forwardemail / forwardemail/superagent

[Feature request] Expose CookieAccessInfo from cookiejar in Node

Open
#1,683 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

In Node, we have access to an `Agent`'s cookie jar on the `.jar` property, but in order to retrieve cookies from it (useful in certain cases including testing) [we also need access to `CookieAccessInfo`](https://github.com/bmeck/node-cookiejar#methods-1), which currently isn't exposed by Superagent.

Currently, the way to work around this would be to import `cookiejar` in our own code, however:

1. Having an implicit dependency is a bad idea, not least because there's no guarantee that we'll get the version of `cookiejar` that Superagent is using. A different version is not guaranteed to be compatible, and at the very least it would break `CookieAccessInfo.All` because it's [used like a symbol](https://github.com/bmeck/node-cookiejar/blob/7d0d6317f5cdecca7fa1eebd1126eeb40e56e2cc/cookiejar.js#L133).

2. If we make the dependency explicit in `package.json` we have to take care to match the version that Superagent uses, which is annoying and brittle - even then there may not be a strong guarantee that Superagent uses the version we import.

For these reasons, could `CookieAccessInfo` (or alternatively, the whole `cookiejar` module) be exposed somewhere? Maybe as a static property of `Agent`? Then we could do `superagent.agent.CookieAccessInfo`. Or maybe as a prototype property? Another option is to expose it on the main import, but I'm not sure if that makes sense or not. Or even just a separate file we could import like `'superagent/cookiejar'`. If we can work out which one is preferred I'd be happy to throw up a PR myself. I'd also like it to be exposed from Supertest, if that makes any difference.

Previous request from a long time ago that was closed without explanation: #192

Contributor guide

Open the contributing guide

Research direction

Trace Agent's .jar property and the bundled cookiejar dependency first; compare exposing CookieAccessInfo on Agent, the main import, or a subpath such as superagent/cookiejar. Done means a stable Node-facing export that avoids consumers importing cookiejar directly, with Supertest coverage if that remains in scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.