https://github.com/jai0212/secure-auth-ai
An npm package for advanced sign-in security, including AI-based risk assessment, anomaly detection, real-time PostgreSQL database, automated user management and MFA. Compatible with React, Vue, and Angular
https://github.com/jai0212/secure-auth-ai
ai-security anomaly-detection authentication javascript mfa multi-factor-authentication npm-package postgresql python realtime-database user-management web-development z-score
Last synced: about 1 month ago
JSON representation
An npm package for advanced sign-in security, including AI-based risk assessment, anomaly detection, real-time PostgreSQL database, automated user management and MFA. Compatible with React, Vue, and Angular
- Host: GitHub
- URL: https://github.com/jai0212/secure-auth-ai
- Owner: Jai0212
- License: mit
- Created: 2024-07-18T12:05:03.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-19T11:37:04.000Z (9 months ago)
- Last Synced: 2025-03-21T06:06:19.306Z (about 1 month ago)
- Topics: ai-security, anomaly-detection, authentication, javascript, mfa, multi-factor-authentication, npm-package, postgresql, python, realtime-database, user-management, web-development, z-score
- Language: Python
- Homepage: https://www.npmjs.com/package/secure-auth-ai
- Size: 587 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SecureAuthAI
[](https://www.npmjs.com/package/secure-auth-ai)

🔐 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:
```bash
npm install secure-auth-ai
```Import the package in your project:
```bash
import * as SAA from 'secure-auth-ai';
```Or import specific functions:
```bash
import { initializePackageSAA, signUpSAA } from 'secure-auth-ai';
```All functions are asynchronous and should be used with axios for HTTP requests:
```bash
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 messageWhen 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
```bash
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/`):
```js
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