iron-session
Advanced tools
Comparing version 8.0.2 to 8.0.3
@@ -112,5 +112,5 @@ import * as http from 'http'; | ||
<T extends object>(cookies: CookieStore, sessionOptions: SessionOptions): Promise<IronSession<T>>; | ||
<T_1 extends object>(req: http.IncomingMessage | Request, res: Response | http.ServerResponse<http.IncomingMessage>, sessionOptions: SessionOptions): Promise<IronSession<T_1>>; | ||
<T extends object>(req: http.IncomingMessage | Request, res: Response | http.ServerResponse<http.IncomingMessage>, sessionOptions: SessionOptions): Promise<IronSession<T>>; | ||
}; | ||
export { type IronSession, type SessionOptions, getIronSession, sealData, unsealData }; |
@@ -270,3 +270,3 @@ import { serialize, parse } from 'cookie'; | ||
export { getIronSession, sealData, unsealData }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "iron-session", | ||
"version": "8.0.2", | ||
"version": "8.0.3", | ||
"description": "Secure, stateless, and cookie-based session library for JavaScript", | ||
@@ -46,5 +46,5 @@ "keywords": [ | ||
"@types/cookie": "0.6.0", | ||
"@types/node": "20.14.2", | ||
"@typescript-eslint/eslint-plugin": "7.13.0", | ||
"@typescript-eslint/parser": "7.13.0", | ||
"@types/node": "20.16.1", | ||
"@typescript-eslint/eslint-plugin": "7.18.0", | ||
"@typescript-eslint/parser": "7.18.0", | ||
"c8": "10.1.2", | ||
@@ -57,9 +57,10 @@ "concurrently": "8.2.2", | ||
"eslint-plugin-import": "2.29.1", | ||
"eslint-plugin-prettier": "5.1.3", | ||
"prettier": "3.3.2", | ||
"prettier-plugin-packagejson": "2.5.0", | ||
"publint": "0.2.8", | ||
"tsup": "8.1.0", | ||
"tsx": "4.15.4", | ||
"typescript": "5.4.5" | ||
"eslint-plugin-prettier": "5.2.1", | ||
"prettier": "3.3.3", | ||
"prettier-plugin-packagejson": "2.5.1", | ||
"publint": "0.2.10", | ||
"tsup": "8.2.4", | ||
"tsx": "4.17.0", | ||
"turbo": "^2.0.5", | ||
"typescript": "5.5.4" | ||
}, | ||
@@ -66,0 +67,0 @@ "publishConfig": { |
@@ -9,13 +9,14 @@ # iron-session ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/vvo/iron-session/ci.yaml) [![GitHub license](https://img.shields.io/github/license/vvo/iron-session?style=flat)](https://github.com/vvo/iron-session/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/iron-session)](https://www.npmjs.com/package/iron-session) ![npm](https://img.shields.io/npm/dm/iron-session) ![npm package minimized gzipped size (select exports)](https://img.shields.io/bundlejs/size/iron-session?exports=getIronSession) | ||
<div align="center"> | ||
<a href="https://stytch.com?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=logo&utm_campaign=iron-session"> | ||
<a href="https://clerk.com"> | ||
<picture> | ||
<source width="200px" media="(prefers-color-scheme: dark)" srcset="./sponsor/stytch_white.svg'> | ||
<source width="200px" media="(prefers-color-scheme: light)" srcset="./sponsor/stytch_charcoal.svg"> | ||
<img width="200px" src="./sponsor/stytch_charcoal.svg" /> | ||
<source width="200px" media="(prefers-color-scheme: dark)" srcset="./sponsor/clerk-light.svg"> | ||
<source width="200px" media="(prefers-color-scheme: light)" srcset="./sponsor/clerk-dark.svg"> | ||
<img width="200px" src="./sponsor/clerk-dark.svg" /> | ||
</picture> | ||
</a> | ||
<p align="center">API-first authentication, authorization, and fraud prevention</p> | ||
<p align="center">Clerk is a complete suite of embeddable UIs, flexible APIs, and admin dashboards to authenticate and manage your users.</p> | ||
<p align="center"> | ||
<a href="https://stytch.com?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=website-link&utm_campaign=iron-session"><b>Website</b></a> • | ||
<a href="https://stytch.com/docs?utm_source=oss-sponsorship&utm_medium=paid_sponsorship&utm_content=docs-link&utm_campaign=iron-session"><b>Documentation</b></a> | ||
<a href="https://go.clerk.com/198WZf0"> | ||
<b>Add authentication in 7 minutes 👉</b> | ||
</a> | ||
</p> | ||
@@ -64,2 +65,4 @@ </div> | ||
*We have extensive examples here too: https://get-iron-session.vercel.app/.* | ||
To get a session, there's a single method to know: `getIronSession`. | ||
@@ -71,8 +74,9 @@ | ||
export function get(req, res) { | ||
const session = getIronSession(req, res, { password: "...", cookieName: "..." }); | ||
export async function get(req, res) { | ||
const session = await getIronSession(req, res, { password: "...", cookieName: "..." }); | ||
return session; | ||
} | ||
export function post(req, res) { | ||
const session = getIronSession(req, res, { password: "...", cookieName: "..." }); | ||
export async function post(req, res) { | ||
const session = await getIronSession(req, res, { password: "...", cookieName: "..." }); | ||
session.username = "Alison"; | ||
@@ -88,8 +92,9 @@ await session.save(); | ||
export function GET() { | ||
const session = getIronSession(cookies(), { password: "...", cookieName: "..." }); | ||
export async function GET() { | ||
const session = await getIronSession(cookies(), { password: "...", cookieName: "..." }); | ||
return session; | ||
} | ||
export function POST() { | ||
const session = getIronSession(cookies(), { password: "...", cookieName: "..." }); | ||
export async function POST() { | ||
const session = await getIronSession(cookies(), { password: "...", cookieName: "..." }); | ||
session.username = "Alison"; | ||
@@ -107,5 +112,6 @@ await session.save(); | ||
const session = await getIronSession(cookies(), { password: "...", cookieName: "..." }); | ||
return session | ||
} | ||
function Profile() { | ||
async function Profile() { | ||
const session = await getIronSessionData(); | ||
@@ -129,3 +135,3 @@ | ||
- `password`, **required**: Private key used to encrypt the cookie. It has to be at least 32 characters long. Use <https://1password.com/password-generator/> to generate strong passwords. `password` can be either a `string` or an `array` of objects like this: `[{id: 2, password: "..."}, {id: 1, password: "..."}]` to allow for password rotation. | ||
- `password`, **required**: Private key used to encrypt the cookie. It has to be at least 32 characters long. Use <https://1password.com/password-generator/> to generate strong passwords. `password` can be either a `string` or an `object` with incrementing keys like this: `{2: "...", 1: "..."}` to allow for password rotation. iron-session will use the highest numbered key for new cookies. | ||
- `cookieName`, **required**: Name of the cookie to be stored | ||
@@ -150,3 +156,7 @@ - `ttl`, _optional_: In seconds. Default to the equivalent of 14 days. You can set this to `0` and iron-session will compute the maximum allowed value by cookies. | ||
```ts | ||
const session = getIronSession<SessionData>(req, res, sessionOptions); | ||
type SessionData = { | ||
// Your data | ||
} | ||
const session = await getIronSession<SessionData>(req, res, sessionOptions); | ||
``` | ||
@@ -157,3 +167,7 @@ | ||
```ts | ||
const session = getIronSession<SessionData>(cookies(), sessionOptions); | ||
type SessionData = { | ||
// Your data | ||
} | ||
const session = await getIronSession<SessionData>(cookies(), sessionOptions); | ||
``` | ||
@@ -160,0 +174,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90011
243
19