Skip to content

Commit

Permalink
Document Cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
colincasey committed Apr 22, 2024
1 parent 5022c19 commit 55387ef
Show file tree
Hide file tree
Showing 41 changed files with 1,723 additions and 94 deletions.
6 changes: 6 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ docs/*.md

# subsequent PRs will un-ignore areas that are under review until
# all docs are complete and we can drop this ignore file entirely
!docs/tough-cookie.cookie.md
!docs/tough-cookie.cookie.*.md
!docs/tough-cookie.createcookieoptions.md
!docs/tough-cookie.parsecookieoptions.md
!docs/tough-cookie.parsecookieoptions.loose.md
!docs/tough-cookie.serializedcookie.md
!docs/tough-cookie.prefixsecurity.md
!docs/tough-cookie.md
!docs/tough-cookie.store.md
Expand Down
49 changes: 49 additions & 0 deletions api/docs/tough-cookie.cookie._constructor_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [(constructor)](./tough-cookie.cookie._constructor_.md)

## Cookie.(constructor)

Create a new Cookie instance.

**Signature:**

```typescript
constructor(options?: CreateCookieOptions);
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

options


</td><td>

CreateCookieOptions


</td><td>

_(Optional)_ The attributes to set on the cookie


</td></tr>
</tbody></table>
17 changes: 17 additions & 0 deletions api/docs/tough-cookie.cookie.canonicalizeddomain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [canonicalizedDomain](./tough-cookie.cookie.canonicalizeddomain.md)

## Cookie.canonicalizedDomain() method

Calls [canonicalDomain()](./tough-cookie.canonicaldomain.md) with the [Cookie.domain](./tough-cookie.cookie.domain.md) property.

**Signature:**

```typescript
canonicalizedDomain(): string | undefined;
```
**Returns:**

string \| undefined

17 changes: 17 additions & 0 deletions api/docs/tough-cookie.cookie.cdomain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [cdomain](./tough-cookie.cookie.cdomain.md)

## Cookie.cdomain() method

Alias for [Cookie.canonicalizedDomain()](./tough-cookie.cookie.canonicalizeddomain.md)

**Signature:**

```typescript
cdomain(): string | undefined;
```
**Returns:**

string \| undefined

17 changes: 17 additions & 0 deletions api/docs/tough-cookie.cookie.clone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [clone](./tough-cookie.cookie.clone.md)

## Cookie.clone() method

Does a deep clone of this cookie, implemented exactly as `Cookie.fromJSON(cookie.toJSON())`<!-- -->.

**Signature:**

```typescript
clone(): Cookie | undefined;
```
**Returns:**

[Cookie](./tough-cookie.cookie.md) \| undefined

17 changes: 17 additions & 0 deletions api/docs/tough-cookie.cookie.cookiestring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [cookieString](./tough-cookie.cookie.cookiestring.md)

## Cookie.cookieString() method

Encodes to a `Cookie` header value (specifically, the [Cookie.key](./tough-cookie.cookie.key.md) and [Cookie.value](./tough-cookie.cookie.value.md) properties joined with "=").

**Signature:**

```typescript
cookieString(): string;
```
**Returns:**

string

15 changes: 15 additions & 0 deletions api/docs/tough-cookie.cookie.creation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [creation](./tough-cookie.cookie.creation.md)

## Cookie.creation property

Set to the date and time when a Cookie is initially stored or a matching cookie is received that replaces an existing cookie (See [RFC6265 Section 5.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.3)<!-- -->).

Also used to maintain ordering among cookies. Among cookies that have equal-length path fields, cookies with earlier creation-times are listed before cookies with later creation-times (See [RFC6265 Section 5.4](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.4)<!-- -->).

**Signature:**

```typescript
creation: Date | 'Infinity' | null;
```
13 changes: 13 additions & 0 deletions api/docs/tough-cookie.cookie.creationindex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [creationIndex](./tough-cookie.cookie.creationindex.md)

## Cookie.creationIndex property

A global counter used to break ordering ties between two cookies that have equal-length path fields and the same creation-time.

**Signature:**

```typescript
creationIndex: number;
```
13 changes: 13 additions & 0 deletions api/docs/tough-cookie.cookie.domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [domain](./tough-cookie.cookie.domain.md)

## Cookie.domain property

The 'Domain' attribute of the cookie represents the domain the cookie belongs to (See [RFC6265 Section 5.2.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.3)<!-- -->).

**Signature:**

```typescript
domain: string | null;
```
13 changes: 13 additions & 0 deletions api/docs/tough-cookie.cookie.expires.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [expires](./tough-cookie.cookie.expires.md)

## Cookie.expires property

The 'Expires' attribute of the cookie (See [RFC6265 Section 5.2.1](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.1)<!-- -->).

**Signature:**

```typescript
expires: Date | 'Infinity' | null;
```
57 changes: 57 additions & 0 deletions api/docs/tough-cookie.cookie.expirytime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [expiryTime](./tough-cookie.cookie.expirytime.md)

## Cookie.expiryTime() method

Computes the absolute unix-epoch milliseconds that this cookie expires.

The "Max-Age" attribute takes precedence over "Expires" (as per the RFC). The [Cookie.lastAccessed](./tough-cookie.cookie.lastaccessed.md) attribute (or the `now` parameter if given) is used to offset the [Cookie.maxAge](./tough-cookie.cookie.maxage.md) attribute.

If Expires ([Cookie.expires](./tough-cookie.cookie.expires.md)<!-- -->) is set, that's returned.

**Signature:**

```typescript
expiryTime(now?: Date): number | undefined;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

now


</td><td>

Date


</td><td>

_(Optional)_ can be used to provide a time offset (instead of [Cookie.lastAccessed](./tough-cookie.cookie.lastaccessed.md)<!-- -->) to use when calculating the "Max-Age" value


</td></tr>
</tbody></table>
**Returns:**

number \| undefined

13 changes: 13 additions & 0 deletions api/docs/tough-cookie.cookie.extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [extensions](./tough-cookie.cookie.extensions.md)

## Cookie.extensions property

Contains attributes which are not part of the defined spec but match the `extension-av` syntax defined in Section 4.1.1 of RFC6265 (See [RFC6265 Section 4.1.1](https://www.rfc-editor.org/rfc/rfc6265.html#section-4.1.1)<!-- -->).

**Signature:**

```typescript
extensions: string[] | null;
```
76 changes: 76 additions & 0 deletions api/docs/tough-cookie.cookie.fromjson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [fromJSON](./tough-cookie.cookie.fromjson.md)

## Cookie.fromJSON() method

Does the reverse of [Cookie.toJSON()](./tough-cookie.cookie.tojson.md)<!-- -->.

**Signature:**

```typescript
static fromJSON(str: unknown): Cookie | undefined;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

str


</td><td>

unknown


</td><td>

An unparsed JSON string or a value that has already been parsed as JSON


</td></tr>
</tbody></table>
**Returns:**

[Cookie](./tough-cookie.cookie.md) \| undefined

## Remarks

Any Date properties (such as .expires, .creation, and .lastAccessed) are parsed via Date.parse, not tough-cookie's parseDate, since ISO timestamps are being handled at this layer.

## Example


```
const json = JSON.stringify({
key: 'alpha',
value: 'beta',
domain: 'example.com',
path: '/foo',
expires: '2038-01-19T03:14:07.000Z',
})
const cookie = Cookie.fromJSON(json)
cookie.key === 'alpha'
cookie.value === 'beta'
cookie.domain === 'example.com'
cookie.path === '/foo'
cookie.expires === new Date(Date.parse('2038-01-19T03:14:07.000Z'))
```

13 changes: 13 additions & 0 deletions api/docs/tough-cookie.cookie.hostonly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [hostOnly](./tough-cookie.cookie.hostonly.md)

## Cookie.hostOnly property

A boolean flag indicating if a cookie is a host-only cookie (i.e.; when the request's host exactly matches the domain of the cookie) or not (See [RFC6265 Section 5.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.3)<!-- -->).

**Signature:**

```typescript
hostOnly: boolean | null;
```
13 changes: 13 additions & 0 deletions api/docs/tough-cookie.cookie.httponly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [httpOnly](./tough-cookie.cookie.httponly.md)

## Cookie.httpOnly property

The 'HttpOnly' flag of the cookie indicates if the cookie is inaccessible to client scripts or not (See [RFC6265 Section 5.2.6](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.6)<!-- -->).

**Signature:**

```typescript
httpOnly: boolean;
```
17 changes: 17 additions & 0 deletions api/docs/tough-cookie.cookie.ispersistent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [tough-cookie](./tough-cookie.md) &gt; [Cookie](./tough-cookie.cookie.md) &gt; [isPersistent](./tough-cookie.cookie.ispersistent.md)

## Cookie.isPersistent() method

Indicates if the cookie has been persisted to a store or not.

**Signature:**

```typescript
isPersistent(): boolean;
```
**Returns:**

boolean

Loading

0 comments on commit 55387ef

Please sign in to comment.