Skip to content
Esc
navigateopen⌘Jpreview
Dashboard
On this page

supertokens-node

References documentation for the supertokens-node package

Classes

default

Defined in: index.ts

Constructors

Constructor
new default(): default;
Returns

default

Properties

Property Modifier Type Default value Defined in
Error static typeof default SuperTokensError index.ts
init static (config) => void SuperTokens.init index.ts
RecipeUserId static typeof RecipeUserId RecipeUserId index.ts
User static typeof User User index.ts

Methods

convertToRecipeUserId()
static convertToRecipeUserId(recipeUserId): RecipeUserId;

Defined in: index.ts

Parameters
Parameter Type
recipeUserId string
Returns

RecipeUserId

createUserIdMapping()
static createUserIdMapping(input): Promise<
  | {
  status: "OK" | "UNKNOWN_SUPERTOKENS_USER_ID_ERROR";
}
  | {
  doesExternalUserIdExist: boolean;
  doesSuperTokensUserIdExist: boolean;
  status: "USER_ID_MAPPING_ALREADY_EXISTS_ERROR";
}>;

Defined in: index.ts

Parameters
Parameter Type
input { externalUserId: string; externalUserIdInfo?: string; force?: boolean; superTokensUserId: string; userContext?: Record<string, any>; }
input.externalUserId string
input.externalUserIdInfo? string
input.force? boolean
input.superTokensUserId string
input.userContext? Record<string, any>
Returns

Promise< | { status: "OK" | "UNKNOWN_SUPERTOKENS_USER_ID_ERROR"; } | { doesExternalUserIdExist: boolean; doesSuperTokensUserIdExist: boolean; status: "USER_ID_MAPPING_ALREADY_EXISTS_ERROR"; }>

deleteUser()
static deleteUser(
   userId, 
   removeAllLinkedAccounts, 
   userContext?): Promise<{
  status: "OK";
}>;

Defined in: index.ts

Parameters
Parameter Type Default value
userId string undefined
removeAllLinkedAccounts boolean true
userContext? Record<string, any> undefined
Returns

Promise<{ status: "OK"; }>

deleteUserIdMapping()
static deleteUserIdMapping(input): Promise<{
  didMappingExist: boolean;
  status: "OK";
}>;

Defined in: index.ts

Parameters
Parameter Type
input { force?: boolean; userContext?: Record<string, any>; userId: string; userIdType?: "SUPERTOKENS" | "EXTERNAL" | "ANY"; }
input.force? boolean
input.userContext? Record<string, any>
input.userId string
input.userIdType? "SUPERTOKENS" | "EXTERNAL" | "ANY"
Returns

Promise<{ didMappingExist: boolean; status: "OK"; }>

getAllCORSHeaders()
static getAllCORSHeaders(): string[];

Defined in: index.ts

Returns

string[]

getRequestFromUserContext()
static getRequestFromUserContext(userContext): BaseRequest;

Defined in: index.ts

Parameters
Parameter Type
userContext UserContext
Returns

BaseRequest

getUser()
static getUser(userId, userContext?): Promise<User>;

Defined in: index.ts

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

Promise<User>

getUserCount()
static getUserCount(
   includeRecipeIds?, 
   tenantId?, 
userContext?): Promise<number>;

Defined in: index.ts

Parameters
Parameter Type
includeRecipeIds? string[]
tenantId? string
userContext? Record<string, any>
Returns

Promise<number>

getUserIdMapping()
static getUserIdMapping(input): Promise<
  | {
  externalUserId: string;
  externalUserIdInfo: string;
  status: "OK";
  superTokensUserId: string;
}
  | {
  status: "UNKNOWN_MAPPING_ERROR";
}>;

Defined in: index.ts

Parameters
Parameter Type
input { userContext?: Record<string, any>; userId: string; userIdType?: "SUPERTOKENS" | "EXTERNAL" | "ANY"; }
input.userContext? Record<string, any>
input.userId string
input.userIdType? "SUPERTOKENS" | "EXTERNAL" | "ANY"
Returns

