Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,20 @@ declare namespace fastifySession {
cookiePrefix?: string;
}

export interface CookieOptions extends Omit<CookieSerializeOptions, 'signed' | 'maxAge'> {
export interface CookieOptions extends Omit<CookieSerializeOptions, 'signed' | 'maxAge' | 'httpOnly' | 'secure'> {
/** A `number` in milliseconds that specifies the `Expires` attribute by adding the specified milliseconds to the current date. If both `expires` and `maxAge` are set, then `expires` is used. */
maxAge?: number;
/**
* The `boolean` value of the `HttpOnly` attribute.
* @default true
*/
httpOnly?: boolean;
/**
* The `boolean` value of the `Secure` attribute. Set this option to false when communicating over an unencrypted (HTTP) connection.
* Value can be set to `auto`; in that case the `Secure` attribute is false for HTTP and true for HTTPS.
* @default true
*/
secure?: boolean | 'auto';
}

export class MemoryStore implements fastifySession.SessionStore {
Expand Down
6 changes: 4 additions & 2 deletions types/index.tst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ app.register(plugin, {
}
})

const cookieMaxAge: CookieOptions = {}
const cookieOptions: CookieOptions = {}

expect(cookieMaxAge.maxAge).type.toBe<number | undefined>()
expect(cookieOptions.maxAge).type.toBe<number | undefined>()
expect(cookieOptions.httpOnly).type.toBe<boolean | undefined>()
expect(cookieOptions.secure).type.toBe<boolean | 'auto' | undefined>()

app.register(plugin, {
secret,
Expand Down
Loading