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

Hierarchy

  • default

Index

Constructors

constructor

Methods

Static generateStateToSendToOAuthProvider

  • generateStateToSendToOAuthProvider(input?: { userContext?: any }): string
  • Generate a new state that will be sent to the third party provider

    Parameters

    • Optional input: { userContext?: any }
      • Optional userContext?: any

    Returns string

    string

Static getAuthCodeFromURL

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

    Parameters

    • Optional input: { userContext?: any }
      • Optional userContext?: any

    Returns string

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

Static getAuthErrorFromURL

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

    Parameters

    • Optional input: { userContext?: any }
      • Optional userContext?: any

    Returns undefined | string

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

Static getAuthStateFromURL

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

    Parameters

    • Optional input: { userContext?: any }
      • Optional userContext?: any

    Returns string

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

Static getAuthorisationURLFromBackend

  • 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}

Static getAuthorisationURLWithQueryParamsAndSetState

  • getAuthorisationURLWithQueryParamsAndSetState(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
      • Optional userContext?: any

    Returns Promise<string>

    URL string

Static getStateAndOtherInfoFromStorage

  • getStateAndOtherInfoFromStorage<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

    • Optional input: { userContext?: any }
      • Optional userContext?: any

    Returns undefined | (StateObject & CustomStateProperties)

    State object from storage

Static init

Static setStateAndOtherInfoToStorage

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

Static signInAndUp

  • signInAndUp(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

Static signOut

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

Static verifyAndGetStateOrThrowError

  • verifyAndGetStateOrThrowError<CustomStateProperties>(input: { stateFromAuthProvider: undefined | string; stateObjectFromStorage: undefined | (StateObject & CustomStateProperties); 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: 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