Promise< | { externalUserId: string; externalUserIdInfo: string; status: "OK"; superTokensUserId: string; } | { status: "UNKNOWN_MAPPING_ERROR"; }>

getUsersNewestFirst()
static getUsersNewestFirst(input): Promise<{
  nextPaginationToken?: string;
  users: User[];
}>;

Defined in: index.ts

Parameters
Parameter Type
input { includeRecipeIds?: string[]; limit?: number; paginationToken?: string; query?: { [key: string]: string; }; tenantId: string; userContext?: Record<string, any>; }
input.includeRecipeIds? string[]
input.limit? number
input.paginationToken? string
input.query? { [key: string]: string; }
input.tenantId string
input.userContext? Record<string, any>
Returns

Promise<{ nextPaginationToken?: string; users: User[]; }>

getUsersOldestFirst()
static getUsersOldestFirst(input): Promise<{
  nextPaginationToken?: string;
  users: User[];
}>;

Defined in: index.ts

Parameters
Parameter Type
input { includeRecipeIds?: string[]; limit?: number; paginationToken?: string; query?: { [key: string]: string; }; tenantId: string; userContext?: Record<string, any>; }
input.includeRecipeIds? string[]
input.limit? number
input.paginationToken? string
input.query? { [key: string]: string; }
input.tenantId string
input.userContext? Record<string, any>
Returns

Promise<{ nextPaginationToken?: string; users: User[]; }>

isRecipeInitialized()
static isRecipeInitialized(recipeId): boolean;

Defined in: index.ts

Parameters
Parameter Type
recipeId string
Returns

boolean

listUsersByAccountInfo()
static listUsersByAccountInfo(
   tenantId, 
   accountInfo, 
   doUnionOfAccountInfo, 
userContext?): Promise<User[]>;

Defined in: index.ts

Parameters
Parameter Type Default value
tenantId string undefined
accountInfo AccountInfoInput undefined
doUnionOfAccountInfo boolean false
userContext? Record<string, any> undefined
Returns

Promise<User[]>

updateOrDeleteUserIdMappingInfo()
static updateOrDeleteUserIdMappingInfo(input): Promise<{
  status: "OK" | "UNKNOWN_MAPPING_ERROR";
}>;

Defined in: index.ts

Parameters
Parameter Type
input { externalUserIdInfo?: string; userContext?: Record<string, any>; userId: string; userIdType?: "SUPERTOKENS" | "EXTERNAL" | "ANY"; }
input.externalUserIdInfo? string
input.userContext? Record<string, any>
input.userId string
input.userIdType? "SUPERTOKENS" | "EXTERNAL" | "ANY"
Returns

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


RecipeUserId

Defined in: recipeUserId.ts

Constructors

Constructor
new RecipeUserId(recipeUserId): RecipeUserId;

Defined in: recipeUserId.ts

Parameters
Parameter Type
recipeUserId string
Returns

RecipeUserId

Methods

getAsString()
getAsString(): string;

Defined in: recipeUserId.ts

Returns

string


User

Defined in: user.ts

Implements

Constructors

Constructor
new User(user): User;

Defined in: user.ts

Parameters
Parameter Type
user UserWithoutHelperFunctions
Returns

User

Properties

Property Modifier Type Defined in
emails readonly string[] user.ts
id readonly string user.ts
isPrimaryUser readonly boolean user.ts
loginMethods readonly LoginMethod[] user.ts
phoneNumbers readonly string[] user.ts
tenantIds readonly string[] user.ts
thirdParty readonly object[] user.ts
timeJoined readonly number user.ts
webauthn readonly object user.ts
webauthn.credentialIds public string[] user.ts

Methods

toJson()
toJson(): JSONObject;

Defined in: user.ts

Returns

JSONObject

