Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Module recipe/thirdpartypasswordless

Index

References

PasswordlessUser

Re-exports PasswordlessUser

RecipeFunctionOptions

Re-exports RecipeFunctionOptions

StateObject

Re-exports StateObject

ThirdPartyUserType

Re-exports ThirdPartyUserType

Type aliases

PasswordlessFlowType

PasswordlessFlowType: "USER_INPUT_CODE" | "MAGIC_LINK" | "USER_INPUT_CODE_AND_MAGIC_LINK"

PostAPIHookContext

PostAPIHookContext: RecipePostAPIHookContext<PreAndPostAPIHookAction>

PreAPIHookContext

PreAPIHookContext: RecipePreAPIHookContext<PreAndPostAPIHookAction>

PreAndPostAPIHookAction

RecipeInterface

RecipeInterface: { clearPasswordlessLoginAttemptInfo: any; consumePasswordlessCode: any; createPasswordlessCode: any; doesPasswordlessUserEmailExist: any; doesPasswordlessUserPhoneNumberExist: any; generateThirdPartyStateToSendToOAuthProvider: any; getAuthorisationURLFromBackend: any; getPasswordlessLinkCodeFromURL: any; getPasswordlessLoginAttemptInfo: any; getPasswordlessPreAuthSessionIdFromURL: any; getThirdPartyAuthCodeFromURL: any; getThirdPartyAuthErrorFromURL: any; getThirdPartyAuthStateFromURL: any; getThirdPartyAuthorisationURLWithQueryParamsAndSetState: any; getThirdPartyStateAndOtherInfoFromStorage: any; resendPasswordlessCode: any; setPasswordlessLoginAttemptInfo: any; setThirdPartyStateAndOtherInfoToStorage: any; thirdPartySignInAndUp: any; verifyAndGetThirdPartyStateOrThrowError: any }

