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

@hedhog/auth

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hedhog/auth

  • 0.0.26
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
Β 
Created
Source

hedhog/auth

Hedhog Avatar

HedHog Auth is a library designed to handle authentication tasks within the HedHog framework. It provides functionalities for user login, token management, multi-factor authentication (MFA), and password reset, ensuring secure and reliable user authentication processes.

Features

  • Token Verification: Verify authentication tokens for users.
  • Login: Authenticate users with email and password, and handle multi-factor authentication if required.
  • OTP Management: Manage one-time passwords (OTP) for multi-factor authentication.
  • Password Reset: Facilitate password reset requests through email.

Installation

This library is a part of the HedHog framework and is typically included as a dependency in your HedHog projects. Ensure you have the necessary dependencies and setup by following the installation guide in the HedHog framework documentation.

npm i @hedhog/auth
Controller

The AuthController defines the following endpoints:

  • GET /auth/verify: Verify the authentication status of the user.
  • POST /auth/login: Authenticate a user using email and password.
  • POST /auth/otp: Verify an OTP code for multi-factor authentication.
  • POST /auth/forget: Request a password reset link via email.
AuthService

The AuthService provides methods for:

  • verifyToken(token: string): Verify the provided JWT token.
  • generateRandomString(length: number): Generate a random string of specified length.
  • generateRandomNumber(): Generate a random 6-digit number.
  • loginWithEmailAndPassword(email: string, password: string): Authenticate users with email and password and handle multi-factor authentication if required.
  • getToken(user): Generate a JWT token for the authenticated user.
  • forget({ email }: ForgetDTO): Initiate a password reset process for the specified email.
  • otp({ token, code }: OtpDTO): Verify the OTP code provided by the user.

Folder Structure

auth/
β”œβ”€β”€ dist/                        # Compiled JavaScript files from build
β”œβ”€β”€ node_modules/                # Discardable folder with all module dependencies
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ auth.controller.ts         # Defines routes for authentication
β”‚   β”œβ”€β”€ auth.service.ts            # Contains authentication logic
β”‚   β”œβ”€β”€ auth.module.ts             # Authentication module
β”‚   β”œβ”€β”€ index.ts                   # Entry point for auth files
β”‚   β”œβ”€β”€ dto/
β”‚   β”‚   β”œβ”€β”€ forget.dto.ts          # Data Transfer Object for password reset
β”‚   β”‚   β”œβ”€β”€ login.dto.ts           # Data Transfer Object for login
β”‚   β”‚   └── otp.dto.ts             # Data Transfer Object for OTP verification
β”‚   β”œβ”€β”€ decorators/
β”‚   β”‚   β”œβ”€β”€ public.decorator.ts    # Custom decorator to mark public routes
β”‚   β”‚   └── user.decorator.ts      # Custom decorator to get user from request
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── user.type.ts           # Type definitions for user-related data
β”‚   β”œβ”€β”€ enums/
β”‚   β”‚   └── multifactor-type.enum.ts # Enumeration for multi-factor authentication types
β”‚   β”œβ”€β”€ guards/
β”‚   β”‚   └── auth.guard.ts          # Guard for protecting routes
β”‚   β”œβ”€β”€ migrations/
β”‚   β”‚   └── index.ts               # Migration scripts
β”œβ”€β”€ .gitignore                     # Specifies which files Git should ignore
β”œβ”€β”€ package.json                   # Manages dependencies and scripts for the library
β”œβ”€β”€ package-lock.json              # Lock file for package dependencies
β”œβ”€β”€ README.md                      # Documentation for the library
β”œβ”€β”€ tsconfig.lib.json              # TypeScript configuration for the library
└── tsconfig.production.json       # TypeScript configuration for production builds

FAQs

Package last updated on 20 Sep 2024

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