Skip to content

parthasawa100/typescript-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auth TypeScript

Description

Auth TypeScript is an authentication package for TypeScript applications. It provides a class for handling user authentication and token generation/verification using JSON Web Tokens (JWT).

Installation

You can install Auth TypeScript via npm:

npm install typescript-auth

import { Authentication, User, AuthConfig } from 'typescript-auth';
interface CustomUser extends User {
    username: string;
}
const authConfig: AuthConfig = {
    secretKey: 'your_secret_key_here',
    expiresIn: '1h'
};
const auth = new Authentication<CustomUser>(authConfig);
const user: CustomUser = {
    email: 'example@example.com',
    username: 'example_user'
};
// Login
const token = auth.login(user);
console.log('Generated token:', token);
// Verify
const isTokenValid = auth.verify(token!);
console.log('Is token valid?', isTokenValid);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published