Skip to content
Esc
navigateopen⌘Jpreview
Dashboard
On this page

supertokens-node/recipe/accountlinking

References documentation for the supertokens-node/recipe/accountlinking package

Classes

default

Defined in: recipe/accountlinking/index.ts

Constructors

Constructor
new default(): default;
Returns

default

Properties

Property Modifier Type Default value Defined in
init static (config?) => RecipeListFunction Recipe.init recipe/accountlinking/index.ts

Methods

canCreatePrimaryUser()
static canCreatePrimaryUser(recipeUserId, userContext?): Promise<
  | {
  status: "OK";
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  description: string;
  primaryUserId: string;
  status:   | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
     | "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
recipeUserId RecipeUserId
userContext? Record<string, any>
Returns

Promise< | { status: "OK"; wasAlreadyAPrimaryUser: boolean; } | { description: string; primaryUserId: string; status: | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"; }>

canLinkAccounts()
static canLinkAccounts(
   recipeUserId, 
   primaryUserId, 
   userContext?): Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
}
  | {
  description: string;
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
recipeUserId RecipeUserId
primaryUserId string
userContext? Record<string, any>
Returns

Promise< | { accountsAlreadyLinked: boolean; status: "OK"; } | { description: string; primaryUserId: string; status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; } | { description: string; primaryUserId: string; status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; } | { status: "INPUT_USER_IS_NOT_A_PRIMARY_USER"; }>

createPrimaryUser()
static createPrimaryUser(recipeUserId, userContext?): Promise<
  | {
  status: "OK";
  user: User;
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
recipeUserId RecipeUserId
userContext? Record<string, any>
Returns

Promise< | { status: "OK"; user: User; wasAlreadyAPrimaryUser: boolean; } | { primaryUserId: string; status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"; } | { description: string; primaryUserId: string; status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; }>

createPrimaryUserIdOrLinkAccounts()
static createPrimaryUserIdOrLinkAccounts(
   tenantId, 
   recipeUserId, 
   session?, 
userContext?): Promise<User>;

Defined in: recipe/accountlinking/index.ts

This is a function which is a combination of createPrimaryUser and linkAccounts where the input recipeUserId is either linked to a user that it can be linked to, or is made into a primary user.

The output will be the user ID of the user that it was linked to, or it will be the same as the input recipeUserId if it was made into a primary user, or if there was no linking that happened.

Parameters
Parameter Type
tenantId string
recipeUserId RecipeUserId
session? SessionContainerInterface
userContext? Record<string, any>
Returns

Promise<User>

getPrimaryUserThatCanBeLinkedToRecipeUserId()
static getPrimaryUserThatCanBeLinkedToRecipeUserId(
   tenantId, 
   recipeUserId, 
userContext?): Promise<User>;

Defined in: recipe/accountlinking/index.ts

This function returns the primary user that the input recipe ID can be linked to. It can be used to determine which primary account the linking will happen to if the input recipe user ID was to be linked.

If the function returns undefined, it means that there is no primary user that the input recipe ID can be linked to, and therefore it can be made into a primary user itself.

Parameters
Parameter Type
tenantId string
recipeUserId RecipeUserId
userContext? Record<string, any>
Returns

Promise<User>

isEmailChangeAllowed()
static isEmailChangeAllowed(
   recipeUserId, 
   newEmail, 
   isVerified, 
   session?, 
userContext?): Promise<boolean>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
recipeUserId RecipeUserId
newEmail string
isVerified boolean
session? SessionContainerInterface
userContext? Record<string, any>
Returns

Promise<boolean>

isSignInAllowed()
static isSignInAllowed(
   tenantId, 
   recipeUserId, 
   session?, 
userContext?): Promise<boolean>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
tenantId string
recipeUserId RecipeUserId
session? SessionContainerInterface
userContext? Record<string, any>
Returns

Promise<boolean>

isSignUpAllowed()
static isSignUpAllowed(
   tenantId, 
   newUser, 
   isVerified, 
   session?, 
userContext?): Promise<boolean>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
tenantId string
newUser AccountInfoWithRecipeId
isVerified boolean
session? SessionContainerInterface
userContext? Record<string, any>
Returns

Promise<boolean>

linkAccounts()
static linkAccounts(
   recipeUserId, 
   primaryUserId, 
   userContext?): Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
  user: User;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
  user: User;
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
recipeUserId RecipeUserId
primaryUserId string
userContext? Record<string, any>
Returns

Promise< | { accountsAlreadyLinked: boolean; status: "OK"; user: User; } | { primaryUserId: string; status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; user: User; } | { description: string; primaryUserId: string; status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; } | { status: "INPUT_USER_IS_NOT_A_PRIMARY_USER"; }>

unlinkAccount()
static unlinkAccount(recipeUserId, userContext?): Promise<{
  status: "OK";
  wasLinked: boolean;
  wasRecipeUserDeleted: boolean;
}>;

Defined in: recipe/accountlinking/index.ts

Parameters
Parameter Type
recipeUserId RecipeUserId
userContext? Record<string, any>
Returns

Promise<{ status: "OK"; wasLinked: boolean; wasRecipeUserDeleted: boolean; }>

Variables

canCreatePrimaryUser()

const canCreatePrimaryUser: (recipeUserId, userContext?) => Promise<
  | {
  status: "OK";
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  description: string;
  primaryUserId: string;
  status:   | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
     | "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}> = Wrapper.canCreatePrimaryUser;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
recipeUserId RecipeUserId
userContext? Record<string, any>

Returns

Promise< | { status: "OK"; wasAlreadyAPrimaryUser: boolean; } | { description: string; primaryUserId: string; status: | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR" | "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"; }>


canLinkAccounts()

const canLinkAccounts: (recipeUserId, primaryUserId, userContext?) => Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
}
  | {
  description: string;
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}> = Wrapper.canLinkAccounts;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
recipeUserId RecipeUserId
primaryUserId string
userContext? Record<string, any>

Returns

Promise< | { accountsAlreadyLinked: boolean; status: "OK"; } | { description: string; primaryUserId: string; status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; } | { description: string; primaryUserId: string; status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; } | { status: "INPUT_USER_IS_NOT_A_PRIMARY_USER"; }>


createPrimaryUser()

const createPrimaryUser: (recipeUserId, userContext?) => Promise<
  | {
  status: "OK";
  user: User;
  wasAlreadyAPrimaryUser: boolean;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR";
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}> = Wrapper.createPrimaryUser;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
recipeUserId RecipeUserId
userContext? Record<string, any>

Returns

Promise< | { status: "OK"; user: User; wasAlreadyAPrimaryUser: boolean; } | { primaryUserId: string; status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_PRIMARY_USER_ID_ERROR"; } | { description: string; primaryUserId: string; status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; }>


createPrimaryUserIdOrLinkAccounts()

const createPrimaryUserIdOrLinkAccounts: (tenantId, recipeUserId, session?, userContext?) => Promise<User> = Wrapper.createPrimaryUserIdOrLinkAccounts;

Defined in: recipe/accountlinking/index.ts

This is a function which is a combination of createPrimaryUser and linkAccounts where the input recipeUserId is either linked to a user that it can be linked to, or is made into a primary user.

The output will be the user ID of the user that it was linked to, or it will be the same as the input recipeUserId if it was made into a primary user, or if there was no linking that happened.

Parameters

Parameter Type
tenantId string
recipeUserId RecipeUserId
session? SessionContainerInterface
userContext? Record<string, any>

Returns

Promise<User>


getPrimaryUserThatCanBeLinkedToRecipeUserId()

const getPrimaryUserThatCanBeLinkedToRecipeUserId: (tenantId, recipeUserId, userContext?) => Promise<User> = Wrapper.getPrimaryUserThatCanBeLinkedToRecipeUserId;

Defined in: recipe/accountlinking/index.ts

This function returns the primary user that the input recipe ID can be linked to. It can be used to determine which primary account the linking will happen to if the input recipe user ID was to be linked.

If the function returns undefined, it means that there is no primary user that the input recipe ID can be linked to, and therefore it can be made into a primary user itself.

Parameters

Parameter Type
tenantId string
recipeUserId RecipeUserId
userContext? Record<string, any>

Returns

Promise<User>


init()

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

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
config? TypeInput

Returns

RecipeListFunction


isEmailChangeAllowed()

const isEmailChangeAllowed: (recipeUserId, newEmail, isVerified, session?, userContext?) => Promise<boolean> = Wrapper.isEmailChangeAllowed;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
recipeUserId RecipeUserId
newEmail string
isVerified boolean
session? SessionContainerInterface
userContext? Record<string, any>

Returns

Promise<boolean>


isSignInAllowed()

const isSignInAllowed: (tenantId, recipeUserId, session?, userContext?) => Promise<boolean> = Wrapper.isSignInAllowed;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
tenantId string
recipeUserId RecipeUserId
session? SessionContainerInterface
userContext? Record<string, any>

Returns

Promise<boolean>


isSignUpAllowed()

const isSignUpAllowed: (tenantId, newUser, isVerified, session?, userContext?) => Promise<boolean> = Wrapper.isSignUpAllowed;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
tenantId string
newUser AccountInfoWithRecipeId
isVerified boolean
session? SessionContainerInterface
userContext? Record<string, any>

Returns

Promise<boolean>


linkAccounts()

const linkAccounts: (recipeUserId, primaryUserId, userContext?) => Promise<
  | {
  accountsAlreadyLinked: boolean;
  status: "OK";
  user: User;
}
  | {
  primaryUserId: string;
  status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
  user: User;
}
  | {
  description: string;
  primaryUserId: string;
  status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
}
  | {
  status: "INPUT_USER_IS_NOT_A_PRIMARY_USER";
}> = Wrapper.linkAccounts;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
recipeUserId RecipeUserId
primaryUserId string
userContext? Record<string, any>

Returns

Promise< | { accountsAlreadyLinked: boolean; status: "OK"; user: User; } | { primaryUserId: string; status: "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; user: User; } | { description: string; primaryUserId: string; status: "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"; } | { status: "INPUT_USER_IS_NOT_A_PRIMARY_USER"; }>


unlinkAccount()

const unlinkAccount: (recipeUserId, userContext?) => Promise<{
  status: "OK";
  wasLinked: boolean;
  wasRecipeUserDeleted: boolean;
}> = Wrapper.unlinkAccount;

Defined in: recipe/accountlinking/index.ts

Parameters

Parameter Type
recipeUserId RecipeUserId
userContext? Record<string, any>

Returns

Promise<{ status: "OK"; wasLinked: boolean; wasRecipeUserDeleted: boolean; }>

References

RecipeInterface

Re-exports RecipeInterface

API reference

API schema and response details