supertokens-node
    Preparing search index...

    Variable consumeCode

    consumeCode: {
        (
            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>;
                },
        ): 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" },
        >;
        (
            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>;
                },
        ): 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";
            },
        >;
    } = Wrapper.consumeCode

    Type declaration

      • (
            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>;
                },
        ): 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?: 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" },
        >

      • (
            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>;
                },
        ): 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";
            },
        >
        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";
            },
        >