npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bento-core/session-timeout

v1.0.0

Published

This package provides a session timeout component that handles:

Downloads

56

Readme

Introduction

This package provides a session timeout component that handles:

  • An inactivity timer and session TTL checker
  • A timeout warning dialog
  • Session timeout/TTL extension

and is easy to integrate with the @bento-core/authentication package. For the component's technical details, please see DESIGN.md.

See below for usage instructions.

Usage

Quick Start

import { SessionTimeoutGenerator } from '@bento-core/session-timeout';

// Generate the component
const { SessionTimeout } = SessionTimeoutGenerator({
  /** See Generator Options **/
});

// Use the component (e.g. In LayoutView)
const Layout = (props) => {
  return (
    <>
      {/* ... other components */ }

      <HashRouter>
        <>
          {/* ... other components */ }

          <SessionTimeout />

          {/* ... other components */ }
        </>
      </HashRouter>
    </>
  );
};

Generator Configuration

See the available DEFAULT_CONFIG_SESSIONTIMEOUT object to understand the component generator options. You can choose to override config, and/or selectors. You DO NOT need to override all of the options if you don't want to. The component generator will only use the options you provide.

export const DEFAULT_CONFIG_SESSIONTIMEOUT = {
  // Misc. Configuration Options
  config: {
    // Show the timeout warning dialog N seconds before the session expires
    thresholdTime: 300,
    // Interval to ping the server ttl endpoint in seconds
    pingInterval: 10,
    // The message to show if the extend session request fails (JSX Component or string)
    extendSessionError: 'Unable to extend session. Please try again.',
    // The message to show after the user has signed out (JSX Component or string)
    afterSignout: (
      <div>
        <div>This authenticated session is no longer valid.</div>
        <div>Please login to establish a new session.</div>
      </div>
    ),
    // The endpoint to ping to extend the session
    extendEndpoint: '',
    // The endpoint to ping to get the session ttl
    ttlEndpoint: '',
  },

  // Redux State Selectors
  selectors: {
    /**
     * Selects whether the user is signed in from the global Redux state
     *
     * Note:
     * - If a user is signed in, the component is activated.
     *
     *
     * @param {object} state Redux state
     * @returns {boolean} Whether the user is signed in
     */
    isSignedIn: (state) => state.login && state.login.isSignedIn,
  },
};

Exports

This component exports the following components and objects by default. You may use them as necessary.

  • SessionTimeoutGenerator - The component generator function
  • DEFAULT_CONFIG_SESSIONTIMEOUT - The default configuration object

Props

This component, which is generated by the provided generator, accepts the following props directly. The default value is specified, along with the possible values. The classes prop will override the default styling for any provided classes.

<SessionTimeout
  title={undefined}             // string|React.Component The title of the modal
  body={undefined}              // string|React.Componemnt The body text of the modal.
  classes={undefined}           // object The classes to apply to the modal
  signOut={undefined}           // Function to sign out the user when the session expires and any other actions to take
  showNotification={undefined}  // Function to show a notification to the user
/>