These are the SDK reference docs. If you’re looking for docs to implement SuperTokens, you might want to check out the User Guides

Hierarchy

  • default

Index

Constructors

Properties

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

Type declaration

    • (config?: TypeInput): RecipeListFunction
    • Parameters

      • Optional config: TypeInput

      Returns RecipeListFunction

Methods

  • consumeRecoverAccountToken(input: { tenantId: string; token: string; userContext?: Record<string, any> }): Promise<{ email: string; status: "OK"; userId: string } | ConsumeRecoverAccountTokenErrorResponse>
  • Parameters

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

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

  • createRecoverAccountLink(__namedParameters: { email: string; tenantId: string; userContext?: Record<string, any>; userId: string }): Promise<GenerateRecoverAccountTokenErrorResponse | { link: string; status: string }>
  • Parameters

    • __namedParameters: { email: string; tenantId: string; userContext?: Record<string, any>; userId: string }
      • email: string
      • tenantId: string
      • Optional userContext?: Record<string, any>
      • userId: string

    Returns Promise<GenerateRecoverAccountTokenErrorResponse | { link: string; status: string }>

  • generateRecoverAccountToken(input: { email: string; tenantId: string; userContext?: Record<string, any>; userId: string }): Promise<{ status: "OK"; token: string } | GenerateRecoverAccountTokenErrorResponse>
  • We do not make email optional here because we want to allow passing in primaryUserId. If we make email optional, and if the user provides a primaryUserId, then it may result in two problems:

    • there is no recipeUserId = input primaryUserId, in this case, this function will throw an error
    • There is a recipe userId = input primaryUserId, but that recipe has no email, or has wrong email compared to what the user wanted to generate a reset token for.

    And we want to allow primaryUserId being passed in.

    Parameters

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

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

  • getCredential(input: { recipeUserId: string; userContext?: Record<string, any>; webauthnCredentialId: string }): Promise<{ createdAt: number; recipeUserId: RecipeUserId; relyingPartyId: string; status: "OK"; webauthnCredentialId: string } | GetCredentialErrorResponse>
  • Parameters

    • input: { recipeUserId: string; userContext?: Record<string, any>; webauthnCredentialId: string }
      • recipeUserId: string
      • Optional userContext?: Record<string, any>
      • webauthnCredentialId: string

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

  • getGeneratedOptions(input: { tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<{ challenge: string; createdAt: number; email: string; expiresAt: number; origin: string; relyingPartyId: string; relyingPartyName: string; status: "OK"; timeout: string; userPresence: boolean; userVerification: UserVerification; webauthnGeneratedOptionsId: string } | GetGeneratedOptionsErrorResponse>
  • Parameters

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

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

  • getUserFromRecoverAccountToken(input: { tenantId: string; token: string; userContext?: Record<string, any> }): Promise<{ recipeUserId: RecipeUserId; status: "OK"; user: User } | GetUserFromRecoverAccountTokenErrorResponse>
  • Parameters

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

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

  • listCredentials(input: { recipeUserId: string; userContext?: Record<string, any> }): Promise<{ credentials: { createdAt: number; recipeUserId: string; relyingPartyId: string; webauthnCredentialId: string }[]; status: "OK" }>
  • Parameters

    • input: { recipeUserId: string; userContext?: Record<string, any> }
      • recipeUserId: string
      • Optional userContext?: Record<string, any>

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

  • recoverAccount(__namedParameters: { credential: RegistrationPayload; tenantId?: string; token: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<ConsumeRecoverAccountTokenErrorResponse | { status: "OK" } | RegisterCredentialErrorResponse>
  • Parameters

    • __namedParameters: { credential: RegistrationPayload; tenantId?: string; token: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }
      • credential: RegistrationPayload
      • Optional tenantId?: string
      • token: string
      • Optional userContext?: Record<string, any>
      • webauthnGeneratedOptionsId: string

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

  • registerCredential(input: { credential: RegistrationPayload; recipeUserId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<{ status: "OK" } | RegisterCredentialErrorResponse>
  • Parameters

    • input: { credential: RegistrationPayload; recipeUserId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }
      • credential: RegistrationPayload
      • recipeUserId: string
      • Optional userContext?: Record<string, any>
      • webauthnGeneratedOptionsId: string

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

  • registerOptions(input: { attestation: undefined | Attestation; origin: string; relyingPartyId: string; relyingPartyName: string; residentKey: undefined | ResidentKey; supportedAlgorithmIds: undefined | number[]; tenantId: string; timeout: undefined | number; userContext?: Record<string, any>; userPresence: undefined | boolean; userVerification: undefined | UserVerification } & { recoverAccountToken: string } & { attestation: undefined | Attestation; origin: string; relyingPartyId: string; relyingPartyName: string; residentKey: undefined | ResidentKey; supportedAlgorithmIds: undefined | number[]; tenantId: string; timeout: undefined | number; userContext?: Record<string, any>; userPresence: undefined | boolean; userVerification: undefined | UserVerification } & { displayName: undefined | string; email: string }): Promise<{ attestation: Attestation; authenticatorSelection: { requireResidentKey: boolean; residentKey: ResidentKey; userVerification: UserVerification }; challenge: string; createdAt: string; excludeCredentials: { id: string; transports: ("ble" | "hybrid" | "internal" | "nfc" | "usb")[]; type: "public-key" }[]; expiresAt: string; pubKeyCredParams: { alg: number; type: "public-key" }[]; rp: { id: string; name: string }; status: "OK"; timeout: number; user: { displayName: string; id: string; name: string }; webauthnGeneratedOptionsId: string } | RegisterOptionsErrorResponse>
  • Parameters

    • input: { attestation: undefined | Attestation; origin: string; relyingPartyId: string; relyingPartyName: string; residentKey: undefined | ResidentKey; supportedAlgorithmIds: undefined | number[]; tenantId: string; timeout: undefined | number; userContext?: Record<string, any>; userPresence: undefined | boolean; userVerification: undefined | UserVerification } & { recoverAccountToken: string } & { attestation: undefined | Attestation; origin: string; relyingPartyId: string; relyingPartyName: string; residentKey: undefined | ResidentKey; supportedAlgorithmIds: undefined | number[]; tenantId: string; timeout: undefined | number; userContext?: Record<string, any>; userPresence: undefined | boolean; userVerification: undefined | UserVerification } & { displayName: undefined | string; email: string }

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

  • removeCredential(input: { recipeUserId: string; userContext?: Record<string, any>; webauthnCredentialId: string }): Promise<{ status: "OK" } | RemoveCredentialErrorResponse>
  • Parameters

    • input: { recipeUserId: string; userContext?: Record<string, any>; webauthnCredentialId: string }
      • recipeUserId: string
      • Optional userContext?: Record<string, any>
      • webauthnCredentialId: string

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

  • removeGeneratedOptions(input: { tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<{ status: "OK" } | RemoveGeneratedOptionsErrorResponse>
  • Parameters

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

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

  • sendEmail(input: TypeWebauthnRecoverAccountEmailDeliveryInput & { userContext?: Record<string, any> }): Promise<void>
  • sendRecoverAccountEmail(__namedParameters: { email: string; tenantId: string; userContext?: Record<string, any>; userId: string }): Promise<{ link: string; status: string } | { status: string }>
  • Parameters

    • __namedParameters: { email: string; tenantId: string; userContext?: Record<string, any>; userId: string }
      • email: string
      • tenantId: string
      • Optional userContext?: Record<string, any>
      • userId: string

    Returns Promise<{ link: string; status: string } | { status: string }>

  • signIn(input: { credential: AuthenticationPayload; session: undefined | SessionContainer; shouldTryLinkingWithSessionUser: undefined | boolean; tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<{ recipeUserId: RecipeUserId; status: "OK"; user: User } | SignInErrorResponse>
  • Parameters

    • input: { credential: AuthenticationPayload; session: undefined | SessionContainer; shouldTryLinkingWithSessionUser: undefined | boolean; tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }
      • credential: AuthenticationPayload
      • session: undefined | SessionContainer
      • shouldTryLinkingWithSessionUser: undefined | boolean
      • tenantId: string
      • Optional userContext?: Record<string, any>
      • webauthnGeneratedOptionsId: string

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

  • signInOptions(input: { origin: string; relyingPartyId: string; relyingPartyName: string; tenantId: string; timeout: undefined | number; userContext?: Record<string, any>; userPresence: undefined | boolean; userVerification: undefined | UserVerification }): Promise<{ challenge: string; createdAt: string; expiresAt: string; status: "OK"; timeout: number; userVerification: UserVerification; webauthnGeneratedOptionsId: string } | SignInOptionsErrorResponse>
  • Parameters

    • input: { origin: string; relyingPartyId: string; relyingPartyName: string; tenantId: string; timeout: undefined | number; userContext?: Record<string, any>; userPresence: undefined | boolean; userVerification: undefined | UserVerification }
      • origin: string
      • relyingPartyId: string
      • relyingPartyName: string
      • tenantId: string
      • timeout: undefined | number
      • Optional userContext?: Record<string, any>
      • userPresence: undefined | boolean
      • userVerification: undefined | UserVerification

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

  • signUp(input: { credential: RegistrationPayload; session: undefined | SessionContainer; shouldTryLinkingWithSessionUser: undefined | boolean; tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<{ recipeUserId: RecipeUserId; status: "OK"; user: User } | SignUpErrorResponse>
  • Parameters

    • input: { credential: RegistrationPayload; session: undefined | SessionContainer; shouldTryLinkingWithSessionUser: undefined | boolean; tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }
      • credential: RegistrationPayload
      • session: undefined | SessionContainer
      • shouldTryLinkingWithSessionUser: undefined | boolean
      • tenantId: string
      • Optional userContext?: Record<string, any>
      • webauthnGeneratedOptionsId: string

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

  • updateUserEmail(input: { email: string; recipeUserId: string; tenantId: string; userContext?: Record<string, any> }): Promise<{ status: "OK" } | UpdateUserEmailErrorResponse>
  • Parameters

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

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

  • verifyCredentials(input: { credential: AuthenticationPayload; tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }): Promise<{ status: "OK" | "UNKNOWN_USER_ID_ERROR" | "INVALID_CREDENTIALS_ERROR" | "INVALID_OPTIONS_ERROR" | "INVALID_AUTHENTICATOR_ERROR" | "CREDENTIAL_NOT_FOUND_ERROR" | "OPTIONS_NOT_FOUND_ERROR" }>
  • Parameters

    • input: { credential: AuthenticationPayload; tenantId: string; userContext?: Record<string, any>; webauthnGeneratedOptionsId: string }
      • credential: AuthenticationPayload
      • tenantId: string
      • Optional userContext?: Record<string, any>
      • webauthnGeneratedOptionsId: string

    Returns Promise<{ status: "OK" | "UNKNOWN_USER_ID_ERROR" | "INVALID_CREDENTIALS_ERROR" | "INVALID_OPTIONS_ERROR" | "INVALID_AUTHENTICATOR_ERROR" | "CREDENTIAL_NOT_FOUND_ERROR" | "OPTIONS_NOT_FOUND_ERROR" }>

Generated using TypeDoc