Skip to content

Commit

Permalink
more type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Jul 2, 2024
1 parent 9eafc55 commit 88da59b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/ts/recipe/multifactorauth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { SessionContainerInterface } from "../session/types";
import Recipe from "./recipe";
import { TenantConfig } from "../multitenancy/types";
import RecipeUserId from "../../recipeUserId";
import { RiskScores } from "../../types";

export type MFARequirementList = (
| {
Expand Down Expand Up @@ -80,6 +81,7 @@ export type RecipeInterface = {
requiredSecondaryFactorsForUser: Promise<string[]>;
requiredSecondaryFactorsForTenant: Promise<string[]>;
userContext: UserContext;
riskScores?: RiskScores;
}) => Promise<MFARequirementList> | MFARequirementList;

markFactorAsCompleteInSession: (input: {
Expand Down
11 changes: 7 additions & 4 deletions lib/ts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export type TypeInput = {
isInServerlessEnv?: boolean;
debug?: boolean;
security?: {
anomalyServiceAPIKey?: string; // this will be provided by us on our supertokens.com dashboard
rateLimitServiceApiKey?: string; // this will be provided by us on our supertokens.com dashboard (cache wrapper)
googleRecaptcha?: {
// if the user provides both, we will use v2
v2SecretKey?: string;
Expand Down Expand Up @@ -121,6 +119,10 @@ export type SecurityFunctions = {
userContext: UserContext;
}) => Promise<boolean>;

// The apiKey for this will be fetched from the core during the /apiversion API call, and will be saved in memory for use.
// In case /apiversion has not yet been called, this function will call that API first. In case it has been called, but there
// is no API key for this, it means this function will not do anything and return undefined. This also means that if the user
// has added the license key in the core to enable this feature, they will have to restart the backend process once.
calculateRiskScoreUsingAnomalyService: (input: {
infoFromRequest: InfoFromRequest;
email?: string;
Expand All @@ -130,7 +132,7 @@ export type SecurityFunctions = {
userId?: string;
actionType: AnomalyServiceActionTypes;
userContext: UserContext;
}) => Promise<RiskScores>;
}) => Promise<RiskScores | undefined>; // undefined means we have nothing to return, and we completely ignore this.

logToAnomalyService: (input: {
infoFromRequest: InfoFromRequest;
Expand Down Expand Up @@ -233,7 +235,8 @@ export type SecurityFunctions = {
}[]
| undefined;

// these are functions to actually query the rate limit service
// these are functions to actually query the rate limit service. The api key for this
// will be fetched from the /apiversion API call, similar to the api key for the anomaly service.
setRateLimitForKey: (input: {
keys: {
key: string;
Expand Down

0 comments on commit 88da59b

Please sign in to comment.