supertokens-node
    Preparing search index...
    Index

    Constructors

    Properties

    Error: typeof default = SuperTokensError
    init: (config: TypeInput) => RecipeListFunction = Recipe.init

    Methods

    • This function will only verify the code (not consume it), and: NOT create a new user if it doesn't exist NOT verify the user email if it exists NOT do any linking NOT delete the code unless it returned RESTART_FLOW_ERROR

      Parameters

      • input:
            | {
                deviceId: string;
                preAuthSessionId: string;
                tenantId: string;
                userContext?: Record<string, any>;
                userInputCode: string;
            }
            | {
                linkCode: string;
                preAuthSessionId: string;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<
          | {
              consumedDevice: {
                  email?: string;
                  failedCodeInputAttemptCount: number;
                  phoneNumber?: string;
                  preAuthSessionId: string;
              };
              status: "OK";
          }
          | {
              failedCodeInputAttemptCount: number;
              maximumCodeInputAttempts: number;
              status: | "INCORRECT_USER_INPUT_CODE_ERROR"
              | "EXPIRED_USER_INPUT_CODE_ERROR";
          }
          | { status: "RESTART_FLOW_ERROR" },
      >

      1. verifies the code
      2. creates the user if it doesn't exist
      3. tries to link it
      4. marks the email as verified

      Parameters

      • input:
            | {
                deviceId: string;
                preAuthSessionId: string;
                session?: undefined;
                tenantId: string;
                userContext?: Record<string, any>;
                userInputCode: string;
            }
            | {
                linkCode: string;
                preAuthSessionId: string;
                session?: undefined;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<
          | {
              consumedDevice: {
                  email?: string;
                  failedCodeInputAttemptCount: number;
                  phoneNumber?: string;
                  preAuthSessionId: string;
              };
              createdNewRecipeUser: boolean;
              recipeUserId: RecipeUserId;
              status: "OK";
              user: User;
          }
          | {
              failedCodeInputAttemptCount: number;
              maximumCodeInputAttempts: number;
              status: | "INCORRECT_USER_INPUT_CODE_ERROR"
              | "EXPIRED_USER_INPUT_CODE_ERROR";
          }
          | { status: "RESTART_FLOW_ERROR" },
      >

      1. verifies the code
      2. creates the user if it doesn't exist
      3. tries to link it
      4. marks the email as verified

      Parameters

      • input:
            | {
                deviceId: string;
                preAuthSessionId: string;
                session: SessionContainer;
                tenantId: string;
                userContext?: Record<string, any>;
                userInputCode: string;
            }
            | {
                linkCode: string;
                preAuthSessionId: string;
                session: SessionContainer;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<
          | {
              consumedDevice: {
                  email?: string;
                  failedCodeInputAttemptCount: number;
                  phoneNumber?: string;
                  preAuthSessionId: string;
              };
              createdNewRecipeUser: boolean;
              recipeUserId: RecipeUserId;
              status: "OK";
              user: User;
          }
          | {
              failedCodeInputAttemptCount: number;
              maximumCodeInputAttempts: number;
              status: | "INCORRECT_USER_INPUT_CODE_ERROR"
              | "EXPIRED_USER_INPUT_CODE_ERROR";
          }
          | { status: "RESTART_FLOW_ERROR" }
          | {
              reason:
                  | "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
                  | "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
                  | "EMAIL_VERIFICATION_REQUIRED"
                  | "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
              status: "LINKING_TO_SESSION_USER_FAILED";
          },
      >

    • Parameters

      • input: ({ email: string } | { phoneNumber: string }) & {
            session?: SessionContainer;
            tenantId: string;
            userContext?: Record<string, any>;
            userInputCode?: string;
        }

      Returns Promise<
          {
              codeId: string;
              codeLifetime: number;
              deviceId: string;
              linkCode: string;
              preAuthSessionId: string;
              status: "OK";
              timeCreated: number;
              userInputCode: string;
          },
      >

    • Parameters

      • input:
            | { email: string; tenantId: string; userContext?: Record<string, any> }
            | {
                phoneNumber: string;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<string>

    • Parameters

      • input: {
            deviceId: string;
            tenantId: string;
            userContext?: Record<string, any>;
            userInputCode?: string;
        }

      Returns Promise<
          | {
              codeId: string;
              codeLifetime: number;
              deviceId: string;
              linkCode: string;
              preAuthSessionId: string;
              status: "OK";
              timeCreated: number;
              userInputCode: string;
          }
          | { status: "RESTART_FLOW_ERROR"
          | "USER_INPUT_CODE_ALREADY_USED_ERROR" },
      >

    • Parameters

      • input: { deviceId: string; tenantId: string; userContext?: Record<string, any> }

      Returns Promise<undefined | DeviceType>

    • Parameters

      • input: { email: string; tenantId: string; userContext?: Record<string, any> }

      Returns Promise<DeviceType[]>

    • Parameters

      • input: { phoneNumber: string; tenantId: string; userContext?: Record<string, any> }

      Returns Promise<DeviceType[]>

    • Parameters

      • input: {
            preAuthSessionId: string;
            tenantId: string;
            userContext?: Record<string, any>;
        }

      Returns Promise<undefined | DeviceType>

    • Parameters

      • input:
            | { email: string; tenantId: string; userContext?: Record<string, any> }
            | {
                phoneNumber: string;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<{ status: "OK" }>

    • Parameters

      • input:
            | {
                codeId: string;
                tenantId: string;
                userContext?: Record<string, any>;
            }
            | {
                preAuthSessionId: string;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<{ status: "OK" }>

    • Parameters

      • input: TypePasswordlessEmailDeliveryInput & { userContext?: Record<string, any> }

      Returns Promise<void>

    • Parameters

      • input: TypePasswordlessSmsDeliveryInput & { userContext?: Record<string, any> }

      Returns Promise<void>

    • Parameters

      • input:
            | {
                email: string;
                session?: SessionContainer;
                tenantId: string;
                userContext?: Record<string, any>;
            }
            | {
                phoneNumber: string;
                session?: SessionContainer;
                tenantId: string;
                userContext?: Record<string, any>;
            }

      Returns Promise<
          {
              createdNewRecipeUser: boolean;
              recipeUserId: RecipeUserId;
              status: string;
              user: User;
          },
      >

    • Parameters

      • input: {
            email?: null | string;
            phoneNumber?: null | string;
            recipeUserId: RecipeUserId;
            userContext?: Record<string, any>;
        }

      Returns Promise<
          | {
              status: | "OK"
              | "EMAIL_ALREADY_EXISTS_ERROR"
              | "UNKNOWN_USER_ID_ERROR"
              | "PHONE_NUMBER_ALREADY_EXISTS_ERROR";
          }
          | {
              reason: string;
              status: | "EMAIL_CHANGE_NOT_ALLOWED_ERROR"
              | "PHONE_NUMBER_CHANGE_NOT_ALLOWED_ERROR";
          },
      >