Skip to main content

ThunderIDExpressClient

ThunderIDExpressClient is the Express-aware client class exported by @thunderid/express. It extends ThunderIDNodeClient and adds Express-specific request and configuration access.

Import

const {ThunderIDExpressClient} = require('@thunderid/express');

Overview

In most applications, you do not instantiate this class directly. The thunderID() middleware creates and initializes it for you, then attaches it to req.thunderIDAuth and res.thunderIDAuth.

Express-Specific Members

expressConfig

Returns the initialized ExpressClientConfig value or undefined if the client has not been initialized yet.

MemberTypeDescription
expressConfigExpressClientConfig | undefinedThe Express SDK configuration used to initialize the client

getUserFromRequest(req)

Reads the session ID from req.cookies[SESSION_COOKIE_NAME] and returns the current user for that session.

getUserFromRequest(req: express.Request): Promise<User | undefined>
index.js
app.get('/me', async (req, res) => {
const user = await req.thunderIDAuth.getUserFromRequest(req);
res.json(user);
});

Inherited Behavior

Because ThunderIDExpressClient extends ThunderIDNodeClient, inherited Node client methods are also available. This Express SDK section does not provide a full reference for the inherited Node surface.

Notes

  • getUserFromRequest(req) depends on req.cookies, so mount cookie-parser before routes that use it
  • signIn() and signOut() are also overridden internally to integrate with Express request and response handling, but this page focuses on the public Express-specific additions
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.