Implementation of
UserType.toJson;
fromApi()
static fromApi(apiUser): User;

Defined in: user.ts

This function is used to create a User object from the API response.

Parameters
Parameter Type Description
apiUser Omit<UserWithoutHelperFunctions, "id"> & object The API response from the user endpoint.
Returns

User

A User object.

Variables

convertToRecipeUserId()

convertToRecipeUserId: (recipeUserId) => RecipeUserId = SuperTokensWrapper.convertToRecipeUserId;

Defined in: index.ts

Parameters

Parameter Type
recipeUserId string

Returns

RecipeUserId


createUserIdMapping()

createUserIdMapping: (input) => Promise<
  | {
  status: "OK" | "UNKNOWN_SUPERTOKENS_USER_ID_ERROR";
}
  | {
  doesExternalUserIdExist: boolean;
  doesSuperTokensUserIdExist: boolean;
  status: "USER_ID_MAPPING_ALREADY_EXISTS_ERROR";
}> = SuperTokensWrapper.createUserIdMapping;

Defined in: index.ts

Parameters

Parameter Type
input { externalUserId: string; externalUserIdInfo?: string; force?: boolean; superTokensUserId: string; userContext?: Record<string, any>; }
input.externalUserId string
input.externalUserIdInfo? string
input.force? boolean
input.superTokensUserId string
input.userContext? Record<string, any>

Returns

Promise< | { status: "OK" | "UNKNOWN_SUPERTOKENS_USER_ID_ERROR"; } | { doesExternalUserIdExist: boolean; doesSuperTokensUserIdExist: boolean; status: "USER_ID_MAPPING_ALREADY_EXISTS_ERROR"; }>


deleteUser()

deleteUser: (userId, removeAllLinkedAccounts, userContext?) => Promise<{
  status: "OK";
}> = SuperTokensWrapper.deleteUser;

Defined in: index.ts

Parameters

Parameter Type Default value
userId string undefined
removeAllLinkedAccounts boolean true
userContext? Record<string, any> undefined

Returns

Promise<{ status: "OK"; }>


deleteUserIdMapping()

deleteUserIdMapping: (input) => Promise<{
  didMappingExist: boolean;
  status: "OK";
}> = SuperTokensWrapper.deleteUserIdMapping;

Defined in: index.ts

Parameters

Parameter Type
input { force?: boolean; userContext?: Record<string, any>; userId: string; userIdType?: "SUPERTOKENS" | "EXTERNAL" | "ANY"; }
input.force? boolean
input.userContext? Record<string, any>
input.userId string
input.userIdType? "SUPERTOKENS" | "EXTERNAL" | "ANY"

Returns

Promise<{ didMappingExist: boolean; status: "OK"; }>


Error

Error: typeof default = SuperTokensWrapper.Error;

Defined in: index.ts


getAllCORSHeaders()

getAllCORSHeaders: () => string[] = SuperTokensWrapper.getAllCORSHeaders;

Defined in: index.ts

Returns

string[]


getRequestFromUserContext()

getRequestFromUserContext: (userContext) => BaseRequest = SuperTokensWrapper.getRequestFromUserContext;

Defined in: index.ts

Parameters

Parameter Type
userContext UserContext

Returns

BaseRequest


getUser()

getUser: (userId, userContext?) => Promise<User> = SuperTokensWrapper.getUser;

Defined in: index.ts

Parameters

Parameter Type
userId string
userContext? Record<string, any>

Returns

Promise<User>


getUserCount()

getUserCount: (includeRecipeIds?, tenantId?, userContext?) => Promise<number> = SuperTokensWrapper.getUserCount;

Defined in: index.ts

Parameters

Parameter Type
includeRecipeIds? string[]
tenantId? string
userContext? Record<string, any>

Returns

Promise<number>


getUserIdMapping()

