asyntax-auth
v1.0.0
Published
A simple simulated authentication library for Node.js projects. Intended for frontend prototyping and testing only. **Not for production use!**
Readme
asyntax-auth
A simple simulated authentication library for Node.js projects. Intended for frontend prototyping and testing only. Not for production use!
Installation
Install from npm:
npm install asyntax-auth
# or
yarn add asyntax-auth
# or
pnpm add asyntax-authUsage
1. Import and Initialize
const { AuthKit } = require('asyntax-auth');
const auth = new AuthKit();2. Register a User
await auth.register('[email protected]', 'password123');3. Login
const { token, user } = await auth.login('[email protected]', 'password123');
console.log(token, user);4. Get Current User
const currentUser = auth.getCurrentUser();
console.log(currentUser);5. Logout
auth.logout();6. Verify Token
const isValid = auth.verifyToken(token);
console.log(isValid); // true or false7. Request Password Reset
const resetToken = await auth.requestPasswordReset('[email protected]');
console.log(resetToken);8. Reset Password
const success = await auth.resetPassword(resetToken, 'newPassword123');
console.log(success); // true if successfulTypeScript Usage
import { AuthKit } from 'asyntax-auth';
const auth = new AuthKit();
// ...same API as aboveAPI Reference
register(email, password)– Register a new user.login(email, password)– Log in and receive a token and user object.getCurrentUser()– Get the currently logged-in user.logout()– Log out the current user.verifyToken(token)– Check if a token is valid.requestPasswordReset(email)– Request a password reset token.resetPassword(resetToken, newPassword)– Reset password using the token.
Notes
- All data is stored in-memory and will be lost when the process exits.
- Passwords are stored in plain text for simulation only.
- Do not use in production environments.
License
MIT
