Skip to main content
References

EmailPassword

Classes

default

Defined in: recipe/emailpassword/index.ts:27

Constructors

Constructor
new default(): default;
Returns

default

Properties

PropertyModifierTypeDefault valueDefined in
Errorstatictypeof defaultSuperTokensErrorrecipe/emailpassword/index.ts:30
initstatic(config?) => RecipeListFunctionRecipe.initrecipe/emailpassword/index.ts:28

Methods

consumePasswordResetToken()
static consumePasswordResetToken(
tenantId,
token,
userContext?): Promise<
| {
email: string;
status: "OK";
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:236

Parameters
ParameterType
tenantIdstring
tokenstring
userContext?Record<string, any>
Returns

Promise< | { email: string; status: "OK"; userId: string; } | { status: "RESET_PASSWORD_INVALID_TOKEN_ERROR"; }>

static createResetPasswordLink(
tenantId,
userId,
email,
userContext?): Promise<
| {
link: string;
status: "OK";
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:280

Parameters
ParameterType
tenantIdstring
userIdstring
emailstring
userContext?Record<string, any>
Returns

Promise< | { link: string; status: "OK"; } | { status: "UNKNOWN_USER_ID_ERROR"; }>

createResetPasswordToken()
static createResetPasswordToken(
tenantId,
userId,
email,
userContext?): Promise<
| {
status: "OK";
token: string;
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:183

We do not make email optional here cause we want to allow passing in primaryUserId. If we make email optional, and if the user provides a primaryUserId, then it may result in two problems:

  • there is no recipeUserId = input primaryUserId, in this case, this function will throw an error
  • There is a recipe userId = input primaryUserId, but that recipe has no email, or has wrong email compared to what the user wanted to generate a reset token for.

And we want to allow primaryUserId being passed in.

Parameters
ParameterType
tenantIdstring
userIdstring
emailstring
userContext?Record<string, any>
Returns

Promise< | { status: "OK"; token: string; } | { status: "UNKNOWN_USER_ID_ERROR"; }>

resetPasswordUsingToken()
static resetPasswordUsingToken(
tenantId,
token,
newPassword,
userContext?): Promise<
| {
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:197

Parameters
ParameterType
tenantIdstring
tokenstring
newPasswordstring
userContext?Record<string, any>
Returns

Promise< | { status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR"; } | { failureReason: string; status: "PASSWORD_POLICY_VIOLATED_ERROR"; }>

sendEmail()
static sendEmail(input): Promise<void>;

Defined in: recipe/emailpassword/index.ts:343

Parameters
Returns

Promise<void>

sendResetPasswordEmail()
static sendResetPasswordEmail(
tenantId,
userId,
email,
userContext?): Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:305

Parameters
ParameterType
tenantIdstring
userIdstring
emailstring
userContext?Record<string, any>
Returns

Promise<{ status: "OK" | "UNKNOWN_USER_ID_ERROR"; }>

signIn()
Call Signature
static signIn(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:100

Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
session?undefined
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "WRONG_CREDENTIALS_ERROR"; }>

Call Signature
static signIn(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;

Defined in: recipe/emailpassword/index.ts:107

Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
sessionSessionContainerInterface
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "WRONG_CREDENTIALS_ERROR"; } | { reason: | "EMAIL_VERIFICATION_REQUIRED" | "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; status: "LINKING_TO_SESSION_USER_FAILED"; }>

signUp()
Call Signature
static signUp(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:32

Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
session?undefined
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "EMAIL_ALREADY_EXISTS_ERROR"; }>

Call Signature
static signUp(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;

Defined in: recipe/emailpassword/index.ts:46

Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
sessionSessionContainerInterface
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "EMAIL_ALREADY_EXISTS_ERROR"; } | { reason: | "EMAIL_VERIFICATION_REQUIRED" | "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; status: "LINKING_TO_SESSION_USER_FAILED"; }>

updateEmailOrPassword()
static updateEmailOrPassword(input): Promise<
| {
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
}
| {
reason: string;
status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:255

Parameters
ParameterType
input{ applyPasswordPolicy?: boolean; email?: string; password?: string; recipeUserId: RecipeUserId; tenantIdForPasswordPolicy?: string; userContext?: Record<string, any>; }
input.applyPasswordPolicy?boolean
input.email?string
input.password?string
input.recipeUserIdRecipeUserId
input.tenantIdForPasswordPolicy?string
input.userContext?Record<string, any>
Returns

Promise< | { status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR"; } | { reason: string; status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR"; } | { failureReason: string; status: "PASSWORD_POLICY_VIOLATED_ERROR"; }>

verifyCredentials()
static verifyCredentials(
tenantId,
email,
password,
userContext?): Promise<{
status: "OK" | "WRONG_CREDENTIALS_ERROR";
}>;

Defined in: recipe/emailpassword/index.ts:153

Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
userContext?Record<string, any>
Returns

Promise<{ status: "OK" | "WRONG_CREDENTIALS_ERROR"; }>

Variables

consumePasswordResetToken()

consumePasswordResetToken: (tenantId, token, userContext?) => Promise<
| {
email: string;
status: "OK";
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}> = Wrapper.consumePasswordResetToken;

Defined in: recipe/emailpassword/index.ts:369

Parameters

ParameterType
tenantIdstring
tokenstring
userContext?Record<string, any>

Returns

Promise< | { email: string; status: "OK"; userId: string; } | { status: "RESET_PASSWORD_INVALID_TOKEN_ERROR"; }>

createResetPasswordLink: (tenantId, userId, email, userContext?) => Promise<
| {
link: string;
status: "OK";
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.createResetPasswordLink;

Defined in: recipe/emailpassword/index.ts:375

Parameters

ParameterType
tenantIdstring
userIdstring
emailstring
userContext?Record<string, any>

Returns

Promise< | { link: string; status: "OK"; } | { status: "UNKNOWN_USER_ID_ERROR"; }>

createResetPasswordToken()

createResetPasswordToken: (tenantId, userId, email, userContext?) => Promise<
| {
status: "OK";
token: string;
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.createResetPasswordToken;

Defined in: recipe/emailpassword/index.ts:365

We do not make email optional here cause we want to allow passing in primaryUserId. If we make email optional, and if the user provides a primaryUserId, then it may result in two problems:

  • there is no recipeUserId = input primaryUserId, in this case, this function will throw an error
  • There is a recipe userId = input primaryUserId, but that recipe has no email, or has wrong email compared to what the user wanted to generate a reset token for.

And we want to allow primaryUserId being passed in.

Parameters

ParameterType
tenantIdstring
userIdstring
emailstring
userContext?Record<string, any>

Returns

Promise< | { status: "OK"; token: string; } | { status: "UNKNOWN_USER_ID_ERROR"; }>

Error

Error: typeof default = Wrapper.Error;

Defined in: recipe/emailpassword/index.ts:357

init()

init: (config?) => RecipeListFunction = Wrapper.init;

Defined in: recipe/emailpassword/index.ts:355

Parameters

ParameterType
config?TypeInput

Returns

RecipeListFunction

resetPasswordUsingToken()

resetPasswordUsingToken: (tenantId, token, newPassword, userContext?) => Promise<
| {
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}> = Wrapper.resetPasswordUsingToken;

Defined in: recipe/emailpassword/index.ts:367

Parameters

ParameterType
tenantIdstring
tokenstring
newPasswordstring
userContext?Record<string, any>

Returns

Promise< | { status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR"; } | { failureReason: string; status: "PASSWORD_POLICY_VIOLATED_ERROR"; }>

sendEmail()

sendEmail: (input) => Promise<void> = Wrapper.sendEmail;

Defined in: recipe/emailpassword/index.ts:379

Parameters

Returns

Promise<void>

sendResetPasswordEmail()

sendResetPasswordEmail: (tenantId, userId, email, userContext?) => Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.sendResetPasswordEmail;

Defined in: recipe/emailpassword/index.ts:377

Parameters

ParameterType
tenantIdstring
userIdstring
emailstring
userContext?Record<string, any>

Returns

Promise<{ status: "OK" | "UNKNOWN_USER_ID_ERROR"; }>

signIn()

signIn: {
(tenantId, email, password, session?, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>;
(tenantId, email, password, session, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
} = Wrapper.signIn;

Defined in: recipe/emailpassword/index.ts:361

Call Signature

(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>;
Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
session?undefined
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "WRONG_CREDENTIALS_ERROR"; }>

Call Signature

(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
sessionSessionContainerInterface
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "WRONG_CREDENTIALS_ERROR"; } | { reason: | "EMAIL_VERIFICATION_REQUIRED" | "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; status: "LINKING_TO_SESSION_USER_FAILED"; }>

signUp()

signUp: {
(tenantId, email, password, session?, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>;
(tenantId, email, password, session, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
} = Wrapper.signUp;

Defined in: recipe/emailpassword/index.ts:359

Call Signature

(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>;
Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
session?undefined
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "EMAIL_ALREADY_EXISTS_ERROR"; }>

Call Signature

(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
Parameters
ParameterType
tenantIdstring
emailstring
passwordstring
sessionSessionContainerInterface
userContext?Record<string, any>
Returns

Promise< | { recipeUserId: RecipeUserId; status: "OK"; user: User; } | { status: "EMAIL_ALREADY_EXISTS_ERROR"; } | { reason: | "EMAIL_VERIFICATION_REQUIRED" | "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; status: "LINKING_TO_SESSION_USER_FAILED"; }>

updateEmailOrPassword()

updateEmailOrPassword: (input) => Promise<
| {
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
}
| {
reason: string;
status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}> = Wrapper.updateEmailOrPassword;

Defined in: recipe/emailpassword/index.ts:371

Parameters

ParameterType
input{ applyPasswordPolicy?: boolean; email?: string; password?: string; recipeUserId: RecipeUserId; tenantIdForPasswordPolicy?: string; userContext?: Record<string, any>; }
input.applyPasswordPolicy?boolean
input.email?string
input.password?string
input.recipeUserIdRecipeUserId
input.tenantIdForPasswordPolicy?string
input.userContext?Record<string, any>

Returns

Promise< | { status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR"; } | { reason: string; status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR"; } | { failureReason: string; status: "PASSWORD_POLICY_VIOLATED_ERROR"; }>

verifyCredentials()

verifyCredentials: (tenantId, email, password, userContext?) => Promise<{
status: "OK" | "WRONG_CREDENTIALS_ERROR";
}> = Wrapper.verifyCredentials;

Defined in: recipe/emailpassword/index.ts:363

Parameters

ParameterType
tenantIdstring
emailstring
passwordstring
userContext?Record<string, any>

Returns

Promise<{ status: "OK" | "WRONG_CREDENTIALS_ERROR"; }>

References

APIInterface

Re-exports APIInterface

APIOptions

Re-exports APIOptions

RecipeInterface

Re-exports RecipeInterface