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/session

Index

Type aliases

APIInterface: { refreshPOST: undefined | ((input: { options: APIOptions; userContext: any }) => Promise<void>); signOutPOST: undefined | ((input: { options: APIOptions; userContext: any }) => Promise<{ status: "OK" }>); verifySession: any }

Type declaration

APIOptions: { config: TypeNormalisedInput; isInServerlessEnv: boolean; recipeId: string; recipeImplementation: RecipeInterface; req: BaseRequest; res: BaseResponse }

Type declaration

RecipeInterface: { createNewSession: any; getAccessTokenLifeTimeMS: any; getAllSessionHandlesForUser: any; getRefreshTokenLifeTimeMS: any; getSession: any; getSessionInformation: any; refreshSession: any; regenerateAccessToken: any; revokeAllSessionsForUser: any; revokeMultipleSessions: any; revokeSession: any; updateAccessTokenPayload: any; updateSessionData: any }

Type declaration

  • createNewSession:function
    • createNewSession(input: { accessTokenPayload?: any; res: any; sessionData?: any; userContext: any; userId: string }): Promise<SessionContainer>
    • Parameters

      • input: { accessTokenPayload?: any; res: any; sessionData?: any; userContext: any; userId: string }
        • Optional accessTokenPayload?: any
        • res: any
        • Optional sessionData?: any
        • userContext: any
        • userId: string

      Returns Promise<SessionContainer>

  • getAccessTokenLifeTimeMS:function
    • getAccessTokenLifeTimeMS(input: { userContext: any }): Promise<number>
  • getAllSessionHandlesForUser:function
    • getAllSessionHandlesForUser(input: { userContext: any; userId: string }): Promise<string[]>
  • getRefreshTokenLifeTimeMS:function
    • getRefreshTokenLifeTimeMS(input: { userContext: any }): Promise<number>
  • getSession:function
  • getSessionInformation:function
    • getSessionInformation(input: { sessionHandle: string; userContext: any }): Promise<SessionInformation>
    • Used to retrieve all session information for a given session handle. Can be used in place of:

      • getSessionData
      • getAccessTokenPayload

      Parameters

      • input: { sessionHandle: string; userContext: any }
        • sessionHandle: string
        • userContext: any

      Returns Promise<SessionInformation>

  • refreshSession:function
    • refreshSession(input: { req: any; res: any; userContext: any }): Promise<SessionContainer>
  • regenerateAccessToken:function
    • regenerateAccessToken(input: { accessToken: string; newAccessTokenPayload?: any; userContext: any }): Promise<{ accessToken?: { createdTime: number; expiry: number; token: string }; session: { handle: string; userDataInJWT: any; userId: string }; status: "OK" }>
    • Parameters

      • input: { accessToken: string; newAccessTokenPayload?: any; userContext: any }
        • accessToken: string
        • Optional newAccessTokenPayload?: any
        • userContext: any

      Returns Promise<{ accessToken?: { createdTime: number; expiry: number; token: string }; session: { handle: string; userDataInJWT: any; userId: string }; status: "OK" }>

  • revokeAllSessionsForUser:function
    • revokeAllSessionsForUser(input: { userContext: any; userId: string }): Promise<string[]>
  • revokeMultipleSessions:function
    • revokeMultipleSessions(input: { sessionHandles: string[]; userContext: any }): Promise<string[]>
    • Parameters

      • input: { sessionHandles: string[]; userContext: any }
        • sessionHandles: string[]
        • userContext: any

      Returns Promise<string[]>

  • revokeSession:function
    • revokeSession(input: { sessionHandle: string; userContext: any }): Promise<boolean>
  • updateAccessTokenPayload:function
    • updateAccessTokenPayload(input: { newAccessTokenPayload: any; sessionHandle: string; userContext: any }): Promise<void>
    • Parameters

      • input: { newAccessTokenPayload: any; sessionHandle: string; userContext: any }
        • newAccessTokenPayload: any
        • sessionHandle: string
        • userContext: any

      Returns Promise<void>

  • updateSessionData:function
    • updateSessionData(input: { newSessionData: any; sessionHandle: string; userContext: any }): Promise<void>
    • Parameters

      • input: { newSessionData: any; sessionHandle: string; userContext: any }
        • newSessionData: any
        • sessionHandle: string
        • userContext: any

      Returns Promise<void>

SessionInformation: { accessTokenPayload: any; expiry: number; sessionData: any; sessionHandle: string; timeCreated: number; userId: string }

Type declaration

  • accessTokenPayload: any
  • expiry: number
  • sessionData: any
  • sessionHandle: string
  • timeCreated: number
  • userId: string

Variables

Error: typeof default = SessionWrapper.Error

Functions

  • createJWT(payload?: any, validitySeconds?: number, userContext?: any): Promise<{ jwt: string; status: "OK" } | { status: "UNSUPPORTED_ALGORITHM_ERROR" }>
  • Parameters

    • Optional payload: any
    • Optional validitySeconds: number
    • userContext: any = {}

    Returns Promise<{ jwt: string; status: "OK" } | { status: "UNSUPPORTED_ALGORITHM_ERROR" }>

  • createNewSession(res: any, userId: string, accessTokenPayload?: any, sessionData?: any, userContext?: any): Promise<SessionContainer>
  • getAllSessionHandlesForUser(userId: string, userContext?: any): Promise<string[]>
  • getJWKS(userContext?: any): Promise<{ keys: JsonWebKey[]; status: "OK" }>
  • getOpenIdDiscoveryConfiguration(userContext?: any): Promise<{ issuer: string; jwks_uri: string; status: "OK" }>
  • getSessionInformation(sessionHandle: string, userContext?: any): Promise<SessionInformation>
  • init(config?: TypeInput): RecipeListFunction
  • refreshSession(req: any, res: any, userContext?: any): Promise<SessionContainer>
  • revokeAllSessionsForUser(userId: string, userContext?: any): Promise<string[]>
  • revokeMultipleSessions(sessionHandles: string[], userContext?: any): Promise<string[]>
  • revokeSession(sessionHandle: string, userContext?: any): Promise<boolean>
  • updateAccessTokenPayload(sessionHandle: string, newAccessTokenPayload: any, userContext?: any): Promise<void>
  • updateSessionData(sessionHandle: string, newSessionData: any, userContext?: any): Promise<void>

Generated using TypeDoc