@sa2-movie-ticket/passport
v1.0.5
Published
Passport microservice for movie ticket booking system
Readme
@sa2-movie-ticket/passport
A lightweight authentication token library for the Movie Ticket booking system, built with Bun. This package provides utilities to generate and verify custom HMAC-based tokens.
Installation
bun add @sa2-movie-ticket/passport
# or
npm install @sa2-movie-ticket/passportUsage
Generate a Token
import { generateToken } from "@sa2-movie-ticket/passport";
const data = {
userId: "user-123",
role: "user",
};
const secret = "my-secret-key";
const expiresIn = 3600; // 1 hour in seconds
const token = generateToken(data, secret, expiresIn);
console.log(token);Verify a Token
import { verifyToken } from "@sa2-movie-ticket/passport";
const secret = "my-secret-key";
const result = verifyToken(token, secret);
if (result.valid) {
console.log("Valid token for user:", result.data);
} else {
console.error("Invalid token:", result.reason);
}Scripts
bun run tsup: Build the library (ESM & CJS) for distribution.bun run build: Compile into a standalone executable (if needed).bun run dev: Run in watch mode.
Publishing
This package is configured to publish to the npm registry via GitHub Actions.
