Skip to content

Commit 179a67f

Browse files
🤖 Merge PR DefinitelyTyped#74864 [express-session] Update cookie option to accept a function for v1.19.0 by @lincond
Co-authored-by: Ravi van Rooijen <ravivanrooijen@live.nl>
1 parent f2fe721 commit 179a67f

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎types/express-session/express-session-tests.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ app.use(
7373
}),
7474
);
7575

76+
app.use(
77+
session({
78+
secret: "keyboard cat",
79+
cookie: (req) => ({ secure: req.secure }),
80+
}),
81+
);
82+
7683
// Various `crypto.CipherKey` types
7784
app.use(session({ secret: Buffer.from("keyboard cat", "utf8") }));
7885
app.use(session({ secret: crypto.createSecretKey(Buffer.from("keyboard cat", "utf8")) }));

‎types/express-session/index.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ declare namespace session {
8585
store?: Store | undefined;
8686

8787
/**
88-
* Settings object for the session ID cookie.
88+
* Settings object for the session ID cookie, or a callback that dynamically generates it based on the incoming request.
8989
* @see CookieOptions
9090
*/
91-
cookie?: CookieOptions | undefined;
91+
cookie?: CookieOptions | ((req: express.Request) => CookieOptions) | undefined;
9292

9393
/**
9494
* Force the session identifier cookie to be set on every response. The expiration is reset to the original `maxAge`, resetting the expiration countdown.

‎types/express-session/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/express-session",
4-
"version": "1.18.9999",
4+
"version": "1.19.9999",
55
"projects": [
66
"https://github.com/expressjs/session"
77
],

0 commit comments

Comments
 (0)