Updated express-session types (#40314)

- Allow `secure: 'auto'` cookie setting
- Restrict `sameSite` cookie setting to boolean or valid string value
  according to (draft) spec
This commit is contained in:
Tom Spencer
2019-11-18 14:13:48 -08:00
committed by Sheetal Nandi
parent 779fdbf9df
commit aa52de569b
2 changed files with 28 additions and 1 deletions
@@ -7,6 +7,22 @@ app.use(session({
secret: 'keyboard cat',
cookie: { secure: true }
}));
app.use(session({
secret: 'keyboard cat',
cookie: { secure: 'auto' }
}));
app.use(session({
secret: 'keyboard cat',
cookie: { sameSite: 'none' }
}));
app.use(session({
secret: 'keyboard cat',
cookie: { sameSite: 'lax' }
}));
app.use(session({
secret: 'keyboard cat',
cookie: { sameSite: 'strict' }
}));
app.use(session({
secret: 'keyboard cat',
name: 'connect.sid',
+12 -1
View File
@@ -4,6 +4,7 @@
// Jacob Bogers <https://github.com/jacobbogers>
// Naoto Yokoyama <https://github.com/builtinnya>
// Ryan Cannon <https://github.com/ry7n>
// Tom Spencer <https://github.com/fiznool>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -58,7 +59,17 @@ declare namespace session {
secret: string | string[];
name?: string;
store?: Store | MemoryStore;
cookie?: express.CookieOptions;
cookie?: {
maxAge?: number;
signed?: boolean;
expires?: Date;
httpOnly?: boolean;
path?: string;
domain?: string;
secure?: boolean | 'auto';
encode?: (val: string) => string;
sameSite?: boolean | 'lax' | 'strict' | 'none';
};
genid?(req: express.Request): string;
rolling?: boolean;
resave?: boolean;