forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add types for tough-cookie-file-store
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Type definitions for tough-cookie-file-store 1.2 | ||
// Project: https://github.com/ivanmarban/tough-cookie-file-store | ||
// Definitions by: Emily Marigold Klassen <https://github.com/forivall> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.2 | ||
|
||
import tough = require('tough-cookie'); | ||
|
||
export = FileCookieStore; | ||
|
||
declare class FileCookieStore extends tough.Store { | ||
idx: { | ||
[domain: string]: { | ||
[path: string]: { | ||
[key: string]: tough.Cookie | ||
} | ||
} | ||
}; | ||
filePath: string; | ||
synchronous: boolean; | ||
|
||
constructor(filePath: string); | ||
|
||
checkExpired(domain: string | null, path: string | null, key: string | null): boolean; | ||
|
||
findCookie( | ||
domain: string, | ||
path: string, | ||
key: string, | ||
cb: (err: null, cookie: tough.Cookie | null) => void | ||
): void; | ||
|
||
findCookies( | ||
domain: string, | ||
path: string, | ||
cb: (err: null, cookies: tough.Cookie[]) => void | ||
): void; | ||
|
||
getAllCookies(cb: (err: Error | null, cookies: tough.Cookie[]) => void): void; | ||
|
||
inspect(): string; | ||
|
||
isEmpty(): boolean; | ||
|
||
isExpired(): boolean; | ||
|
||
putCookie(cookie: tough.Cookie, cb: (err: Error | null) => void): void; | ||
|
||
removeCookie( | ||
domain: string, | ||
path: string, | ||
key: string, | ||
cb: (err: Error | null) => void | ||
): void; | ||
|
||
removeCookies( | ||
domain: string, | ||
path: string, | ||
cb: (err: Error | null) => void | ||
): void; | ||
|
||
updateCookie( | ||
oldCookie: tough.Cookie, | ||
newCookie: tough.Cookie, | ||
cb: (err: Error | null) => void | ||
): void; | ||
} |
20 changes: 20 additions & 0 deletions
20
types/tough-cookie-file-store/tough-cookie-file-store-tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import CookieStore = require('tough-cookie-file-store'); | ||
import { CookieJar } from 'tough-cookie'; | ||
new CookieJar(new CookieStore('./cookie.json')); | ||
|
||
/* check if cookie is empty or expired */ | ||
const cookieInstance = new CookieStore('./cookie.json'); | ||
cookieInstance.isExpired(); // will return True if the cookie is expired | ||
cookieInstance.isEmpty(); // will return True if cookie is empty | ||
|
||
/* request example */ | ||
/* | ||
// Disabled due to warning in npm test: | ||
// Error: tough-cookie-file-store depends on request but has a lower required TypeScript version. | ||
import * as request from 'request' | ||
var j = request.jar(new CookieStore('./cookie.json')); | ||
const r = request.defaults({ jar : j }) | ||
r('http://www.google.com', function() { | ||
r('http://images.google.com') | ||
}) | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"tough-cookie-file-store-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |