# @types/client-sessions

> TypeScript definitions for client-sessions

Latest version **0.8.7** (published 2025-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/client-sessions
pnpm add @types/client-sessions
yarn add @types/client-sessions
bun add @types/client-sessions
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.8.7 |
| Published | 2025-10-24 |
| First published | 2017-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51475 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/client-sessions
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/client-sessions
- npm.io page: https://npm.io/package/@types/client-sessions

## Dependencies (2)

- [@types/node](https://npm.io/package/@types/node.md) *
- [@types/cookies](https://npm.io/package/@types/cookies.md) *

## Recent versions

- 0.8.7 (latest) — 2025-10-24
- 0.8.6 (ts5.1) — 2023-11-07
- 0.8.4 (ts4.3) — 2023-09-04
- 0.8.3 (ts4.2) — 2021-07-08
- 0.8.1 (ts3.5) — 2021-05-19
- 0.8.0 (ts2.4) — 2017-08-15
- 0.8.5 — 2023-10-17
- 0.8.2 — 2021-05-28

## README

# Installation
> `npm install --save @types/client-sessions`

# Summary
This package contains type definitions for client-sessions (https://github.com/mozilla/node-client-sessions).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/client-sessions.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/client-sessions/index.d.ts)
````ts
/// <reference types="node" />

import cookies = require("cookies");

interface CookieOptions extends cookies.IOptions {
    /**
     * a boolean indicating whether the cookie will expire when browser closes or not
     * (false by default).
     */
    ephemeral?: boolean | undefined;
}

declare namespace client_sessions {
    type NextFunction = (err?: Error) => void;
    type RequestHandler = (req: any, res: any, next: NextFunction) => any;

    interface SessionOptions {
        /**
         * encryption secret for the session.
         * required
         */
        secret: string;

        /**
         * session cookie name.
         * Default: 'session_state'
         */
        cookieName?: string | undefined;

        /**
         * how long the session will stay valid in ms.
         * Default: 24 hours
         */
        duration?: number | undefined;

        /**
         * if expiresIn < activeDuration, the session will be extended by activeDuration milliseconds.
         * Default: 5 minutes
         */
        activeDuration?: number | undefined;

        /**
         * session accessor on the request object.
         * Default: 'session'
         */
        requestKey?: string | undefined;

        cookie?: CookieOptions | undefined;
    }

    interface DecodeResult {
        content: any;
        createdAt: number;
        duration: number;
    }

    interface ComputeHmacOptions {
        signatureAlgorithm: string;
        signatureKey: Buffer;
    }

    interface Util {
        computeHmac(options: any, iv: string, ciphertext: string, duration: number, createdAt: number): Buffer;
        encode(options: SessionOptions, content: any, duration?: number, createdAt?: number): string;
        decode(options: SessionOptions, encoded: string): DecodeResult;
    }

    interface Sessions {
        (options: SessionOptions): RequestHandler;
        util: Util;
    }
}

declare var client_sessions: client_sessions.Sessions;
export = client_sessions;
export as namespace client_sessions;

````

### Additional Details
 * Last updated: Fri, 24 Oct 2025 04:02:41 GMT
 * Dependencies: [@types/cookies](https://npmjs.com/package/@types/cookies), [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Aditya](https://github.com/netroy), and [Ankit Malik](https://github.com/DiabolusGX).

---
_Source: https://npm.io/package/@types/client-sessions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
