I'm back from here. https://github.com/sindresorhus/got/issues/811
It is an issue of tough-cookie library. But the fix is in stale status for several months...
So I'm thinking it would be really nice if got provides an abstract interface so I can use other cookie store than tough-cookie.
Out of curiosity, what other cookie storage would you use?
It is an issue of tough-cookie library. But the fix is in stale status for several months...
You haven't opened such issue. Not to mention that tough-cookie is RFC-compliant.
I think @Rokt33r is referring to https://github.com/salesforce/tough-cookie/pull/130
Ah. In this case I would just open a new PR. The fix is very simple.
So I'm thinking it would be really nice if got provides an abstract interface so I can use other cookie store than tough-cookie.
You just need to pass an object having these and you're good to go:
setCookie(cookieOrString, currentUrl, [{options},] cb(err,cookie))getCookieString(currentUrl, [{options},] cb(err,cookies))@sindresorhus I'm not using any for now. But if got makes it possible, I would have options to fork tough-cookie or to make another one from the scratch.
@szmarczak I think we need to define cookieJar interface in this package too. Otherwise, I still need to install @types/tough-cookie every time.
Also it would be awesome if the new interface's methods return Promise rather than accepting callback although it should be breaking change...
I think we need to define cookieJar interface in this package too. Otherwise, I still need to install @types/tough-cookie every time.
:+1:
Also it would be awesome if the new interface's methods return Promise rather than accepting callback although it should be breaking change...
I agree. Maybe we'll see these promises in Got v11. Let's stay with the callbacks for now.
@szmarczak It would be nice not to be so tied to tough-cookie. We could maybe support both though. Detect whether the input is tough.CookieJar and if not, have a nicer general interface using promises. ?
have a nicer general interface using promises. ?
cookieJar needs to be an object:
interface CookieJar {
getCookieString(url: string, callback: (error: Error, cookieHeader: string) => void);
setCookie(rawCookie: string, url: string, callback: (error: Error, result: unknown) => void);
}
we just need to detect if it's a Promise or is it a callback-style function :)