Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: streamline package publishing #453

Merged
merged 19 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(scripts): generate docs to /docs for GitHub Pages
  • Loading branch information
wjhsf committed Sep 9, 2024
commit 8750aef90fa987e9663244cf9c9bf6a41874f3e1
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ yarn add tough-cookie
import { Cookie, CookieJar } from 'tough-cookie'

// parse a `Cookie` request header
const reqCookies = 'ID=298zf09hf012fh2; csrf=u32t4o3tb3gg43; _gat=1'.split(';').map(Cookie.parse)
const reqCookies = 'ID=298zf09hf012fh2; csrf=u32t4o3tb3gg43; _gat=1'
.split(';')
.map(Cookie.parse)
// generate a `Cookie` request header
const cookieHeader = reqCookies.map(cookie => cookie.cookieString()).join(';')
const cookieHeader = reqCookies.map((cookie) => cookie.cookieString()).join(';')

// parse a Set-Cookie response header
const resCookie = Cookie.parse('foo=bar; Domain=example.com; Path=/; Expires=Tue, 21 Oct 2025 00:00:00 GMT')
const resCookie = Cookie.parse(
'foo=bar; Domain=example.com; Path=/; Expires=Tue, 21 Oct 2025 00:00:00 GMT',
)
// generate a Set-Cookie response header
const setCookieHeader = cookie.toString()

Expand All @@ -38,7 +42,7 @@ const matchingCookies = await cookieJar.getCookies('https://example.com/')
```

> [!IMPORTANT]
> For more detailed usage information, refer to the [API docs](./api/docs/tough-cookie.md).
> For more detailed usage information, refer to the [API docs](https://salesforce.github.io/tough-cookie/tough-cookie.md).

## RFC6265bis

Expand All @@ -58,8 +62,14 @@ import { CookieJar } from 'tough-cookie'
const cookieJar = new CookieJar() // uses the in-memory store by default

// storing cookies with various SameSite attributes
await cookieJar.setCookie('strict=authorized; SameSite=strict', 'http://example.com/index.html')
await cookieJar.setCookie('lax=okay; SameSite=lax', 'http://example.com/index.html')
await cookieJar.setCookie(
'strict=authorized; SameSite=strict',
'http://example.com/index.html',
)
await cookieJar.setCookie(
'lax=okay; SameSite=lax',
'http://example.com/index.html',
)
await cookieJar.setCookie('normal=whatever', 'http://example.com/index.html')

// retrieving cookies using a SameSite context
Expand Down Expand Up @@ -105,7 +115,7 @@ You can define this functionality by passing in the `prefixSecurity` option to `
import { CookieJar, MemoryCookieStore } from 'tough-cookie'

const cookieJar = new CookieJar(new MemoryCookieStore(), {
prefixSecurity: 'silent'
prefixSecurity: 'silent',
})

// this cookie will be silently ignored since the url is insecure (http)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@
"scripts": {
"docs": "npm run build && npm run docs:ci",
"docs:ci": "npm run docs:extract -- --local && npm run docs:generate",
"docs:generate": "api-documenter markdown --input-folder ./tmp --output-folder ./api/docs",
"docs:generate": "api-documenter markdown --input-folder ./tmp --output-folder ./docs",
"docs:extract": "api-extractor run --verbose",
"build": "npm run clean && tsc",
"clean": "rm -rf dist",
"version:version-file": "genversion --template version-template.ejs --force lib/version.ts",
"version": "npm run version:version-file && npm run docs && git add ./lib/version.ts ./api/docs",
"version": "npm run version:version-file && npm run docs && git add ./lib/version.ts ./docs",
"test": "npm run test:ts && npm run test:legacy",
"test:ts": "jest",
"test:legacy": "npm run build -- --declaration false && ./test/scripts/vows.js test/*_test.js",
Expand Down