supertokens-node
Version:
NodeJS driver for SuperTokens core
161 lines (160 loc) • 4.4 kB
TypeScript
import { Request, Response, NextFunction } from "express";
import Session from "./sessionClass";
import NormalisedURLPath from "../../normalisedURLPath";
export declare type HandshakeInfo = {
jwtSigningPublicKey: string;
enableAntiCsrf: boolean;
accessTokenBlacklistingEnabled: boolean;
jwtSigningPublicKeyExpiryTime: number;
accessTokenValidity: number;
refreshTokenValidity: number;
};
export declare type CreateOrRefreshAPIResponse = {
session: {
handle: string;
userId: string;
userDataInJWT: any;
};
accessToken: {
token: string;
expiry: number;
createdTime: number;
};
refreshToken: {
token: string;
expiry: number;
createdTime: number;
};
idRefreshToken: {
token: string;
expiry: number;
createdTime: number;
};
antiCsrfToken: string | undefined;
};
export declare const InputSchemaErrorHandlers: {
type: string;
properties: {
onUnauthorised: {
type: string;
};
onTokenTheftDetected: {
type: string;
};
};
additionalProperties: boolean;
};
export interface ErrorHandlers {
onUnauthorised?: ErrorHandlerMiddleware;
onTokenTheftDetected?: TokenTheftErrorHandlerMiddleware;
}
export declare type TypeInput = {
cookieSecure?: boolean;
cookieSameSite?: "strict" | "lax" | "none";
sessionExpiredStatusCode?: number;
cookieDomain?: string;
sessionRefreshFeature?: {
disableDefaultImplementation?: boolean;
};
signOutFeature?: {
disableDefaultImplementation?: boolean;
};
errorHandlers?: ErrorHandlers;
enableAntiCsrf?: boolean;
};
export declare const InputSchema: {
type: string;
properties: {
cookieSecure: {
type: string;
};
cookieSameSite: {
type: string;
};
sessionExpiredStatusCode: {
type: string;
};
cookieDomain: {
type: string;
};
sessionRefreshFeature: {
type: string;
properties: {
disableDefaultImplementation: {
type: string;
};
};
additionalProperties: boolean;
};
signOutFeature: {
type: string;
properties: {
disableDefaultImplementation: {
type: string;
};
};
additionalProperties: boolean;
};
errorHandlers: {
type: string;
properties: {
onUnauthorised: {
type: string;
};
onTokenTheftDetected: {
type: string;
};
};
additionalProperties: boolean;
};
enableAntiCsrf: {
type: string;
};
faunadbSecret: {
type: string;
};
userCollectionName: {
type: string;
};
accessFaunadbTokenFromFrontend: {
type: string;
};
faunadbClient: {
type: string;
};
};
additionalProperties: boolean;
};
export declare type TypeNormalisedInput = {
refreshTokenPath: NormalisedURLPath;
cookieDomain: string | undefined;
cookieSameSite: "strict" | "lax" | "none";
cookieSecure: boolean;
sessionExpiredStatusCode: number;
sessionRefreshFeature: {
disableDefaultImplementation: boolean;
};
signOutFeature: {
disableDefaultImplementation: boolean;
};
errorHandlers: NormalisedErrorHandlers;
enableAntiCsrf: boolean;
};
export interface SessionRequest extends Request {
session?: Session;
}
export interface ErrorHandlerMiddleware {
(message: string, request: Request, response: Response, next: NextFunction): void;
}
export interface TokenTheftErrorHandlerMiddleware {
(sessionHandle: string, userId: string, request: Request, response: Response, next: NextFunction): void;
}
export interface NormalisedErrorHandlers {
onUnauthorised: ErrorHandlerMiddleware;
onTryRefreshToken: ErrorHandlerMiddleware;
onTokenTheftDetected: TokenTheftErrorHandlerMiddleware;
}
export interface VerifySessionOptions {
antiCsrfCheck?: boolean;
sessionRequired?: boolean;
}