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

react-session-dynamodb

v1.0.1

Published

A session management component in React that uses dynamodb as the backend

Downloads

3

Readme

react-session-dynamodb

A session management component in React that uses dynamodb as the backend.

NPM JavaScript Style Guide

Note

This component is under active development. Expect frequent updates.

Overview

This component provides the session management functionality in the superflows architecture.

About Authentication in Superflows

Authentication in superflows is token based. User signs in using email and otp. After successful sign in, a token is generated, stored in the dynamodb and returned to the client side, where it is then encrypted and stored in the local storage. As long as the token present in local storage is valid in dynamodb, the user stays logged in.

Session management

Job of this session management module is to check the validity of the client side token and to return the status as true or false. It does so, by polling the backend (dynamodb) continuously at a configurable time interval (default interval being 15 seconds).

Install

npm install --save react-session-dynamodb

Usage

import React from 'react'

import { Session } from 'react-session-dynamodb'
import 'react-session-dynamodb/dist/index.css'

const App = () => {

  function onSessionCheck(result) {
    console.log('session check result', result);
  }

  return (
  
    /*
      
      interval: polling duration
      onSessionCheck: callback function
      awsRegion: aws region
      awsSecret: aws secret
      awsKey: aws access key
      email: email address (from local storage)
      token: token (from local storage)

    */

    <Session 
      interval={15000}
      onSessionCheck={onSessionCheck}
      awsRegion="awsRegion"
      awsSecret="awsSecret"
      awsKey="awsKeyu"
      email="hru************@**ail.com"
      token="980c914d-6242-4aec-9b2c-c24b050519db"
        />

  )
}

export default App

Tests

PASS src/index.test.js (13.854s)

  • ✓ Render, no token on server (3021ms)
  • ✓ Render, token mismatch with server (3004ms)
  • ✓ Render, token match with server (3006ms)
  • ✓ Render, no local token (3005ms)

-------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -------------|----------|----------|----------|----------|-------------------| All files | 89.19 | 81.82 | 90.91 | 88.24 | | index.js | 95.65 | 85 | 100 | 95.24 | 33 | services.js | 25 | 100 | 0 | 25 | 7,14,15 | utils.js | 100 | 50 | 100 | 100 | 16 | -------------|----------|----------|----------|----------|-------------------| Test Suites: 1 passed, 1 total Tests: 4 passed, 4 total Snapshots: 0 total Time: 15.262s Ran all test suites.

License

MIT © superflows-dev