supertokens-node
    Preparing search index...

    Type Alias RecipeInterface

    type RecipeInterface = {
        checkCode: (
            input:
                | {
                    deviceId: string;
                    preAuthSessionId: string;
                    tenantId: string;
                    userContext: UserContext;
                    userInputCode: string;
                }
                | {
                    linkCode: string;
                    preAuthSessionId: string;
                    tenantId: string;
                    userContext: UserContext;
                },
        ) => 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" },
        >;
        consumeCode: (
            input:
                | {
                    deviceId: string;
                    preAuthSessionId: string;
                    session: SessionContainer
                    | undefined;
                    shouldTryLinkingWithSessionUser: boolean | undefined;
                    tenantId: string;
                    userContext: UserContext;
                    userInputCode: string;
                }
                | {
                    linkCode: string;
                    preAuthSessionId: string;
                    session: SessionContainer
                    | undefined;
                    shouldTryLinkingWithSessionUser: boolean | undefined;
                    tenantId: string;
                    userContext: UserContext;
                },
        ) => 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:
                    | "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";
            },
        >;
        createCode: (
            input: ({ email: string } | { phoneNumber: string }) & {
                session: SessionContainer | undefined;
                shouldTryLinkingWithSessionUser: boolean | undefined;
                tenantId: string;
                userContext: UserContext;
                userInputCode?: string;
            },
        ) => Promise<
            {
                codeId: string;
                codeLifetime: number;
                deviceId: string;
                linkCode: string;
                preAuthSessionId: string;
                status: "OK";
                timeCreated: number;
                userInputCode: string;
            },
        >;
        createNewCodeForDevice: (
            input: {
                deviceId: string;
                tenantId: string;
                userContext: UserContext;
                userInputCode?: string;
            },
        ) => 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" },
        >;
        listCodesByDeviceId: (
            input: { deviceId: string; tenantId: string; userContext: UserContext },
        ) => Promise<DeviceType | undefined>;
        listCodesByEmail: (
            input: { email: string; tenantId: string; userContext: UserContext },
        ) => Promise<DeviceType[]>;
        listCodesByPhoneNumber: (
            input: {
                phoneNumber: string;
                tenantId: string;
                userContext: UserContext;
            },
        ) => Promise<DeviceType[]>;
        listCodesByPreAuthSessionId: (
            input: {
                preAuthSessionId: string;
                tenantId: string;
                userContext: UserContext;
            },
        ) => Promise<DeviceType | undefined>;
        revokeAllCodes: (
            input:
                | { email: string; tenantId: string; userContext: UserContext }
                | { phoneNumber: string; tenantId: string; userContext: UserContext },
        ) => Promise<{ status: "OK" }>;
        revokeCode: (
            input:
                | { codeId: string; tenantId: string; userContext: UserContext }
                | {
                    preAuthSessionId: string;
                    tenantId: string;
                    userContext: UserContext;
                },
        ) => Promise<{ status: "OK" }>;
        updateUser: (
            input: {
                email?: string | null;
                phoneNumber?: string | null;
                recipeUserId: RecipeUserId;
                userContext: UserContext;
            },
        ) => Promise<
            | {
                status: | "OK"
                | "UNKNOWN_USER_ID_ERROR"
                | "EMAIL_ALREADY_EXISTS_ERROR"
                | "PHONE_NUMBER_ALREADY_EXISTS_ERROR";
            }
            | {
                reason: string;
                status: | "EMAIL_CHANGE_NOT_ALLOWED_ERROR"
                | "PHONE_NUMBER_CHANGE_NOT_ALLOWED_ERROR";
            },
        >;
    }
    Index

    Properties

    checkCode: (
        input:
            | {
                deviceId: string;
                preAuthSessionId: string;
                tenantId: string;
                userContext: UserContext;
                userInputCode: string;
            }
            | {
                linkCode: string;
                preAuthSessionId: string;
                tenantId: string;
                userContext: UserContext;
            },
    ) => 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" },
    >
    consumeCode: (
        input:
            | {
                deviceId: string;
                preAuthSessionId: string;
                session: SessionContainer
                | undefined;
                shouldTryLinkingWithSessionUser: boolean | undefined;
                tenantId: string;
                userContext: UserContext;
                userInputCode: string;
            }
            | {
                linkCode: string;
                preAuthSessionId: string;
                session: SessionContainer
                | undefined;
                shouldTryLinkingWithSessionUser: boolean | undefined;
                tenantId: string;
                userContext: UserContext;
            },
    ) => 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:
                | "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";
        },
    >
    createCode: (
        input: ({ email: string } | { phoneNumber: string }) & {
            session: SessionContainer | undefined;
            shouldTryLinkingWithSessionUser: boolean | undefined;
            tenantId: string;
            userContext: UserContext;
            userInputCode?: string;
        },
    ) => Promise<
        {
            codeId: string;
            codeLifetime: number;
            deviceId: string;
            linkCode: string;
            preAuthSessionId: string;
            status: "OK";
            timeCreated: number;
            userInputCode: string;
        },
    >
    createNewCodeForDevice: (
        input: {
            deviceId: string;
            tenantId: string;
            userContext: UserContext;
            userInputCode?: string;
        },
    ) => 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" },
    >
    listCodesByDeviceId: (
        input: { deviceId: string; tenantId: string; userContext: UserContext },
    ) => Promise<DeviceType | undefined>
    listCodesByEmail: (
        input: { email: string; tenantId: string; userContext: UserContext },
    ) => Promise<DeviceType[]>
    listCodesByPhoneNumber: (
        input: {
            phoneNumber: string;
            tenantId: string;
            userContext: UserContext;
        },
    ) => Promise<DeviceType[]>
    listCodesByPreAuthSessionId: (
        input: {
            preAuthSessionId: string;
            tenantId: string;
            userContext: UserContext;
        },
    ) => Promise<DeviceType | undefined>
    revokeAllCodes: (
        input:
            | { email: string; tenantId: string; userContext: UserContext }
            | { phoneNumber: string; tenantId: string; userContext: UserContext },
    ) => Promise<{ status: "OK" }>
    revokeCode: (
        input:
            | { codeId: string; tenantId: string; userContext: UserContext }
            | { preAuthSessionId: string; tenantId: string; userContext: UserContext },
    ) => Promise<{ status: "OK" }>
    updateUser: (
        input: {
            email?: string | null;
            phoneNumber?: string | null;
            recipeUserId: RecipeUserId;
            userContext: UserContext;
        },
    ) => Promise<
        | {
            status: | "OK"
            | "UNKNOWN_USER_ID_ERROR"
            | "EMAIL_ALREADY_EXISTS_ERROR"
            | "PHONE_NUMBER_ALREADY_EXISTS_ERROR";
        }
        | {
            reason: string;
            status: | "EMAIL_CHANGE_NOT_ALLOWED_ERROR"
            | "PHONE_NUMBER_CHANGE_NOT_ALLOWED_ERROR";
        },
    >