{"_id":"@baqarnaqvi/auth-module","name":"@baqarnaqvi/auth-module","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@baqarnaqvi/auth-module","version":"1.0.0","description":"A simple NestJS module for handling authentication using JWT and Passport.","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"@nestjs/common":"^11.1.3","@nestjs/core":"^11.1.3","@nestjs/jwt":"^11.0.0","@nestjs/passport":"^11.0.5","passport":"^0.7.0","passport-jwt":"^4.0.1","rxjs":"^7.8.2"},"devDependencies":{"@types/node":"^24.0.12","@types/passport":"^1.0.17","@types/passport-jwt":"^4.0.1","typescript":"^5.8.3"},"_id":"@baqarnaqvi/auth-module@1.0.0","_nodeVersion":"21.6.2","_npmVersion":"10.2.4","dist":{"integrity":"sha512-Lu2ds8qzFhcx77RF5QcCkBHybIBvRJsSI/JB9e7upJfbrksBKdX5UTjLUmiCWzRc01UpghePCc1VaXt1St2qwQ==","shasum":"8406bd725904500e176f459ea05e566a627d7ef4","tarball":"https://registry.npmjs.org/@baqarnaqvi/auth-module/-/auth-module-1.0.0.tgz","fileCount":20,"unpackedSize":111678,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDOJVFbqCc4Yj96oz9QJfsBKCbkjKq40OU5fLHFnGz6HQIhAO39zICi9ne2HcXCbFPa8le55CPfGxpDarDXdL3bBm0/"}]},"_npmUser":{"name":"baqarnaqvi","email":"baqarnaqvi925@gmail.com","actor":{"name":"baqarnaqvi","email":"baqarnaqvi925@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"baqarnaqvi","email":"baqarnaqvi925@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/auth-module_1.0.0_1752068129482_0.4648404542968845"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-09T13:35:29.395Z","1.0.0":"2025-07-09T13:35:29.692Z","modified":"2025-07-09T13:35:29.942Z"},"maintainers":[{"name":"baqarnaqvi","email":"baqarnaqvi925@gmail.com"}],"description":"A simple NestJS module for handling authentication using JWT and Passport.","keywords":[],"license":"ISC","readme":"# @baqarnaqvi/auth-module\n\nA simple NestJS module for handling authentication using JWT and Passport.\n\n## Installation\n\n```bash\nnpm install @baqarnaqvi/auth-module\n```\n\n## Usage\n\n### 1. Import the Module\n\nIn your root or feature module:\n\n```typescript\nimport { Module } from \"@nestjs/common\";\nimport { AuthModule } from \"@baqarnaqvi/auth-module\";\nimport { JwtModule } from \"@nestjs/jwt\";\n\n@Module({\n  imports: [\n    JwtModule.register({\n      secret: process.env.JWT_SECRET || \"your_secret\",\n      signOptions: { expiresIn: \"1h\" },\n    }),\n    AuthModule,\n  ],\n})\nexport class AppModule {}\n```\n\n### 2. Use AuthService to Sign and Validate JWT\n\n```typescript\nimport { Injectable } from \"@nestjs/common\";\nimport { AuthService } from \"@baqarnaqvi/auth-module\";\n\n@Injectable()\nexport class UserService {\n  constructor(private readonly authService: AuthService) {}\n\n  async login(user: any) {\n    const payload = { username: user.username, sub: user.userId };\n    return {\n      access_token: await this.authService.signPayload(payload),\n    };\n  }\n}\n```\n\n### 3. Protect Routes with JwtStrategy\n\nUse the built-in `JwtStrategy` with Passport's `@UseGuards(AuthGuard('jwt'))`:\n\n```typescript\nimport { Controller, Get, UseGuards, Request } from \"@nestjs/common\";\nimport { AuthGuard } from \"@nestjs/passport\";\n\n@Controller(\"profile\")\nexport class ProfileController {\n  @UseGuards(AuthGuard(\"jwt\"))\n  @Get()\n  getProfile(@Request() req) {\n    return req.user;\n  }\n}\n```\n\n## Environment Variables\n\n- `JWT_SECRET`: Secret key for signing JWT tokens (default: `default_secret`)\n\n## Customization\n\n- Override `validatePayload` in `AuthService` for custom validation logic.\n- Configure `JwtModule.register` with your own secret and options.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-413c6b44f7c6e5ea9f0a10c821200a76"}