supertokens-node
Version:
NodeJS driver for SuperTokens core
56 lines (55 loc) • 3.54 kB
TypeScript
// @ts-nocheck
import type { BaseRequest, BaseResponse } from "../../framework";
import NormalisedURLPath from "../../normalisedURLPath";
import RecipeModule from "../../recipeModule";
import STError from "../../error";
import { APIHandled, HTTPMethod, NormalisedAppinfo, RecipeListFunction, UserContext } from "../../types";
import { MultiFactorAuthClaimClass } from "./multiFactorAuthClaim";
import { APIInterface, GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc, GetEmailsForFactorFromOtherRecipesFunc, GetFactorsSetupForUserFromOtherRecipesFunc, GetPhoneNumbersForFactorsFromOtherRecipesFunc, RecipeInterface, TypeInput, TypeNormalisedInput } from "./types";
import { User } from "../../user";
import RecipeUserId from "../../recipeUserId";
import { TenantConfig } from "../multitenancy/types";
import type SuperTokens from "../../supertokens";
import { SessionContainerInterface } from "../session/types";
export default class Recipe extends RecipeModule {
private static instance;
multiFactorAuthClaim: MultiFactorAuthClaimClass;
static RECIPE_ID: "multifactorauth";
getFactorsSetupForUserFromOtherRecipesFuncs: GetFactorsSetupForUserFromOtherRecipesFunc[];
getAllAvailableSecondaryFactorIdsFromOtherRecipesFuncs: GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc[];
getEmailsForFactorFromOtherRecipesFunc: GetEmailsForFactorFromOtherRecipesFunc[];
getPhoneNumbersForFactorFromOtherRecipesFunc: GetPhoneNumbersForFactorsFromOtherRecipesFunc[];
isGetMfaRequirementsForAuthOverridden: boolean;
config: TypeNormalisedInput;
recipeInterfaceImpl: RecipeInterface;
apiImpl: APIInterface;
isInServerlessEnv: boolean;
constructor(stInstance: SuperTokens, recipeId: string, appInfo: NormalisedAppinfo, isInServerlessEnv: boolean, config?: TypeInput);
static getInstanceOrThrowError(): Recipe;
static getInstance(): Recipe | undefined;
static init(config?: TypeInput): RecipeListFunction;
static reset(): void;
getAPIsHandled: () => APIHandled[];
handleAPIRequest: (id: string, _tenantId: string, req: BaseRequest, res: BaseResponse, _: NormalisedURLPath, __: HTTPMethod, userContext: UserContext) => Promise<boolean>;
handleError: (err: STError, _: BaseRequest, __: BaseResponse) => Promise<void>;
getAllCORSHeaders: () => string[];
isErrorFromThisRecipe: (err: any) => err is STError;
addFuncToGetAllAvailableSecondaryFactorIdsFromOtherRecipes: (f: GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc) => void;
getAllAvailableSecondaryFactorIds: (tenantConfig: TenantConfig) => string[];
addFuncToGetFactorsSetupForUserFromOtherRecipes: (func: GetFactorsSetupForUserFromOtherRecipesFunc) => void;
addFuncToGetEmailsForFactorFromOtherRecipes: (func: GetEmailsForFactorFromOtherRecipesFunc) => void;
getEmailsForFactors: (user: User, sessionRecipeUserId: RecipeUserId) => {
status: "OK";
factorIdToEmailsMap: Record<string, string[]>;
} | {
status: "UNKNOWN_SESSION_RECIPE_USER_ID";
};
addFuncToGetPhoneNumbersForFactorsFromOtherRecipes: (func: GetPhoneNumbersForFactorsFromOtherRecipesFunc) => void;
getPhoneNumbersForFactors: (user: User, sessionRecipeUserId: RecipeUserId) => {
status: "OK";
factorIdToPhoneNumberMap: Record<string, string[]>;
} | {
status: "UNKNOWN_SESSION_RECIPE_USER_ID";
};
assertAllowedToSetupFactorElseThrowInvalidClaimError(session: SessionContainerInterface, factorId: string, userContext: UserContext): Promise<void>;
}