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

Index

References

Renames and re-exports __type

Type Aliases

GetRedirectionURLContext: AuthRecipeModuleGetRedirectionURLContext
OnHandleEventContext: AuthRecipeModuleOnHandleEventContext | { action: "SUCCESS"; isNewUser: boolean; user: { email: string; id: string }; userContext: any }
PreAPIHookContext: { action: PreAndPostAPIHookAction; requestInit: RequestInit; url: string; userContext: any }

Type declaration

  • action: PreAndPostAPIHookAction
  • requestInit: RequestInit
  • url: string
  • userContext: any
RecipeInterface: { generateStateToSendToOAuthProvider: any; getAuthCodeFromURL: any; getAuthErrorFromURL: any; getAuthStateFromURL: any; getAuthorisationURLFromBackend: any; getAuthorisationURLWithQueryParamsAndSetState: any; getStateAndOtherInfoFromStorage: any; setStateAndOtherInfoToStorage: any; signInAndUp: any; verifyAndGetStateOrThrowError: any }

Type declaration

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

      Parameters

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

      Returns string

      string

  • getAuthCodeFromURL:function
    • getAuthCodeFromURL(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

  • getAuthErrorFromURL:function
    • getAuthErrorFromURL(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

  • getAuthStateFromURL:function
    • getAuthStateFromURL(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

  • 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

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

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

      {status: "OK", url}

  • getAuthorisationURLWithQueryParamsAndSetState:function
    • 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
        • userContext: any

      Returns Promise<string>

      URL string

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

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

      Returns undefined | StateObject & CustomStateProperties

      State object from storage

  • setStateAndOtherInfoToStorage:function
    • setStateAndOtherInfoToStorage<CustomStateProperties>(input: { state: StateObject & CustomStateProperties; userContext: any }): Promise<void>
    • Set the login state to storage

      Type Parameters

      • CustomStateProperties

      Parameters

      • input: { state: StateObject & CustomStateProperties; userContext: any }
        • state: StateObject & CustomStateProperties
        • userContext: any

      Returns Promise<void>

  • signInAndUp:function
    • signInAndUp(input: { options?: RecipeFunctionOptions; userContext: any }): Promise<{ createdNewUser: boolean; fetchResponse: Response; status: "OK"; user: User } | { 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

      • input: { options?: RecipeFunctionOptions; userContext: any }
        • Optional options?: RecipeFunctionOptions
        • userContext: any

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

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

  • verifyAndGetStateOrThrowError:function
    • verifyAndGetStateOrThrowError<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>

User: UserType & { thirdParty: { id: string; userId: string } }
UserInput: { oAuthCallbackScreen?: FeatureBaseConfig; override?: { components?: ComponentOverrideMap; functions?: any } & AuthRecipeUserInputOverride; signInAndUpFeature?: SignInAndUpFeatureUserInput } & AuthRecipeModuleUserInput<GetRedirectionURLContext, PreAndPostAPIHookAction, OnHandleEventContext>

Variables

SignInAndUpCallbackTheme: ComponentType<{}> = ...
SignInAndUpTheme: React.FC<SignInAndUpThemeProps> = ...
ThirdPartyAuth: React.FC<PropsWithChildren<{ requireAuth?: boolean; userContext?: any; onSessionExpired?: any }>> = ...

Functions

  • EmailVerification(prop?: any): Element
  • SignInAndUp(prop?: PropsWithChildren<{ redirectOnSessionExists?: boolean; userContext?: any }>): Element
  • SignInAndUpCallback(prop?: any): Element
  • generateStateToSendToOAuthProvider(input?: { userContext?: any }): string
  • getAuthCodeFromURL(input?: { userContext?: any }): string
  • getAuthErrorFromURL(input?: { userContext?: any }): undefined | string
  • getAuthStateFromURL(input?: { userContext?: any }): string
  • getAuthorisationURLFromBackend(input: { options?: RecipeFunctionOptions; providerId: string; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK"; url: string }>
  • Parameters

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

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

  • getAuthorisationURLWithQueryParamsAndSetState(input: { authorisationURL: string; options?: RecipeFunctionOptions; providerClientId?: string; providerId: string; userContext?: any }): Promise<string>
  • 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>

  • getEmailVerificationTokenFromURL(input?: { userContext?: any }): string
  • getStateAndOtherInfoFromStorage<CustomStateProperties>(input?: { userContext?: any }): undefined | StateObject & CustomStateProperties
  • Type Parameters

    • CustomStateProperties

    Parameters

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

    Returns undefined | StateObject & CustomStateProperties

  • isEmailVerified(input?: { options?: RecipeFunctionOptions; userContext?: any }): Promise<{ fetchResponse: Response; isVerified: boolean; status: "OK" }>
  • Parameters

    • Optional input: { options?: RecipeFunctionOptions; userContext?: any }
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

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

  • redirectToAuth(input?: "signin" | "signup" | { redirectBack?: boolean; show?: "signin" | "signup" }): Promise<void>
  • redirectToThirdPartyLogin(input: { thirdPartyId: string; userContext?: any }): Promise<{ status: "OK" | "ERROR" }>
  • Parameters

    • input: { thirdPartyId: string; userContext?: any }
      • thirdPartyId: string
      • Optional userContext?: any

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

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

    • Optional input: { options?: RecipeFunctionOptions; userContext?: any }
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

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

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

    • CustomStateProperties

    Parameters

    • input: { state: StateObject & CustomStateProperties; userContext?: any }
      • state: StateObject & CustomStateProperties
      • Optional userContext?: any

    Returns Promise<void>

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

    • Optional input: { options?: RecipeFunctionOptions; userContext?: any }
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

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

  • signOut(input?: { userContext?: any }): Promise<void>
  • verifyAndGetStateOrThrowError<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>

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

    • Optional input: { options?: RecipeFunctionOptions; userContext?: any }
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

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

Generated using TypeDoc