supertokens-node
    Preparing search index...

    Type Alias RecipeInterface

    type RecipeInterface = {
        consumeRecoverAccountToken(
            input: { tenantId: string; token: string; userContext: UserContext },
        ): Promise<
            | ConsumeRecoverAccountTokenErrorResponse
            | { email: string; status: "OK"; userId: string },
        >;
        createNewRecipeUser(
            input: {
                credential: RegistrationPayload;
                tenantId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<
            | CreateNewRecipeUserErrorResponse
            | { recipeUserId: RecipeUserId; status: "OK"; user: User },
        >;
        generateRecoverAccountToken(
            input: {
                email: string;
                tenantId: string;
                userContext: UserContext;
                userId: string;
            },
        ): Promise<
            | GenerateRecoverAccountTokenErrorResponse
            | { status: "OK"; token: string },
        >;
        getCredential(
            input: {
                recipeUserId: string;
                userContext: UserContext;
                webauthnCredentialId: string;
            },
        ): Promise<
            | GetCredentialErrorResponse
            | {
                createdAt: number;
                recipeUserId: RecipeUserId;
                relyingPartyId: string;
                status: "OK";
                webauthnCredentialId: string;
            },
        >;
        getGeneratedOptions(
            input: {
                tenantId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<
            | GetGeneratedOptionsErrorResponse
            | {
                challenge: string;
                createdAt: number;
                email?: string;
                expiresAt: number;
                origin: string;
                relyingPartyId: string;
                relyingPartyName: string;
                status: "OK";
                timeout: number;
                userPresence: boolean;
                userVerification: UserVerification;
                webauthnGeneratedOptionsId: string;
            },
        >;
        getUserFromRecoverAccountToken(
            input: { tenantId: string; token: string; userContext: UserContext },
        ): Promise<
            | GetUserFromRecoverAccountTokenErrorResponse
            | { recipeUserId?: RecipeUserId; status: "OK"; user: User },
        >;
        listCredentials(
            input: { recipeUserId: string; userContext: UserContext },
        ): Promise<
            {
                credentials: {
                    createdAt: number;
                    recipeUserId: string;
                    relyingPartyId: string;
                    webauthnCredentialId: string;
                }[];
                status: "OK";
            },
        >;
        registerCredential(
            input: {
                credential: RegistrationPayload;
                recipeUserId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<RegisterCredentialErrorResponse | { status: "OK" }>;
        registerOptions(
            input: {
                attestation: Attestation | undefined;
                origin: string;
                relyingPartyId: string;
                relyingPartyName: string;
                residentKey: ResidentKey | undefined;
                supportedAlgorithmIds: number[] | undefined;
                tenantId: string;
                timeout: number | undefined;
                userContext: UserContext;
                userPresence: boolean | undefined;
                userVerification: UserVerification | undefined;
            } & (
                | { recoverAccountToken: string }
                | { displayName: string | undefined; email: string }
            ),
        ): Promise<
            | RegisterOptionsErrorResponse
            | {
                attestation: Attestation;
                authenticatorSelection: {
                    requireResidentKey: boolean;
                    residentKey: ResidentKey;
                    userVerification: UserVerification;
                };
                challenge: string;
                createdAt: number;
                excludeCredentials: {
                    id: string;
                    transports: ("ble" | "hybrid" | "internal" | "nfc" | "usb")[];
                    type: "public-key";
                }[];
                expiresAt: number;
                pubKeyCredParams: { alg: number; type: "public-key" }[];
                rp: { id: string; name: string };
                status: "OK";
                timeout: number;
                user: { displayName: string; id: string; name: string };
                webauthnGeneratedOptionsId: string;
            },
        >;
        removeCredential(
            input: {
                recipeUserId: string;
                userContext: UserContext;
                webauthnCredentialId: string;
            },
        ): Promise<RemoveCredentialErrorResponse | { status: "OK" }>;
        removeGeneratedOptions(
            input: {
                tenantId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<RemoveGeneratedOptionsErrorResponse | { status: "OK" }>;
        signIn(
            input: {
                credential: AuthenticationPayload;
                session: SessionContainer | undefined;
                shouldTryLinkingWithSessionUser: boolean | undefined;
                tenantId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<
            | SignInErrorResponse
            | { recipeUserId: RecipeUserId; status: "OK"; user: User },
        >;
        signInOptions(
            input: {
                origin: string;
                relyingPartyId: string;
                relyingPartyName: string;
                tenantId: string;
                timeout: number | undefined;
                userContext: UserContext;
                userPresence: boolean | undefined;
                userVerification: UserVerification | undefined;
            },
        ): Promise<
            | SignInOptionsErrorResponse
            | {
                challenge: string;
                createdAt: number;
                expiresAt: number;
                status: "OK";
                timeout: number;
                userVerification: UserVerification;
                webauthnGeneratedOptionsId: string;
            },
        >;
        signUp(
            input: {
                credential: RegistrationPayload;
                session: SessionContainer | undefined;
                shouldTryLinkingWithSessionUser: boolean | undefined;
                tenantId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<
            | SignUpErrorResponse
            | { recipeUserId: RecipeUserId; status: "OK"; user: User },
        >;
        updateUserEmail(
            input: {
                email: string;
                recipeUserId: string;
                tenantId: string;
                userContext: UserContext;
            },
        ): Promise<UpdateUserEmailErrorResponse | { status: "OK" }>;
        verifyCredentials(
            input: {
                credential: AuthenticationPayload;
                tenantId: string;
                userContext: UserContext;
                webauthnGeneratedOptionsId: string;
            },
        ): Promise<
            | VerifyCredentialsErrorResponse
            | { recipeUserId: RecipeUserId; status: "OK"; user: User },
        >;
    }
    Index

    Methods

    • Parameters

      • input: { tenantId: string; token: string; userContext: UserContext }

      Returns Promise<
          | ConsumeRecoverAccountTokenErrorResponse
          | { email: string; status: "OK"; userId: string },
      >

    • This function is meant only for creating the recipe in the core and nothing else. We added this even though signUp exists cause devs may override signup expecting it to be called just during sign up. But we also need a version of signing up which can be called during operations like creating a user during account recovery flow.

      Parameters

      • input: {
            credential: RegistrationPayload;
            tenantId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<
          | CreateNewRecipeUserErrorResponse
          | { recipeUserId: RecipeUserId; status: "OK"; user: User },
      >

    • We pass in the email as well to this function cause the input userId may not be associated with an webauthn account. In this case, we need to know which email to use to create an webauthn account later on.

      Parameters

      • input: { email: string; tenantId: string; userContext: UserContext; userId: string }

      Returns Promise<
          | GenerateRecoverAccountTokenErrorResponse
          | { status: "OK"; token: string },
      >

    • Parameters

      • input: { recipeUserId: string; userContext: UserContext; webauthnCredentialId: string }

      Returns Promise<
          | GetCredentialErrorResponse
          | {
              createdAt: number;
              recipeUserId: RecipeUserId;
              relyingPartyId: string;
              status: "OK";
              webauthnCredentialId: string;
          },
      >

    • Parameters

      • input: {
            tenantId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<
          | GetGeneratedOptionsErrorResponse
          | {
              challenge: string;
              createdAt: number;
              email?: string;
              expiresAt: number;
              origin: string;
              relyingPartyId: string;
              relyingPartyName: string;
              status: "OK";
              timeout: number;
              userPresence: boolean;
              userVerification: UserVerification;
              webauthnGeneratedOptionsId: string;
          },
      >

    • Parameters

      • input: { tenantId: string; token: string; userContext: UserContext }

      Returns Promise<
          | GetUserFromRecoverAccountTokenErrorResponse
          | { recipeUserId?: RecipeUserId; status: "OK"; user: User },
      >

    • Parameters

      • input: { recipeUserId: string; userContext: UserContext }

      Returns Promise<
          {
              credentials: {
                  createdAt: number;
                  recipeUserId: string;
                  relyingPartyId: string;
                  webauthnCredentialId: string;
              }[];
              status: "OK";
          },
      >

    • Parameters

      • input: {
            credential: RegistrationPayload;
            recipeUserId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<RegisterCredentialErrorResponse | { status: "OK" }>

    • Parameters

      • input: {
            attestation: Attestation | undefined;
            origin: string;
            relyingPartyId: string;
            relyingPartyName: string;
            residentKey: ResidentKey | undefined;
            supportedAlgorithmIds: number[] | undefined;
            tenantId: string;
            timeout: number | undefined;
            userContext: UserContext;
            userPresence: boolean | undefined;
            userVerification: UserVerification | undefined;
        } & (
            | { recoverAccountToken: string }
            | { displayName: string | undefined; email: string }
        )

      Returns Promise<
          | RegisterOptionsErrorResponse
          | {
              attestation: Attestation;
              authenticatorSelection: {
                  requireResidentKey: boolean;
                  residentKey: ResidentKey;
                  userVerification: UserVerification;
              };
              challenge: string;
              createdAt: number;
              excludeCredentials: {
                  id: string;
                  transports: ("ble" | "hybrid" | "internal" | "nfc" | "usb")[];
                  type: "public-key";
              }[];
              expiresAt: number;
              pubKeyCredParams: { alg: number; type: "public-key" }[];
              rp: { id: string; name: string };
              status: "OK";
              timeout: number;
              user: { displayName: string; id: string; name: string };
              webauthnGeneratedOptionsId: string;
          },
      >

    • Parameters

      • input: { recipeUserId: string; userContext: UserContext; webauthnCredentialId: string }

      Returns Promise<RemoveCredentialErrorResponse | { status: "OK" }>

    • Parameters

      • input: {
            tenantId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<RemoveGeneratedOptionsErrorResponse | { status: "OK" }>

    • Parameters

      • input: {
            credential: AuthenticationPayload;
            session: SessionContainer | undefined;
            shouldTryLinkingWithSessionUser: boolean | undefined;
            tenantId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<
          | SignInErrorResponse
          | { recipeUserId: RecipeUserId; status: "OK"; user: User },
      >

    • Parameters

      • input: {
            origin: string;
            relyingPartyId: string;
            relyingPartyName: string;
            tenantId: string;
            timeout: number | undefined;
            userContext: UserContext;
            userPresence: boolean | undefined;
            userVerification: UserVerification | undefined;
        }

      Returns Promise<
          | SignInOptionsErrorResponse
          | {
              challenge: string;
              createdAt: number;
              expiresAt: number;
              status: "OK";
              timeout: number;
              userVerification: UserVerification;
              webauthnGeneratedOptionsId: string;
          },
      >

    • Parameters

      • input: {
            credential: RegistrationPayload;
            session: SessionContainer | undefined;
            shouldTryLinkingWithSessionUser: boolean | undefined;
            tenantId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<
          | SignUpErrorResponse
          | { recipeUserId: RecipeUserId; status: "OK"; user: User },
      >

    • Parameters

      • input: {
            email: string;
            recipeUserId: string;
            tenantId: string;
            userContext: UserContext;
        }

      Returns Promise<UpdateUserEmailErrorResponse | { status: "OK" }>

    • Parameters

      • input: {
            credential: AuthenticationPayload;
            tenantId: string;
            userContext: UserContext;
            webauthnGeneratedOptionsId: string;
        }

      Returns Promise<
          | VerifyCredentialsErrorResponse
          | { recipeUserId: RecipeUserId; status: "OK"; user: User },
      >