{"_id":"@anurag_raj_09/common","_rev":"4-7138f78ad2a0651a03c0bf200c69d6a4","name":"@anurag_raj_09/common","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@anurag_raj_09/common","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@anurag_raj_09/common@1.0.0","maintainers":[{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"}],"dist":{"shasum":"a35fbc1025592969241c84aabb582ead7cfb3ea1","tarball":"https://registry.npmjs.org/@anurag_raj_09/common/-/common-1.0.0.tgz","fileCount":3,"integrity":"sha512-mCFsWsypVbt1XgP6xL7cX8jH9qrBa8mC1Nuc++h5aDCImX6QiBge+a4mVJ3T8bZpIrhVpICTBZSiQXode1DoDA==","signatures":[{"sig":"MEUCICdBkh1MNytNbWqXN0siTqz40FjyyMSS/Vt9v+UMyhdQAiEAqyJxK1U38SUNUuavx+bteVfOcGV2SNoFcZDvWC93MQ0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1774},"main":"./dist/index.js","type":"module","gitHead":"a84c7ad1afe4a59b80d4fda15c9d48c0f4f3e9ba","scripts":{"dev":"npm run build && npm run start","build":"tsc -p tsconfig.json","start":"node ./dist/index.js"},"_npmUser":{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"},"_npmVersion":"10.8.3","directories":{},"_nodeVersion":"20.16.0","dependencies":{"zod":"^4.1.3","init":"^0.1.2","typescript":"^5.9.2"},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/common_1.0.0_1756214199559_0.393678022897199","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@anurag_raj_09/common","version":"1.0.1","keywords":[],"author":"","license":"ISC","_id":"@anurag_raj_09/common@1.0.1","maintainers":[{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"}],"dist":{"shasum":"906e1a9e38e72cce5d3f89898960459114a7ec8d","tarball":"https://registry.npmjs.org/@anurag_raj_09/common/-/common-1.0.1.tgz","fileCount":3,"integrity":"sha512-C3GV1tpASxIlc5t0ctd5IdBIkzXHz3gEKUbWGumUYA0TCc0+zWVki25Y4uNGUCSGtVO4bdj8DUMKRVooj8hVZQ==","signatures":[{"sig":"MEUCIQD3sQyBkMhLZhDpk/QY5c2/T/lpnVB+0dWn2BRIo/VOMwIgMVPwHblNMeC6LwCxwbySUbhuoFdqA9pD098eORgPD40=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2432},"main":"./dist/index.js","type":"module","gitHead":"a84c7ad1afe4a59b80d4fda15c9d48c0f4f3e9ba","scripts":{"dev":"npm run build && npm run start","build":"tsc -p tsconfig.json","start":"node ./dist/index.js"},"_npmUser":{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"},"_npmVersion":"10.8.3","directories":{},"_nodeVersion":"20.16.0","dependencies":{"zod":"^4.1.3","init":"^0.1.2","typescript":"^5.9.2"},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/common_1.0.1_1756214525948_0.2822305356405468","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@anurag_raj_09/common","version":"1.0.2","keywords":[],"author":"","license":"ISC","_id":"@anurag_raj_09/common@1.0.2","maintainers":[{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"}],"dist":{"shasum":"ade1c8dc1fa75203df0ab18b85cc0e6ca5b225a6","tarball":"https://registry.npmjs.org/@anurag_raj_09/common/-/common-1.0.2.tgz","fileCount":7,"integrity":"sha512-YoS2pQiOSGMbGjS8j7/qhkyMCPWzC4sA27EYRVrepZej3G61o0N1NKJEJtdERpo578LKyYGSJgLtdVUFLKYZuw==","signatures":[{"sig":"MEUCICFXN5CCtyUOCiwAwUNRDx9RhJQxafI0/n4rW/xIXzGCAiEAryCvqLpoDJuM0DRVLA4CT4ihSuJszBBiGngkNul0rX8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3351},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"a84c7ad1afe4a59b80d4fda15c9d48c0f4f3e9ba","scripts":{"dev":"npm run build && npm run start","build":"tsc -p tsconfig.json","start":"node ./dist/index.js"},"_npmUser":{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"},"_npmVersion":"10.8.3","directories":{},"_nodeVersion":"20.16.0","dependencies":{"zod":"^4.1.3","init":"^0.1.2","typescript":"^5.9.2"},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/common_1.0.2_1756214634881_0.16901245887123828","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"dependencies":{"@types/bcrypt":"^6.0.0","@types/express":"^5.0.3","@types/jsonwebtoken":"^9.0.10","bcrypt":"^6.0.0","express":"^5.1.0","init":"^0.1.2","jsonwebtoken":"^9.0.2","typescript":"^5.9.2","zod":"^4.1.3"},"name":"@anurag_raj_09/common","version":"1.0.3","main":"./dist/index.js","type":"module","scripts":{"build":"tsc -p tsconfig.json","start":"node ./dist/index.js","dev":"npm run build && npm run start"},"keywords":[],"author":"","license":"ISC","description":"Perfect 👍 now your code looks **clean, safe, and production-ready**.\r Here’s a complete **README.md** for your GitHub package `@anurag_raj_09/common`. I’ll write it in a way so that any developer visiting your repo will instantly understand **what your p","_id":"@anurag_raj_09/common@1.0.3","gitHead":"95b0b35021caa7bd8e917b645b1452caf788bcec","types":"./dist/index.d.ts","_nodeVersion":"20.16.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-Ezxx/QX89pJ+eKXW5J8LILGh0/kspbUHANPN2qBtBdfzGBZqeXH74ZuHjdVMxc7RjfrpJ4yvJCAdOPv5cikzLA==","shasum":"3eab8b46c935a6da339f61569c6cbd8eb4c10b22","tarball":"https://registry.npmjs.org/@anurag_raj_09/common/-/common-1.0.3.tgz","fileCount":8,"unpackedSize":14740,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCK24X6ay6Q80ZFMEvE4xa3JIUEAVrijeRdW8SdqWlVywIhANEYglTa55GVdUFwApdLLcF5Srq6yD3zJfh85AN97O9o"}]},"_npmUser":{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"},"directories":{},"maintainers":[{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/common_1.0.3_1756220690161_0.7544418387481446"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-26T13:16:39.447Z","modified":"2025-08-26T15:04:50.527Z","1.0.0":"2025-08-26T13:16:39.730Z","1.0.1":"2025-08-26T13:22:06.150Z","1.0.2":"2025-08-26T13:23:55.090Z","1.0.3":"2025-08-26T15:04:50.356Z"},"license":"ISC","keywords":[],"maintainers":[{"name":"anurag_raj_09","email":"anurag07raj@gmail.com"}],"readme":"Perfect 👍 now your code looks **clean, safe, and production-ready**.\r\nHere’s a complete **README.md** for your GitHub package `@anurag_raj_09/common`. I’ll write it in a way so that any developer visiting your repo will instantly understand **what your package does, how to install it, and how to use every single function with examples**.\r\n\r\n---\r\n\r\n````markdown\r\n# @anurag_raj_09/common\r\n\r\nA lightweight **authentication and validation utility package** built with **TypeScript, Zod, Bcrypt, and JWT**.  \r\nIt provides ready-to-use helpers for:\r\n\r\n- 🔐 User signup & signin validation (`zod`)\r\n- 🔑 Password hashing and comparison (`bcrypt`)\r\n- 🎟️ JWT token creation & verification (`jsonwebtoken`)\r\n- 🛡️ Express middleware for token protection\r\n\r\n---\r\n\r\n## 📦 Installation\r\n\r\n```bash\r\nnpm install @anurag_raj_09/common\r\n````\r\n\r\nor with yarn:\r\n\r\n```bash\r\nyarn add @anurag_raj_09/common\r\n```\r\n\r\n---\r\n\r\n## 🚀 Features\r\n\r\n1. **User Validation Schemas**\r\n   Validate signup & signin data with strict password rules (uppercase, lowercase, number, symbol).\r\n\r\n2. **Password Security**\r\n   Easily hash passwords and verify them using `bcrypt`.\r\n\r\n3. **JWT Helpers**\r\n   Generate and verify JSON Web Tokens securely.\r\n\r\n4. **Express Middleware**\r\n   Plug-and-play middleware to protect routes with JWT authentication.\r\n\r\n---\r\n\r\n## 📖 Usage Guide\r\n\r\n### 1. User Signup Validation\r\n\r\n```ts\r\nimport { UserSignupValidation } from \"@anurag_raj_09/common\";\r\n\r\nconst data = {\r\n  username: \"anurag123\",\r\n  password: \"Secure@123\",\r\n  email: \"user@example.com\"\r\n};\r\n\r\n// Validate\r\nconst result = UserSignupValidation.safeParse(data);\r\n\r\nif (!result.success) {\r\n  console.log(result.error.format()); // Shows validation errors\r\n} else {\r\n  console.log(result.data); // ✅ Validated data\r\n}\r\n```\r\n\r\n### 2. User Signin Validation\r\n\r\n```ts\r\nimport { UserSigninValidation } from \"@anurag_raj_09/common\";\r\n\r\nconst credentials = {\r\n  username: \"anurag123\",\r\n  password: \"Secure@123\"\r\n};\r\n\r\nconst result = UserSigninValidation.safeParse(credentials);\r\n\r\nif (!result.success) {\r\n  console.log(result.error.format());\r\n} else {\r\n  console.log(result.data);\r\n}\r\n```\r\n\r\n---\r\n\r\n### 3. Create Hashed Password\r\n\r\n```ts\r\nimport { CreateHashpassword } from \"@anurag_raj_09/common\";\r\n\r\nasync function signup(password: string) {\r\n  const { hashPass } = await CreateHashpassword(password);\r\n  console.log(\"Hashed Password:\", hashPass);\r\n  return hashPass;\r\n}\r\n\r\nsignup(\"Secure@123\");\r\n```\r\n\r\n---\r\n\r\n### 4. Check Hashed Password\r\n\r\n```ts\r\nimport { CheckHashPassword } from \"@anurag_raj_09/common\";\r\n\r\nasync function login(password: string, hashed: string) {\r\n  const isMatch = await CheckHashPassword(hashed, password);\r\n  console.log(\"Password Match:\", isMatch);\r\n  return isMatch;\r\n}\r\n\r\nlogin(\"Secure@123\", \"$2b$10$abc...xyzHashedPassword\");\r\n```\r\n\r\n---\r\n\r\n### 5. Create JWT Token\r\n\r\n```ts\r\nimport { CreateToken } from \"@anurag_raj_09/common\";\r\n\r\nconst { token } = CreateToken(\"user123\", process.env.JWT_SECRET!);\r\nconsole.log(\"JWT Token:\", token);\r\n```\r\n\r\n---\r\n\r\n### 6. Verify JWT Token (Express Middleware)\r\n\r\nFirst, extend the Express `Request` type to include `userId`:\r\n\r\n```ts\r\n// index.d.ts\r\ndeclare global {\r\n  namespace Express {\r\n    interface Request {\r\n      userId?: string;\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThen use the middleware:\r\n\r\n```ts\r\nimport express from \"express\";\r\nimport cookieParser from \"cookie-parser\";\r\nimport { VerifyToken } from \"@anurag_raj_09/common\";\r\n\r\nconst app = express();\r\napp.use(cookieParser());\r\n\r\n// Protected route\r\napp.get(\r\n  \"/dashboard\",\r\n  VerifyToken(process.env.JWT_SECRET!),\r\n  (req, res) => {\r\n    res.json({ message: \"Welcome!\", userId: req.userId });\r\n  }\r\n);\r\n```\r\n\r\n---\r\n\r\n## 📑 Types\r\n\r\n* `UValidationSignup` → Type inferred from `UserSignupValidation`\r\n* `UValidationSignin` → Type inferred from `UserSigninValidation`\r\n* `TokenPayload` → Extends `JwtPayload` to include `_id: string`\r\n\r\nExample:\r\n\r\n```ts\r\nimport type { UValidationSignup, UValidationSignin } from \"@anurag_raj_09/common\";\r\n\r\nconst user: UValidationSignup = {\r\n  username: \"testuser\",\r\n  password: \"Strong@123\",\r\n  email: \"test@example.com\"\r\n};\r\n```\r\n\r\n---\r\n\r\n## ⚡ Summary\r\n\r\n* **Validation** → `UserSignupValidation`, `UserSigninValidation`\r\n* **Password** → `CreateHashpassword`, `CheckHashPassword`\r\n* **JWT** → `CreateToken`, `VerifyToken`\r\n\r\nThis package is designed to **save you time when building authentication systems in Node.js/Express apps**. 🚀\r\n\r\n---\r\n\r\n## 🛠️ Tech Stack\r\n\r\n* [Zod](https://github.com/colinhacks/zod) – schema validation\r\n* [Bcrypt](https://github.com/kelektiv/node.bcrypt.js) – password hashing\r\n* [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) – token management\r\n* [Express](https://expressjs.com/) – middleware support\r\n\r\n---\r\n\r\n## 👨‍💻 Author\r\n\r\n**Anurag Raj**\r\n📦 NPM: [@anurag\\_raj\\_09/common](https://www.npmjs.com/package/@anurag_raj_09/common)\r\n🐙 GitHub: [anurag-raj-09](https://github.com/anurag-raj-09)\r\n\r\n```\r\n\r\n---\r\n\r\n⚡ This README is **ready to drop into your GitHub repo**.  \r\nIt gives full **installation, usage, and examples for every function** so developers won’t have to guess.\r\n\r\nDo you also want me to add a **section with “Best Practices”** (like storing `JWT_SECRET` in `.env`, minimum password length, etc.) so new users don’t make mistakes?\r\n```\r\n","readmeFilename":"readme.md","description":"Perfect 👍 now your code looks **clean, safe, and production-ready**.\r Here’s a complete **README.md** for your GitHub package `@anurag_raj_09/common`. I’ll write it in a way so that any developer visiting your repo will instantly understand **what your p"}