getUserIdMapping: (input) => Promise<
  | {
  externalUserId: string;
  externalUserIdInfo: string;
  status: "OK";
  superTokensUserId: string;
}
  | {
  status: "UNKNOWN_MAPPING_ERROR";
}> = SuperTokensWrapper.getUserIdMapping;

Defined in: index.ts

Parameters

Parameter Type
input { userContext?: Record<string, any>; userId: string; userIdType?: "SUPERTOKENS" | "EXTERNAL" | "ANY"; }
input.userContext? Record<string, any>
input.userId string
input.userIdType? "SUPERTOKENS" | "EXTERNAL" | "ANY"

Returns

Promise< | { externalUserId: string; externalUserIdInfo: string; status: "OK"; superTokensUserId: string; } | { status: "UNKNOWN_MAPPING_ERROR"; }>


getUsersNewestFirst()

getUsersNewestFirst: (input) => Promise<{
  nextPaginationToken?: string;
  users: User[];
}> = SuperTokensWrapper.getUsersNewestFirst;

Defined in: index.ts

Parameters

Parameter Type
input { includeRecipeIds?: string[]; limit?: number; paginationToken?: string; query?: { [key: string]: string; }; tenantId: string; userContext?: Record<string, any>; }
input.includeRecipeIds? string[]
input.limit? number
input.paginationToken? string
input.query? { [key: string]: string; }
input.tenantId string
input.userContext? Record<string, any>

Returns

Promise<{ nextPaginationToken?: string; users: User[]; }>


getUsersOldestFirst()

getUsersOldestFirst: (input) => Promise<{
  nextPaginationToken?: string;
  users: User[];
}> = SuperTokensWrapper.getUsersOldestFirst;

Defined in: index.ts

Parameters

Parameter Type
input { includeRecipeIds?: string[]; limit?: number; paginationToken?: string; query?: { [key: string]: string; }; tenantId: string; userContext?: Record<string, any>; }
input.includeRecipeIds? string[]
input.limit? number
input.paginationToken? string
input.query? { [key: string]: string; }
input.tenantId string
input.userContext? Record<string, any>

Returns

Promise<{ nextPaginationToken?: string; users: User[]; }>


init()

init: (config) => void = SuperTokensWrapper.init;

Defined in: index.ts

Parameters

Parameter Type
config TypeInput

Returns

void


isRecipeInitialized()

isRecipeInitialized: (recipeId) => boolean = SuperTokensWrapper.isRecipeInitialized;

Defined in: index.ts

Parameters

Parameter Type
recipeId string

Returns

boolean


listUsersByAccountInfo()

listUsersByAccountInfo: (tenantId, accountInfo, doUnionOfAccountInfo, userContext?) => Promise<User[]> = SuperTokensWrapper.listUsersByAccountInfo;

Defined in: index.ts

Parameters

Parameter Type Default value
tenantId string undefined
accountInfo AccountInfoInput undefined
doUnionOfAccountInfo boolean false
userContext? Record<string, any> undefined

Returns

Promise<User[]>


updateOrDeleteUserIdMappingInfo()

updateOrDeleteUserIdMappingInfo: (input) => Promise<{
  status: "OK" | "UNKNOWN_MAPPING_ERROR";
}> = SuperTokensWrapper.updateOrDeleteUserIdMappingInfo;

Defined in: index.ts

Parameters

Parameter Type
input { externalUserIdInfo?: string; userContext?: Record<string, any>; userId: string; userIdType?: "SUPERTOKENS" | "EXTERNAL" | "ANY"; }
input.externalUserIdInfo? string
input.userContext? Record<string, any>
input.userId string
input.userIdType? "SUPERTOKENS" | "EXTERNAL" | "ANY"

Returns

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

References

SuperTokensConfig

Renames and re-exports TypeInput


SuperTokensPlugin

Re-exports SuperTokensPlugin


SuperTokensPublicConfig

Re-exports SuperTokensPublicConfig


SuperTokensPublicPlugin

Re-exports SuperTokensPublicPlugin

API reference

API schema and response details