This SDK documentation is outdated. Please do not refer to it, and instead visit the User Guides section.

Skip to main content
Version: 7.1.X

Overriding Functions

Main interface#

interface RecipeInterface {
/*
* Called when you want to create a new session for the given userId.
* The default implementation will set the relevant session headers.
*
* @params: res is the response object
* userId (string value)
* jwtPayload and sessionData are optional
*
* @returns: See the type definition below
*/
createNewSession(input: {
res: Express.Response;
userId: string;
jwtPayload?: any;
sessionData?: any;
}): Promise<SessionContainerInterface>;

/*
* Checks whether an active session is present for the request or not
*
* @params: req is the request object
* res is the response object
* verifySessionOptions will contain two boolean values: to enable/disable
* anti-csrf check and another to state if session requirement is optional
*
* @returns: SessionContainerInterface if active session is present,
* else undefined
*/
getSession(input: {
req: Express.Request;
res: Express.Response;
options?: VerifySessionOptions;
}): Promise<SessionContainerInterface | undefined>;

/*
* Called to refresh a session.
*
* @params: req is the request object
* res is the response object
*
* @returns: See the type definition below
*/
refreshSession(input: { req: Express.Request; res: Express.Response }): Promise<SessionContainerInterface>;

/*
* Called to revoke all the existing sessions for the users
*
* @params: userId (string value)
*
* @returns: All the revoked session handles
*/
revokeAllSessionsForUser(input: { userId: string }): Promise<string[]>;

/*
* Called get all session handles for a user
*
* @params: userId (string value)
*
* @returns: All the session handles
*/
getAllSessionHandlesForUser(input: { userId: string }): Promise<string[]>;

/*
* Called when you want to logout a user and end a session
*
* @params: sessionHandle related to the session you want to revoke
*
* @returns: true if session was revoked, else false
*/
revokeSession(input: { sessionHandle: string }): Promise<boolean>;

/*
* Called when you want to revoke multiple user sessions using session handles
*
* @params: sessionHandles related to the sessions you want to revoke
*
* @returns: All the revoked session handles
*/
revokeMultipleSessions(input: { sessionHandles: string[] }): Promise<string[]>;

/*
* Called to get session data associated with a given session handle
*
* @params: sessionHandle
*
* @returns: session data associated with the session handle
*/
getSessionData(input: { sessionHandle: string }): Promise<any>;

/*
* Called to update the session data associated with a given session handle
*
* @params: sessionHandle
* newSessionData
*/
updateSessionData(input: { sessionHandle: string; newSessionData: any }): Promise<void>;

/*
* Called to get jwt data associated with a given session handle
*
* @params: sessionHandle
*
* @returns: jwt data associated with the session handle
*/
getJWTPayload(input: { sessionHandle: string }): Promise<any>;

/*
* Called to update the jwt data associated with a given session handle
*
* @params: sessionHandle
* newJWTPayload
*/
updateJWTPayload(input: { sessionHandle: string; newJWTPayload: any }): Promise<void>;

/*
* Called to get access token life time in milli-seconds(ms).
*/
getAccessTokenLifeTimeMS(): Promise<number>;

/*
* Called to get refresh token life time in milli-seconds(ms).
*/
getRefreshTokenLifeTimeMS(): Promise<number>;
}
interface SessionContainerInterface {
revokeSession(): Promise<void>;

getSessionData(): Promise<any>;

updateSessionData(newSessionData: any): Promise<any>;

getUserId(): string;

getJWTPayload(): any;

getHandle(): string;

getAccessToken(): string;

updateJWTPayload(newJWTPayload: any): Promise<void>;
}

interface VerifySessionOptions {
antiCsrfCheck?: boolean;
sessionRequired?: boolean;
}
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI