diff --git a/lib/build/framework/fastify/index.d.ts b/lib/build/framework/fastify/index.d.ts
index 3cca3a1a2..fb2d3fe21 100644
--- a/lib/build/framework/fastify/index.d.ts
+++ b/lib/build/framework/fastify/index.d.ts
@@ -1,18 +1,21 @@
// @ts-nocheck
///
export type { SessionRequest } from "./framework";
-export declare const plugin: import("fastify").FastifyPluginCallback, import("http").Server>;
+export declare const plugin: import("fastify").FastifyPluginCallback<
+ Record,
+ import("fastify").RawServerDefault
+>;
export declare const errorHandler: () => (
err: any,
req: import("fastify").FastifyRequest<
import("fastify/types/route").RouteGenericInterface,
- import("http").Server,
+ import("fastify").RawServerDefault,
import("http").IncomingMessage
>,
res: import("fastify").FastifyReply<
- import("http").Server,
+ import("fastify").RawServerDefault,
import("http").IncomingMessage,
- import("http").ServerResponse,
+ import("http").ServerResponse,
import("fastify/types/route").RouteGenericInterface,
unknown
>
diff --git a/lib/build/framework/utils.d.ts b/lib/build/framework/utils.d.ts
index 636a97724..123ddf23c 100644
--- a/lib/build/framework/utils.d.ts
+++ b/lib/build/framework/utils.d.ts
@@ -45,7 +45,7 @@ export declare function setCookieForServerResponse(
expires: number,
path: string,
sameSite: "strict" | "lax" | "none"
-): ServerResponse;
+): ServerResponse;
export declare function getCookieValueToSetInHeader(
prev: string | string[] | undefined,
val: string | string[],
diff --git a/lib/build/recipe/multifactorauth/index.d.ts b/lib/build/recipe/multifactorauth/index.d.ts
index a0313fac7..e9e186b03 100644
--- a/lib/build/recipe/multifactorauth/index.d.ts
+++ b/lib/build/recipe/multifactorauth/index.d.ts
@@ -7,6 +7,7 @@ export default class Wrapper {
static init: typeof Recipe.init;
static MultiFactorAuthClaim: import("./multiFactorAuthClaim").MultiFactorAuthClaimClass;
static enableFactorForUser(
+ tenantId: string,
userId: string,
factorId: string,
userContext?: any
diff --git a/lib/build/recipe/multifactorauth/index.js b/lib/build/recipe/multifactorauth/index.js
index 98a54dbfc..998b20ca3 100644
--- a/lib/build/recipe/multifactorauth/index.js
+++ b/lib/build/recipe/multifactorauth/index.js
@@ -29,11 +29,12 @@ Object.defineProperty(exports, "MultiFactorAuthClaim", {
},
});
class Wrapper {
- static async enableFactorForUser(userId, factorId, userContext) {
+ static async enableFactorForUser(tenantId, userId, factorId, userContext) {
const recipeInstance = recipe_1.default.getInstanceOrThrowError();
return recipeInstance.recipeInterfaceImpl.enableFactorForUser({
userId,
factorId,
+ tenantId,
userContext: userContext === undefined ? {} : userContext,
});
}
diff --git a/lib/build/recipe/multifactorauth/recipe.js b/lib/build/recipe/multifactorauth/recipe.js
index 65af7651f..69c8e27f3 100644
--- a/lib/build/recipe/multifactorauth/recipe.js
+++ b/lib/build/recipe/multifactorauth/recipe.js
@@ -126,10 +126,13 @@ class Recipe extends recipeModule_1.default {
Object.assign({}, currentValue === null || currentValue === void 0 ? void 0 : currentValue.c),
{ [factor]: Math.floor(Date.now() / 1000) }
);
- const requirements = await this.config.getMFARequirementsForSession(
+ const requirements = await this.config.getGlobalMFARequirements(
session.getUserId(),
session.getRecipeUserId(),
session.getTenantId(),
+ session,
+ [], // TODO: this should call getEnabledFactorsForX
+ completed,
userContext
);
const next = multiFactorAuthClaim_1.MultiFactorAuthClaim.buildNextArray(completed, requirements);
diff --git a/lib/build/recipe/multifactorauth/types.d.ts b/lib/build/recipe/multifactorauth/types.d.ts
index 35c28dcb8..7a0b15bc4 100644
--- a/lib/build/recipe/multifactorauth/types.d.ts
+++ b/lib/build/recipe/multifactorauth/types.d.ts
@@ -8,7 +8,7 @@ import { SessionContainerInterface } from "../session/types";
export declare type MFARequirement =
| {
id: string;
- params?: any;
+ maxAgeInSeconds?: number;
}
| string;
export declare type MFARequirementList = (
@@ -26,16 +26,18 @@ export declare type MFAClaimValue = {
};
export declare type TypeInput = {
firstFactors?: string[];
- getMFARequirementsForSession?: (
+ getGlobalMFARequirements?: (
userId: string,
recipeUserId: RecipeUserId,
- tenantId: string | undefined,
+ tenantId: string,
+ session: SessionContainer | undefined,
+ enabledFactors: string[],
+ completedFactors: Record,
userContext: any
) => Promise | MFARequirementList;
getMFARequirementsForFactorSetup?: (
factorId: string,
session: SessionContainer,
- tenantId: string | undefined,
userContext: any
) => Promise | MFARequirementList;
override?: {
@@ -48,16 +50,18 @@ export declare type TypeInput = {
};
export declare type TypeNormalisedInput = {
firstFactors?: string[];
- getMFARequirementsForSession: (
+ getGlobalMFARequirements: (
userId: string,
recipeUserId: RecipeUserId,
- tenantId: string | undefined,
+ tenantId: string,
+ session: SessionContainer | undefined,
+ enabledFactors: string[],
+ completedFactors: Record,
userContext: any
) => Promise | MFARequirementList;
getMFARequirementsForFactorSetup: (
factorId: string,
session: SessionContainer,
- tenantId: string | undefined,
userContext: any
) => Promise | MFARequirementList;
override: {
@@ -69,15 +73,15 @@ export declare type TypeNormalisedInput = {
};
};
export declare type RecipeInterface = {
- getFirstFactors: (input: { tenantId: string }) => Promise;
isAllowedToSetupFactor: (input: {
tenantId: string;
session: SessionContainerInterface;
factorId: string;
userContext: any;
}) => Promise;
- getFactorsSetupForUser: (input: { userId: string; userContext: any }) => Promise;
+ getFactorsSetupForUser: (input: { userId: string; tenantId: string; userContext: any }) => Promise;
enableFactorForUser: (input: {
+ tenantId: string;
userId: string;
factorId: string;
userContext: any;
@@ -95,6 +99,7 @@ export declare type RecipeInterface = {
}>;
getEnabledFactorsForUser: (input: {
userId: string;
+ tenantId: string;
userContext: any;
}) => Promise<{
status: "OK";
diff --git a/lib/build/recipe/multifactorauth/utils.js b/lib/build/recipe/multifactorauth/utils.js
index 86548489f..e64a5e4d2 100644
--- a/lib/build/recipe/multifactorauth/utils.js
+++ b/lib/build/recipe/multifactorauth/utils.js
@@ -34,8 +34,8 @@ function validateAndNormaliseUserInput(config) {
// TODO: the default should be 2FA if any secondary factors are set up, otherwise we only require the first factor to be completed
return [];
},
- getMFARequirementsForSession:
- (_b = config === null || config === void 0 ? void 0 : config.getMFARequirementsForSession) !== null &&
+ getGlobalMFARequirements:
+ (_b = config === null || config === void 0 ? void 0 : config.getGlobalMFARequirements) !== null &&
_b !== void 0
? _b
: () => {
diff --git a/lib/ts/recipe/multifactorauth/index.ts b/lib/ts/recipe/multifactorauth/index.ts
index eea9ef0bd..ed8a925f5 100644
--- a/lib/ts/recipe/multifactorauth/index.ts
+++ b/lib/ts/recipe/multifactorauth/index.ts
@@ -24,6 +24,7 @@ export default class Wrapper {
static MultiFactorAuthClaim = MultiFactorAuthClaim;
static async enableFactorForUser(
+ tenantId: string,
userId: string,
factorId: string,
userContext?: any
@@ -32,6 +33,7 @@ export default class Wrapper {
return recipeInstance.recipeInterfaceImpl.enableFactorForUser({
userId,
factorId,
+ tenantId,
userContext: userContext === undefined ? {} : userContext,
});
}
diff --git a/lib/ts/recipe/multifactorauth/recipe.ts b/lib/ts/recipe/multifactorauth/recipe.ts
index 3a75c90e2..e7d00325d 100644
--- a/lib/ts/recipe/multifactorauth/recipe.ts
+++ b/lib/ts/recipe/multifactorauth/recipe.ts
@@ -168,10 +168,13 @@ export default class Recipe extends RecipeModule {
[factor]: Math.floor(Date.now() / 1000),
};
- const requirements = await this.config.getMFARequirementsForSession(
+ const requirements = await this.config.getGlobalMFARequirements(
session.getUserId(),
session.getRecipeUserId(),
session.getTenantId(),
+ session,
+ [], // TODO: this should call getEnabledFactorsForX
+ completed,
userContext
);
const next = MultiFactorAuthClaim.buildNextArray(completed, requirements);
diff --git a/lib/ts/recipe/multifactorauth/types.ts b/lib/ts/recipe/multifactorauth/types.ts
index 574fd41bc..784d3a79c 100644
--- a/lib/ts/recipe/multifactorauth/types.ts
+++ b/lib/ts/recipe/multifactorauth/types.ts
@@ -23,7 +23,7 @@ import { SessionContainerInterface } from "../session/types";
export type MFARequirement =
| {
id: string;
- params?: any;
+ maxAgeInSeconds?: number;
}
| string;
@@ -45,16 +45,18 @@ export type MFAClaimValue = {
export type TypeInput = {
firstFactors?: string[];
- getMFARequirementsForSession?: (
+ getGlobalMFARequirements?: (
userId: string,
recipeUserId: RecipeUserId,
- tenantId: string | undefined,
+ tenantId: string,
+ session: SessionContainer | undefined,
+ enabledFactors: string[],
+ completedFactors: Record,
userContext: any
) => Promise | MFARequirementList;
getMFARequirementsForFactorSetup?: (
factorId: string,
session: SessionContainer,
- tenantId: string | undefined,
userContext: any
) => Promise | MFARequirementList;
@@ -70,16 +72,18 @@ export type TypeInput = {
export type TypeNormalisedInput = {
firstFactors?: string[];
- getMFARequirementsForSession: (
+ getGlobalMFARequirements: (
userId: string,
recipeUserId: RecipeUserId,
- tenantId: string | undefined,
+ tenantId: string,
+ session: SessionContainer | undefined,
+ enabledFactors: string[],
+ completedFactors: Record,
userContext: any
) => Promise | MFARequirementList;
getMFARequirementsForFactorSetup: (
factorId: string,
session: SessionContainer,
- tenantId: string | undefined,
userContext: any
) => Promise | MFARequirementList;
@@ -93,16 +97,16 @@ export type TypeNormalisedInput = {
};
export type RecipeInterface = {
- getFirstFactors: (input: { tenantId: string }) => Promise;
isAllowedToSetupFactor: (input: {
tenantId: string;
session: SessionContainerInterface;
factorId: string;
userContext: any;
}) => Promise;
- getFactorsSetupForUser: (input: { userId: string; userContext: any }) => Promise;
+ getFactorsSetupForUser: (input: { userId: string; tenantId: string; userContext: any }) => Promise;
enableFactorForUser: (input: {
+ tenantId: string;
userId: string;
factorId: string;
userContext: any;
@@ -114,6 +118,7 @@ export type RecipeInterface = {
}) => Promise<{ status: "OK"; newEnabledFactors: string[] }>;
getEnabledFactorsForUser: (input: {
userId: string;
+ tenantId: string;
userContext: any;
}) => Promise<{ status: "OK"; enabledFactors: string[] }>;
getEnabledFactorsForTenant: (input: {
diff --git a/lib/ts/recipe/multifactorauth/utils.ts b/lib/ts/recipe/multifactorauth/utils.ts
index b0767823d..20c47eb2f 100644
--- a/lib/ts/recipe/multifactorauth/utils.ts
+++ b/lib/ts/recipe/multifactorauth/utils.ts
@@ -30,8 +30,8 @@ export function validateAndNormaliseUserInput(config?: TypeInput): TypeNormalise
// TODO: the default should be 2FA if any secondary factors are set up, otherwise we only require the first factor to be completed
return [];
}),
- getMFARequirementsForSession:
- config?.getMFARequirementsForSession ??
+ getGlobalMFARequirements:
+ config?.getGlobalMFARequirements ??
(() => {
// TODO: the default should be 2FA (so any 2 factors)
return [];