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

secure-auth-ai

v1.0.7

Published

A package for advanced sign-in security, including MFA, real-time PostgreSQL management, AI-based risk assessment, and anomaly detection. Compatible with React, Vue, and Angular, SecureAuthAI automates user management and enhances login protection.

Downloads

64

Readme

SecureAuthAI

npm version npm Frameworks

🔐 SecureAuthAI offers web developers a comprehensive solution for implementing secure sign-in functionalities.

This npm package integrates multi-factor authentication (MFA), real-time PostgreSQL database management, statistical anomaly detection, and a custom AI model. Designed to enhance login security, it automates user management tasks and ensures robust protection against unauthorized access.

It integrates seamlessly with popular web frameworks like React, Vue, and Angular.

Features

  • AI-Based Risk Assessment: Custom AI model detects unsafe login attempts based on location, device, time, and attempts.
  • Anomaly Detection: Statistical methods (Z-Score Calculation) to identify anomalies and prevent unauthorized access.
  • MFA Integration: Enhances security with multi-factor authentication using a secret key.
  • Realtime PostgreSQL Database: Store user details securely with customizable functions provided out-of-the-box.
  • Hassle-Free Implementation: Pre-made functions handle database interactions, eliminating the need for manual API calls.
  • Security: Passwords are tokenized, and user-specific details are automatically managed to prevent security breaches.

Framework Support

SecureAuthAI integrates seamlessly with popular web frameworks:

Installation & Usage:

Install SecureAuthAI via npm:

npm install secure-auth-ai

Import the package in your project:

import * as SAA from 'secure-auth-ai';

Or import specific functions:

import { initializePackageSAA, signUpSAA } from 'secure-auth-ai';

All functions are asynchronous and should be used with axios for HTTP requests:

const response = await initializePackageSAA();

Each response has three attributes to it:

  • value - any value that needs to be returned. If not, or in case of an error, this will be either an empty string or []
  • success - true if request was successful, false otherwise
  • message - message for debugging in case of an error or a success message

When you first use the package, you must call the function initializePackageSAA() which will give you a token that refers to your table. This token is the first parameter in all other functions.

Example

import { initializePackageSAA, signUpSAA, updateUserDetailsSAA, getUserDetailsSAA } from 'secure-auth-ai';
 
const SECURE_AUTH_AI_TABLE_KEY = await initializePackageSAA(["email"]);

const signUpResponse = await signUpSAA(SECURE_AUTH_AI_TABLE_KEY, "hello", {"email": "[email protected]", "phone_number": "+123456789"});

if (signUpResponse.success) {
    const updateResponse = await updateUserDetailsSAA(SECURE_AUTH_AI_TABLE_KEY, "email", "[email protected]", {"phone_number": "+199999999"});

    console.log(updateResponse.message);

    const detailsResponse = await getUserDetailsSAA(SECURE_AUTH_AI_TABLE_KEY, "email", "[email protected]");

    console.log(detailsResponse.value);
}

Everytime the function logInSAA() is called, using the AI model and anomaly detection, it is checked whether the login attempt is safe or not. If it is not safe, you are required to call verifyMfaSSA() to do the MFA.

NOTE: Initally it can take about a minute to get a response as the backend needs to load up.

Available Functions

  • initializePackageSAA
  • signUpSAA
  • logInSAA
  • verifyMfaSAA
  • getUserDetailsSAA
  • getAllDetailsSAA
  • updateUserDetailsSAA
  • addColumnSAA
  • removeColumnSAA
  • removeUserSAA

NOTE: All functions are ASYNCHRONOUS

For detailed usage of each function, refer to the api.js file.

Technical Aspects

  • Backend: Python backend hosted on Render
  • Database: PostgreSQL hosted on Neon
  • Package: JavaScript and Node.js, published on npm
  • AI Model:
    • Created using:
      • XGBoost Classifier
      • Random Forest Classifier
    • Training Data based on change in:
      • Location
      • Device
      • Time
      • Attempts
  • Anomaly Detection: Z-Score Calculation for detecting unusual login patterns.
  • Prediction: Based on the variation in location, device, time & attempts, along with the anomaly detection, it is decided whether a particular login attempt is safe or not

Files

  • backend/ - Core logic and AI model implementation.
  • api.js - API calls.

Webpack Configuration

If you're using React (Webpack) and encounter issues with missing core Node.js modules (like crypto), you may need to update your Webpack configuration. Add the following to your webpack.config.js (found inside node_modules/react-scripts/config/):

resolve: {
  fallback: {
    crypto: false,
    // Add other fallbacks if necessary
  }
}

Acknowledgments

Special thanks to Render, Neon, and npm for their support in hosting and distributing this package.

Contact

For suggestions, feedback, collaborations, or bug reports, please contact me via email: [email protected]

Author and Date
by Jai Joshi
Updated on 19th July, 2024