mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* @types/cookie - Add 'none' as a valid value for sameSite of the CookieSerializeOptions * @types/cookie - Add documentation for 'none' SameSite option
35 lines
939 B
TypeScript
35 lines
939 B
TypeScript
import cookie = require('cookie');
|
|
|
|
function test_serialize(): void {
|
|
let retVal: string;
|
|
|
|
retVal = cookie.serialize('foo', 'bar');
|
|
retVal = cookie.serialize('foo', 'bar', { httpOnly: true });
|
|
retVal = cookie.serialize('foo', 'bar', { sameSite: 'none' });
|
|
retVal = cookie.serialize('foo', 'bar', { sameSite: 'lax' });
|
|
}
|
|
|
|
function test_parse(): void {
|
|
let retVal: { [key: string]: string };
|
|
|
|
retVal = cookie.parse('foo=bar; bar=baz;');
|
|
retVal = cookie.parse('foo=bar; bar=baz', { decode: x => x });
|
|
}
|
|
|
|
function test_options(): void {
|
|
const serializeOptions: cookie.CookieSerializeOptions = {
|
|
encode: (x: string) => x,
|
|
path: '/',
|
|
expires: new Date(),
|
|
maxAge: 200,
|
|
domain: 'example.com',
|
|
secure: false,
|
|
httpOnly: false,
|
|
sameSite: 'strict'
|
|
};
|
|
|
|
const parseOptios: cookie.CookieParseOptions = {
|
|
decode: (x: string) => x
|
|
};
|
|
}
|