diff --git a/index.d.ts b/index.d.ts index 956ffd1..d399e82 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,8 +1,7 @@ import {Stream} from 'stream'; import {Agent, ClientRequest, IncomingMessage} from 'http'; -import {Url} from 'url'; import * as FormData from 'form-data'; -import * as toughCookie from "tough-cookie"; +import * as toughCookie from 'tough-cookie'; declare var request: request.RequestAPI; @@ -68,7 +67,7 @@ declare namespace request { interface CoreOptions { baseUrl?: string; callback?: (error: any, response: IncomingMessage, body: any) => void; - jar?: CookieJar; + jar?: boolean | CookieJar; formData?: any; // Object form?: any; // Object or string auth?: AuthOptions; @@ -227,8 +226,34 @@ declare namespace request { bucket?: string; } - export type CookieJar = toughCookie.CookieJar; + /** + * Cookies + */ + // Request wraps the `tough-cookies`'s CookieJar in a synchronous RequestJar + // https://github.com/request/request/blob/master/lib/cookies.js export type Cookie = toughCookie.Cookie; + export type CookieStore = toughCookie.Store; + export type SetCookieOptions = toughCookie.SetCookieOptions; + + export interface CookieJar { + // RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) { + // var self = this + // return self._jar.setCookieSync(cookieOrStr, uri, options || {}) + // } + setCookie(cookieOrString: Cookie | string, uri: string, options?: SetCookieOptions): Cookie; + + // RequestJar.prototype.getCookieString = function(uri) { + // var self = this + // return self._jar.getCookieStringSync(uri) + // } + getCookieString(uri: string): string; + + // RequestJar.prototype.getCookies = function(uri) { + // var self = this + // return self._jar.getCookiesSync(uri) + // } + getCookies(uri: string): Cookie[]; + } } export = request;