1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export class CookieAccessInfo {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | constructor(domain: string, path?: string, secure?: boolean, script?: boolean);
|
16 |
|
17 | static All: CookieAccessInfo;
|
18 | domain: string; // domain to match
|
19 | path: string; // path to match
|
20 | secure: boolean; // access is secure (ssl generally)
|
21 | script: boolean; // access is from a script
|
22 | }
|
23 |
|
24 | export class Cookie {
|
25 | name: string;
|
26 | value: string;
|
27 | domain: string;
|
28 | explicit_domain: boolean;
|
29 | path: string;
|
30 | explicit_path: boolean;
|
31 | noscript: boolean;
|
32 | secure: boolean;
|
33 | expiration_date: number;
|
34 |
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | constructor(cookie: string | Cookie, requestDomain?: string, requestPath?: string);
|
48 |
|
49 | /**
|
50 | * the set-cookie: string for this cookie
|
51 | */
|
52 | toString(): string;
|
53 |
|
54 | /**
|
55 | * the cookie: string for this cookie
|
56 | */
|
57 | toValueString(): string;
|
58 |
|
59 | /**
|
60 | * parses the string onto this cookie or a new one if called directly
|
61 | * @param cookie string to be parsed into a Cookie
|
62 | * @param requestDomain string definind the requesting domain
|
63 | * @param requestPath string defining the requesting path
|
64 | */
|
65 | parse(cookie: string, requestDomain?: string, requestPath?: string): Cookie;
|
66 |
|
67 | /**
|
68 | * returns true if the access_info allows retrieval of this cookie
|
69 | * @param accessInfo CookieAccessInfo
|
70 | */
|
71 | matches(accessInfo: CookieAccessInfo): boolean;
|
72 |
|
73 | /**
|
74 | * returns true if the cookies cannot exist in the same space
|
75 | * (domain and path match)
|
76 | * @param cookie Cookie
|
77 | */
|
78 | collidesWith(cookie: Cookie): boolean;
|
79 | }
|
80 |
|
81 | export class CookieJar {
|
82 | |
83 |
|
84 |
|
85 | constructor();
|
86 |
|
87 | /**
|
88 | * modify (or add if not already-existing) a cookie to the jar
|
89 | * @param cookie string | Cookie
|
90 | * @param requestDomain string argument is used to default the domain if it is not explicit in the cookie string
|
91 | * @param requestPath string argument is used to set the path if it is not explicit in a cookie String
|
92 | */
|
93 | setCookie(cookie: string | Cookie, requestDomain?: string, requestPath?: string): Cookie | false;
|
94 |
|
95 | /**
|
96 | * modify (or add if not already-existing) a large number of cookies to the
|
97 | * jar
|
98 | * @param cookie string or list of strings defining cookies
|
99 | * @param requestDomain string argument is used to default the domain if it is not explicit in the cookie string
|
100 | * @param requestPath string argument is used to set the path if it is not explicit in a cookie String
|
101 | */
|
102 | setCookies(cookie: string | ReadonlyArray<string>, requestDomain?: string, requestPath?: string): Cookie[];
|
103 |
|
104 | /**
|
105 | * get a cookie with the name and access_info matching
|
106 | * @param cookieName string to be parsed into a Cookie
|
107 | * @param accessInfo CookieAccessInfo
|
108 | */
|
109 | getCookie(cookieName: string, accessInfo: CookieAccessInfo): Cookie | undefined;
|
110 |
|
111 | /**
|
112 | * grab all cookies matching this access_info
|
113 | * @param accessInfo CookieAccessInfo
|
114 | */
|
115 | getCookies(accessInfo: CookieAccessInfo): ReadonlyArray<Cookie> & { toValueString(): string };
|
116 | }
|