Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-session-dynamodb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-session-dynamodb

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

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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% LinesUncovered Line #s
All files89.1981.8290.9188.24
index.js95.658510095.2433
services.js251000257,14,15
utils.js1005010010016
------------------------------------------------------------------------
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

Keywords

FAQs

Package last updated on 24 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc