JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q21274F
  • License MIT

A package designed for web developers seeking to implement secure sign-up and log-in functionalities with advanced security measures...

Package Exports

  • secure-auth-ai
  • secure-auth-ai/api.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (secure-auth-ai) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SecureAuthAI

npm version

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 using Z-score calculation, 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 Model: Custom AI model for detecting unsafe login attempts based on location, device, time, and number of attempts.
  • Anomaly Detection: Statistical methods (Z-Score Calculation) to identify anomalies and prevent unauthorized access.
  • MFA Integration: Multi-Factor Authentication using a secret key to enhance login security.
  • 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:

React Vue.js Angular

Installation & Usage:

Install SecureAuthAI via npm:

npm i 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 which must be used to refer to your table in other functions. 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": "placeholder@example.com", "phone_number": "+123456789"});

if (signUpResponse.success) {
    const updateResponse = await updateUserDetailsSAA(SECURE_AUTH_AI_TABLE_KEY, "email", "placeholder@example.com", {"phone_number": "+199999999"});

    console.log(updateResponse.message)

    const detailsResponse = await getUserDetailsSAA(SECURE_AUTH_AI_TABLE_KEY, "email", "placeholder@example.com");

    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.

Available Functions

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

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

Technical Aspects

  • Backend: Python backend hosted on Render.
  • Database: PostgreSQL hosted on Neon.
  • Package: Written in JavaScript, 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.
  • frontend/ - API calls and frontend integration.

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: jj.joshijai@gmail.com

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