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

@hedhog/auth

v0.0.26

Published

<p align="center"> <img src="https://avatars.githubusercontent.com/u/177489127?s=200&v=4" alt="Hedhog Avatar" /> </p>

Downloads

1,664

Readme

hedhog/auth

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