mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
cookie-session: Adds Keygrip to allowed types for the cookie-session keys property (#34645)
* Adds Keygrip type to keys in type. * Adds test for keygrip type in cookie-session * Adds small changes to cookie-sessions types. * Reverts formatting because it was bloating the diff. * Adds name to definitions-by section. * Updates TypeScript version in header to allow imports of external types.
This commit is contained in:
parent
e7edaf621a
commit
d35eda0100
@ -2,6 +2,7 @@
|
||||
|
||||
import express = require('express');
|
||||
import cookieSession = require('cookie-session');
|
||||
import Keygrip = require('keygrip');
|
||||
|
||||
var app = express()
|
||||
|
||||
@ -36,4 +37,15 @@ app2.use(cookieSession({
|
||||
// have a different value than the default.
|
||||
app2.use(function (req, res, next) {
|
||||
req.sessionOptions.maxAge = req.session['maxAge'] || req.sessionOptions.maxAge
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var app3 = express()
|
||||
|
||||
app3.set('trust proxy', 1) // trust first proxy
|
||||
|
||||
// a Keygrip object may be used instead of an array of keys.
|
||||
app3.use(cookieSession({
|
||||
name: 'session',
|
||||
keys: Keygrip(['key1', 'key2'])
|
||||
}));
|
||||
7
types/cookie-session/index.d.ts
vendored
7
types/cookie-session/index.d.ts
vendored
@ -1,10 +1,11 @@
|
||||
// Type definitions for cookie-session 2.0
|
||||
// Project: https://github.com/expressjs/cookie-session
|
||||
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov>
|
||||
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov>, Jason Cordial <https://github.com/btomw>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
/// <reference types="express" />
|
||||
/// <reference types="keygrip" />
|
||||
|
||||
declare namespace Express {
|
||||
interface Request extends CookieSessionInterfaces.CookieSessionRequest {}
|
||||
@ -20,7 +21,7 @@ declare namespace CookieSessionInterfaces {
|
||||
/**
|
||||
* The list of keys to use to sign & verify cookie values. Set cookies are always signed with keys[0], while the other keys are valid for verification, allowing for key rotation.
|
||||
*/
|
||||
keys?: Array<string>;
|
||||
keys?: Array<string> | import('keygrip');
|
||||
|
||||
/**
|
||||
* A string which will be used as single key if keys is not provided.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user