https://github.com/arjun-9696/cyberauth-utils
Secure and lightweight authentication utility library for Node.js, TypeScript, and Next.js. Includes password hashing, JWT, OAuth helpers, and secure cookie handling.
https://github.com/arjun-9696/cyberauth-utils
bycrypt jswebtoken typescript vitest
Last synced: about 1 year ago
JSON representation
Secure and lightweight authentication utility library for Node.js, TypeScript, and Next.js. Includes password hashing, JWT, OAuth helpers, and secure cookie handling.
- Host: GitHub
- URL: https://github.com/arjun-9696/cyberauth-utils
- Owner: Arjun-9696
- License: mit
- Created: 2025-04-10T10:58:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-10T12:24:43.000Z (about 1 year ago)
- Last Synced: 2025-04-10T13:49:41.198Z (about 1 year ago)
- Topics: bycrypt, jswebtoken, typescript, vitest
- Language: TypeScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ CyberAuth Utils v0.0.1 [](https://www.npmjs.com/package/@arjun-9696/cyberauth-utils)
A lightweight package for secure authentication utilities.
## ๐ Features
- Password hashing and verification
- JWT generation and validation
- OAuth helpers for React/Next.js
- Secure cookie management
## ๐ฆ Package Setup:
- TypeScript support with strict types
- Proper `tsconfig.json` and `tsup.config.ts` for builds
- MIT License included
- Clean `.gitignore` and organized file structure
- Readable `README.md` with professional formatting
## ๐งช Testing:
- Manual testing script (`tests/hash.test.ts`) to verify all core utilities
- Output logs added for confirmation
## ๐ ๏ธ Ready for publishing on npm with name `cyberauth-utils`.
## Installation
```bash
npm install cyberauth-utils
```
## Usage
```ts
import { hashPassword } from 'cyberauth-utils';
const password = 'mySecurePassword123!';
const hashedPassword = await hashPassword(password);
console.log('Hashed Password:', hashedPassword);
```
```ts
import { generateJWT } from 'cyberauth-utils';
const payload = { userId: '123', role: 'admin' };
const secret = 'my_super_secret_key';
const token = generateJWT(payload, secret, { expiresIn: '2h' });
console.log('JWT Token:', token);
```
```ts
import { verifyJWT } from 'cyberauth-utils';
const payload = verifyJWT(token, 'my_super_secret_key');
if (payload) {
console.log('Decoded Payload:', payload);
} else {
console.log('Invalid token');
}
```
```ts
import { setSecureCookie } from 'cyberauth-utils';
const cookie = setSecureCookie('authToken', 'xyz123token', {
maxAgeSeconds: 3600,
path: '/',
httpOnly: true,
secure: true,
sameSite: 'lax',
});
console.log('Set-Cookie Header:', cookie);
```
```ts
import { parseCookies } from 'cyberauth-utils';
const cookieHeader = 'authToken=xyz123token; theme=dark';
const cookies = parseCookies(cookieHeader);
console.log('Parsed Cookies:', cookies);
// Output: { authToken: 'xyz123token', theme: 'dark' }
```
## License
MIT