Type declaration

  • clearPasswordlessLoginAttemptInfo:function
    • clearPasswordlessLoginAttemptInfo(input: { userContext: any }): Promise<void>
  • consumePasswordlessCode:function
    • consumePasswordlessCode(input: { deviceId: string; options?: RecipeFunctionOptions; preAuthSessionId: string; userContext: any; userInputCode: string } | { linkCode: string; options?: RecipeFunctionOptions; preAuthSessionId: string; userContext: any }): Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: PasswordlessUser } | { failedCodeInputAttemptCount: number; fetchResponse: Response; maximumCodeInputAttempts: number; status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR" } | { fetchResponse: Response; status: "RESTART_FLOW_ERROR" }>
    • Log the user in using the input code or link code

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      • input: { deviceId: string; options?: RecipeFunctionOptions; preAuthSessionId: string; userContext: any; userInputCode: string } | { linkCode: string; options?: RecipeFunctionOptions; preAuthSessionId: string; userContext: any }

      Returns Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: PasswordlessUser } | { failedCodeInputAttemptCount: number; fetchResponse: Response; maximumCodeInputAttempts: number; status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR" } | { fetchResponse: Response; status: "RESTART_FLOW_ERROR" }>

      {status: "OK", user, createdNewUser: bool} if succesful

  • createPasswordlessCode:function
    • Create and send a code to the user for passwordless auth

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      Returns Promise<{ deviceId: string; fetchResponse: Response; flowType: PasswordlessFlowType; preAuthSessionId: string; status: "OK" }>

      {status: "OK", deviceId, preAuthSessionId, flowType} If successful

  • doesPasswordlessUserEmailExist:function
    • doesPasswordlessUserEmailExist(input: { email: string; options?: RecipeFunctionOptions; userContext: any }): Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>
    • Check if a user with the given email exists

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      Returns Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>

      {status: "OK", doesExist: boolean}

  • doesPasswordlessUserPhoneNumberExist:function
    • doesPasswordlessUserPhoneNumberExist(input: { options?: RecipeFunctionOptions; phoneNumber: string; userContext: any }): Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>
    • Check if a user with the given phone number exists

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      Returns Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>

      {status: "OK", doesExist: boolean}

  • generateThirdPartyStateToSendToOAuthProvider:function
    • generateThirdPartyStateToSendToOAuthProvider(input: { userContext: any }): string
  • getAuthorisationURLFromBackend:function
    • getAuthorisationURLFromBackend(input: { options?: RecipeFunctionOptions; providerId: string; userContext: any }): Promise<{ fetchResponse: Response; status: "OK"; url: string }>
    • Get the URL to be used by the third party provider for redirecting after the auth flow

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      Returns Promise<{ fetchResponse: Response; status: "OK"; url: string }>

      {status: "OK", url}

  • getPasswordlessLinkCodeFromURL:function
    • getPasswordlessLinkCodeFromURL(input: { userContext: any }): string
  • getPasswordlessLoginAttemptInfo:function
    • getPasswordlessLoginAttemptInfo<CustomLoginAttemptInfoProperties>(input: { userContext: any }): Promise<undefined | ({ deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomLoginAttemptInfoProperties)>
    • Get information about the current login attempt from storage

      Type parameters

      • CustomLoginAttemptInfoProperties

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns Promise<undefined | ({ deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomLoginAttemptInfoProperties)>

      {deviceId, preAuthSessionId, flowType} if present, returns undefined otherwise

  • getPasswordlessPreAuthSessionIdFromURL:function
    • getPasswordlessPreAuthSessionIdFromURL(input: { userContext: any }): string
    • Reads and returns the pre auth session id from the current URL

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns string

      The "preAuthSessionId" query parameter from the current URL

  • getThirdPartyAuthCodeFromURL:function
    • getThirdPartyAuthCodeFromURL(input: { userContext: any }): string
    • Returns the auth code from the current URL

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns string

      The "code" query param from the current URL. Returns an empty string if no code exists

  • getThirdPartyAuthErrorFromURL:function
    • getThirdPartyAuthErrorFromURL(input: { userContext: any }): undefined | string
    • Returns the error from the current URL

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns undefined | string

      The "error" query param from the current URL. Returns undefined if no error exists

  • getThirdPartyAuthStateFromURL:function
    • getThirdPartyAuthStateFromURL(input: { userContext: any }): string
    • Returns the auth state from the current URL

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns string

      The "state" query param from the current URL. Returns an empty string if no state exists

  • getThirdPartyAuthorisationURLWithQueryParamsAndSetState:function
    • getThirdPartyAuthorisationURLWithQueryParamsAndSetState(input: { authorisationURL: string; options?: RecipeFunctionOptions; providerClientId?: string; providerId: string; userContext: any }): Promise<string>
    • Get the URL that should be opened for third party authentication

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      • input: { authorisationURL: string; options?: RecipeFunctionOptions; providerClientId?: string; providerId: string; userContext: any }
        • authorisationURL: string
        • Optional options?: RecipeFunctionOptions
        • Optional providerClientId?: string
        • providerId: string
        • userContext: any

      Returns Promise<string>

      URL string

  • getThirdPartyStateAndOtherInfoFromStorage:function
    • getThirdPartyStateAndOtherInfoFromStorage<CustomStateProperties>(input: { userContext: any }): undefined | (StateObject & CustomStateProperties)
    • Get the current login state from storage, this is also used when calling signInUp

      Type parameters

      • CustomStateProperties

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns undefined | (StateObject & CustomStateProperties)

      State object from storage

  • resendPasswordlessCode:function
    • resendPasswordlessCode(input: { deviceId: string; options?: RecipeFunctionOptions; preAuthSessionId: string; userContext: any }): Promise<{ fetchResponse: Response; status: "OK" | "RESTART_FLOW_ERROR" }>
    • Resend the code to the user

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      Returns Promise<{ fetchResponse: Response; status: "OK" | "RESTART_FLOW_ERROR" }>

      {status: "OK"} if succesful

  • setPasswordlessLoginAttemptInfo:function
    • setPasswordlessLoginAttemptInfo<CustomStateProperties>(input: { attemptInfo: { deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomStateProperties; userContext: any }): Promise<void>
    • Set information about the current login attempt to storage

      Type parameters

      • CustomStateProperties

      Parameters

      • input: { attemptInfo: { deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomStateProperties; userContext: any }
        • attemptInfo: { deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomStateProperties
        • userContext: any

      Returns Promise<void>

  • setThirdPartyStateAndOtherInfoToStorage:function
    • setThirdPartyStateAndOtherInfoToStorage<CustomStateProperties>(input: { state: StateObject & CustomStateProperties; userContext: any }): Promise<void>
  • thirdPartySignInAndUp:function
    • thirdPartySignInAndUp(input: { options?: RecipeFunctionOptions; userContext: any }): Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: ThirdPartyUserType } | { fetchResponse: Response; status: "NO_EMAIL_GIVEN_BY_PROVIDER" }>
    • Sign up/Sign in the user, this method uses the login attempt information from storage

      throws

      STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

      Parameters

      Returns Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: ThirdPartyUserType } | { fetchResponse: Response; status: "NO_EMAIL_GIVEN_BY_PROVIDER" }>

      {status: OK, user, createdNewUser: boolean} if succesful

  • verifyAndGetThirdPartyStateOrThrowError:function
    • verifyAndGetThirdPartyStateOrThrowError<CustomStateProperties>(input: { stateFromAuthProvider: string | undefined; stateObjectFromStorage: (StateObject & CustomStateProperties) | undefined; userContext: any }): Promise<StateObject & CustomStateProperties>
    • Verify that the state recieved from the third party provider matches the one in storage

      Type parameters

      • CustomStateProperties

      Parameters

      • input: { stateFromAuthProvider: string | undefined; stateObjectFromStorage: (StateObject & CustomStateProperties) | undefined; userContext: any }
        • stateFromAuthProvider: string | undefined
        • stateObjectFromStorage: (StateObject & CustomStateProperties) | undefined
        • userContext: any

      Returns Promise<StateObject & CustomStateProperties>

UserInput

UserInput: { override?: { functions?: any } } & RecipeModuleUserInput<PreAndPostAPIHookAction>

Functions

Const clearPasswordlessLoginAttemptInfo

  • clearPasswordlessLoginAttemptInfo(input?: { userContext?: any }): Promise<void>

Const consumePasswordlessCode

  • consumePasswordlessCode(input?: { options?: RecipeFunctionOptions; userContext?: any; userInputCode: string } | { options?: RecipeFunctionOptions; userContext?: any }): Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: PasswordlessUser } | { failedCodeInputAttemptCount: number; fetchResponse: Response; maximumCodeInputAttempts: number; status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR" } | { fetchResponse: Response; status: "RESTART_FLOW_ERROR" }>
  • Parameters

    Returns Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: PasswordlessUser } | { failedCodeInputAttemptCount: number; fetchResponse: Response; maximumCodeInputAttempts: number; status: "INCORRECT_USER_INPUT_CODE_ERROR" | "EXPIRED_USER_INPUT_CODE_ERROR" } | { fetchResponse: Response; status: "RESTART_FLOW_ERROR" }>

Const createPasswordlessCode

Const doesPasswordlessUserEmailExist

  • doesPasswordlessUserEmailExist(input: { email: string; options?: RecipeFunctionOptions; userContext?: any }): Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>

Const doesPasswordlessUserPhoneNumberExist

  • doesPasswordlessUserPhoneNumberExist(input: { options?: RecipeFunctionOptions; phoneNumber: string; userContext?: any }): Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>

Const generateThirdPartyStateToSendToOAuthProvider

  • generateThirdPartyStateToSendToOAuthProvider(input?: { userContext?: any }): string

Const getAuthorisationURLFromBackend

  • getAuthorisationURLFromBackend(input: { options?: RecipeFunctionOptions; providerId: string; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK"; url: string }>

Const getPasswordlessLinkCodeFromURL

  • getPasswordlessLinkCodeFromURL(input?: { userContext?: any }): string

Const getPasswordlessLoginAttemptInfo

  • getPasswordlessLoginAttemptInfo<CustomLoginAttemptInfoProperties>(input?: { userContext?: any }): Promise<undefined | ({ deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomLoginAttemptInfoProperties)>

Const getPasswordlessPreAuthSessionIdFromURL

  • getPasswordlessPreAuthSessionIdFromURL(input?: { userContext?: any }): string

Const getThirdPartyAuthCodeFromURL

  • getThirdPartyAuthCodeFromURL(input?: { userContext?: any }): string

Const getThirdPartyAuthErrorFromURL

  • getThirdPartyAuthErrorFromURL(input?: { userContext?: any }): undefined | string

Const getThirdPartyAuthStateFromURL

  • getThirdPartyAuthStateFromURL(input?: { userContext?: any }): string

Const getThirdPartyAuthorisationURLWithQueryParamsAndSetState

  • getThirdPartyAuthorisationURLWithQueryParamsAndSetState(input: { authorisationURL: string; options?: RecipeFunctionOptions; providerClientId?: string; providerId: string; userContext?: any }): Promise<string>

Const getThirdPartyStateAndOtherInfoFromStorage

  • getThirdPartyStateAndOtherInfoFromStorage<CustomStateProperties>(input?: { userContext?: any }): undefined | (StateObject & CustomStateProperties)

Const init

Const resendPasswordlessCode

  • resendPasswordlessCode(input?: { options?: RecipeFunctionOptions; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK" | "RESTART_FLOW_ERROR" }>

Const setPasswordlessLoginAttemptInfo

  • setPasswordlessLoginAttemptInfo<CustomStateProperties>(input: { attemptInfo: { deviceId: string; flowType: PasswordlessFlowType; preAuthSessionId: string } & CustomStateProperties; userContext?: any }): Promise<void>

Const setThirdPartyStateAndOtherInfoToStorage

  • setThirdPartyStateAndOtherInfoToStorage<CustomStateProperties>(input: { state: StateObject & CustomStateProperties; userContext?: any }): Promise<void>

Const signOut

  • signOut(input?: { userContext?: any }): Promise<void>

Const thirdPartySignInAndUp

  • thirdPartySignInAndUp(input?: { options?: RecipeFunctionOptions; userContext?: any }): Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: ThirdPartyUserType } | { fetchResponse: Response; status: "NO_EMAIL_GIVEN_BY_PROVIDER" }>

Const verifyAndGetThirdPartyStateOrThrowError

  • verifyAndGetThirdPartyStateOrThrowError<CustomStateProperties>(input: { stateFromAuthProvider: undefined | string; stateObjectFromStorage: undefined | (StateObject & CustomStateProperties); userContext?: any }): Promise<StateObject & CustomStateProperties>
  • Type parameters

    • CustomStateProperties

    Parameters

    • input: { stateFromAuthProvider: undefined | string; stateObjectFromStorage: undefined | (StateObject & CustomStateProperties); userContext?: any }
      • stateFromAuthProvider: undefined | string
      • stateObjectFromStorage: undefined | (StateObject & CustomStateProperties)
      • Optional userContext?: any

    Returns Promise<StateObject & CustomStateProperties>

Generated using TypeDoc