Function useSessionStore

  • A Pinia store for storing Solid log-in sessions. It uses @inrupt/solid-client-authn-browser internally, and the user should manage the authentication flow (e.g. callback). It exposes session-related variables as states, and actions for session mangement.

    Parameters

    • Optional pinia: null | Pinia
    • Optional hot: StoreGeneric

    Returns PiniaStore<useSessionStore>

Properties

info: undefined | {
    clientAppId?: string;
    expirationDate?: number;
    isLoggedIn: boolean;
    sessionId: string;
    webId?: string;
}

An (reactive) ISessionInfo object.

Type declaration

  • Optional clientAppId?: string
  • Optional expirationDate?: number
  • isLoggedIn: boolean
  • sessionId: string
  • Optional webId?: string
isLoggedIn: boolean

(Reactive) whether the session is logged-in or not

session: {
    events: { on: { (eventName: "login", listener: () => void): ISessionEventListener; (eventName: "logout", listener: () => void): ISessionEventListener; (eventName: "sessionExpired", listener: () => void): ISessionEventListener; (eventName: "sessionRestore", listener: (currentUrl: string) => unknown): ISessionEventListener; (...;
    fetch: any;
    handleIncomingRedirect: ((inputOptions?) => Promise<undefined | ISessionInfo>);
    info: { isLoggedIn: boolean; webId?: string | undefined; clientAppId?: string | undefined; sessionId: string; expirationDate?: number | undefined; };
    login: ((options) => Promise<void>);
    logout: ((options?) => Promise<void>);
    onError(callback) => void;
    onLogin(callback) => void;
    onLogout(callback) => void;
    onSessionExpiration(callback) => void;
    onSessionRestore(callback) => void;
}

The Session object. Reactivity is lost. Useful mainly for its functions (e.g. fetch())

Type declaration

  • Readonly events: { on: { (eventName: "login", listener: () => void): ISessionEventListener; (eventName: "logout", listener: () => void): ISessionEventListener; (eventName: "sessionExpired", listener: () => void): ISessionEventListener; (eventName: "sessionRestore", listener: (currentUrl: string) => unknown): ISessionEventListener; (...
  • fetch: any
  • handleIncomingRedirect: ((inputOptions?) => Promise<undefined | ISessionInfo>)
      • (inputOptions?): Promise<undefined | ISessionInfo>
      • Parameters

        • Optional inputOptions: string | IHandleIncomingRedirectOptions

        Returns Promise<undefined | ISessionInfo>

  • Readonly info: { isLoggedIn: boolean; webId?: string | undefined; clientAppId?: string | undefined; sessionId: string; expirationDate?: number | undefined; }
  • login: ((options) => Promise<void>)
      • (options): Promise<void>
      • Parameters

        • options: default

        Returns Promise<void>

  • logout: ((options?) => Promise<void>)
      • (options?): Promise<void>
      • Parameters

        • Optional options: ILogoutOptions

        Returns Promise<void>

  • onError:function
    • Parameters

      • callback: ((error, errorDescription?) => unknown)
          • (error, errorDescription?): unknown
          • Parameters

            • error: null | string
            • Optional errorDescription: null | string

            Returns unknown

      Returns void

  • onLogin:function
    • Parameters

      • callback: (() => unknown)
          • (): unknown
          • Returns unknown

      Returns void

  • onLogout:function
    • Parameters

      • callback: (() => unknown)
          • (): unknown
          • Returns unknown

      Returns void

  • onSessionExpiration:function
    • Parameters

      • callback: (() => unknown)
          • (): unknown
          • Returns unknown

      Returns void

  • onSessionRestore:function
    • Parameters

      • callback: ((currentUrl) => unknown)
          • (currentUrl): unknown
          • Parameters

            • currentUrl: string

            Returns unknown

      Returns void

webid: string

(Reactive) The webid of the current user

Methods

  • Handles the redirect after log-in in the IDP. Roughly resmbles the session.handleIncomingRedirect() call, but with explicit parameters.

    Parameters

    • Optional redirectUrl: string

      The redirectUrl that this function call resembles. It can be undefined.

    • Optional restorePreviousSession: boolean

      Whether to restore the previous sesison or not

    Returns Promise<undefined | ISessionInfo>

    Session info if the function is invoked while the actual callback; or undefined

  • Perform log-in

    Parameters

    • solidIdentityProvider: string

      IDP for performing log-in

    • redirectUrl: string

      The (absolute URL of) place to redirect to (to handle callback)

    • Optional clientName: string

      The name of the application that request the log-in

    Returns Promise<void>

  • Log-out

    Returns Promise<void>

Generated using TypeDoc