{"_id":"@akkikhan/saas-framework-auth","_rev":"2-3923b3fed8e08d067d7ef0e26004a272","name":"@akkikhan/saas-framework-auth","dist-tags":{"latest":"1.0.0-dev.1"},"versions":{"1.0.0":{"name":"@akkikhan/saas-framework-auth","version":"1.0.0","keywords":["auth","jwt","multi-tenant","saas","authentication","express"],"author":{"name":"SaaS Framework"},"license":"MIT","_id":"@akkikhan/saas-framework-auth@1.0.0","maintainers":[{"name":"akkikhan","email":"akki@primussoft.com"}],"homepage":"https://github.com/akkikhan/saas-framework-auth#readme","bugs":{"url":"https://github.com/akkikhan/saas-framework-auth/issues"},"dist":{"shasum":"e31b5780b70cbff316db07c2172967a60e4a8048","tarball":"https://registry.npmjs.org/@akkikhan/saas-framework-auth/-/saas-framework-auth-1.0.0.tgz","fileCount":9,"integrity":"sha512-VWXYy9F1LrMaXhICjmh1qFoIfdZIKxBD/yzazuKmvQA+a7bzqjbdkrPIGCosumiVjBYeBmG53lH8usAOWv6utA==","signatures":[{"sig":"MEUCIDGCteEyR0ay5bjtvN5AVdPb0PdA1SUE8sAnAJZIdkFnAiEA2rtiythHQA2yGLrE7oVDxVk4iu5Zd+F0cN/7nrBGgZo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36129},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ed4dc048ae63648f4a7bfd8b2e28a8e9d2fceae4","scripts":{"build":"tsc","prepublishOnly":"npm run build","publish-package":"npm publish --access public"},"_npmUser":{"name":"akkikhan","email":"akki@primussoft.com"},"repository":{"url":"git+https://github.com/akkikhan/saas-framework-auth.git","type":"git"},"_npmVersion":"10.9.2","description":"Authentication SDK for SaaS Framework multi-tenant applications","directories":{},"_nodeVersion":"22.16.0","dependencies":{"jsonwebtoken":"^9.0.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^24.3.0","@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.6"},"peerDependencies":{"express":">=4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/saas-framework-auth_1.0.0_1756119010957_0.1119267491314182","host":"s3://npm-registry-packages-npm-production"}},"1.0.0-dev.1":{"name":"@akkikhan/saas-framework-auth","version":"1.0.0-dev.1","description":"Authentication SDK for SaaS Framework multi-tenant applications","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build","publish-package":"npm publish --access public"},"keywords":["auth","jwt","multi-tenant","saas","authentication","express"],"author":{"name":"SaaS Framework"},"license":"MIT","devDependencies":{"@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.6","typescript":"^5.0.0"},"dependencies":{"jsonwebtoken":"^9.0.2"},"peerDependencies":{"express":">=4.0.0"},"repository":{"type":"git","url":"git+https://github.com/akkikhan/auth.git"},"homepage":"https://github.com/saas-framework/auth#readme","_id":"@akkikhan/saas-framework-auth@1.0.0-dev.1","gitHead":"9ce7f60754aed225b07d36818461600d787f65cf","bugs":{"url":"https://github.com/akkikhan/auth/issues"},"_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-NewRoixKkcCWFGZ4PvHeIhtOdVW5+uNZoRCWP+Fo76AhVijcv4wjJyiK6/UuTvwaiCQ5DIsWPE93kUmoS+bl5Q==","shasum":"aa18b083b28459ce790b2b08465bbc5a0d61867c","tarball":"https://registry.npmjs.org/@akkikhan/saas-framework-auth/-/saas-framework-auth-1.0.0-dev.1.tgz","fileCount":13,"unpackedSize":69283,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAZuqNAhlm/8ELPjlLg/FZznyIYnSYvFSKMatnL8QZvJAiA/ynSbPJP9KfYwIP5aVYCQnSC1OqoFLzYa8zBtI6c6fg=="}]},"_npmUser":{"name":"akkikhan","email":"akki@primussoft.com"},"directories":{},"maintainers":[{"name":"akkikhan","email":"akki@primussoft.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/saas-framework-auth_1.0.0-dev.1_1756272804956_0.574363826573197"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-25T10:50:10.858Z","modified":"2025-08-27T05:33:25.380Z","1.0.0":"2025-08-25T10:50:11.187Z","1.0.0-dev.1":"2025-08-27T05:33:25.209Z"},"bugs":{"url":"https://github.com/akkikhan/auth/issues"},"author":{"name":"SaaS Framework"},"license":"MIT","homepage":"https://github.com/saas-framework/auth#readme","keywords":["auth","jwt","multi-tenant","saas","authentication","express"],"repository":{"type":"git","url":"git+https://github.com/akkikhan/auth.git"},"description":"Authentication SDK for SaaS Framework multi-tenant applications","maintainers":[{"name":"akkikhan","email":"akki@primussoft.com"}],"readme":"# @saas-framework/auth\n\nA comprehensive authentication SDK for multi-tenant SaaS applications built with the SaaS Framework.\n\n## Features\n\n- **JWT Token Management**: Secure token generation, validation, and refresh\n- **Multi-tenant Support**: Isolated authentication per tenant\n- **Express Middleware**: Drop-in authentication middleware for Express.js\n- **TypeScript Support**: Full TypeScript definitions included\n- **Flexible Configuration**: Easily configurable for different environments\n\n## Installation\n\n```bash\nnpm install @saas-framework/auth\n```\n\n## Quick Start\n\n```typescript\nimport { SaaSAuth } from '@saas-framework/auth';\n\nconst auth = new SaaSAuth({\n  apiKey: 'your-tenant-auth-api-key',\n  baseUrl: 'https://your-saas-platform.com/api/v2/auth'\n});\n\n// Login user\nconst session = await auth.login('user@example.com', 'password');\n\n// Verify token\nconst isValid = await auth.verifyToken(session.token);\n\n// Get current user\nconst user = await auth.getCurrentUser(session.token);\n```\n\n## Express.js Integration\n\n```typescript\nimport express from 'express';\nimport { SaaSAuth } from '@saas-framework/auth';\n\nconst app = express();\nconst auth = new SaaSAuth({ /* config */ });\n\n// Protect routes with authentication middleware\napp.use('/api/protected', auth.middleware());\n\napp.get('/api/protected/profile', (req, res) => {\n  // req.user is automatically populated by the middleware\n  res.json({ user: req.user });\n});\n```\n\n## API Reference\n\n### Constructor\n\n```typescript\nnew SaaSAuth(config: SaaSAuthConfig)\n```\n\n#### SaaSAuthConfig\n\n- `apiKey` (string): Your tenant's authentication API key\n- `baseUrl` (string): Base URL of your SaaS platform's auth endpoints\n\n### Methods\n\n#### `login(email: string, password: string): Promise<AuthSession>`\n\nAuthenticates a user with email and password.\n\n**Returns:** `AuthSession` containing token, user info, and expiration\n\n#### `verifyToken(token: string): Promise<boolean>`\n\nVerifies if a JWT token is valid and not expired.\n\n#### `getCurrentUser(token: string): Promise<User>`\n\nRetrieves user information from a valid JWT token.\n\n#### `refreshToken(refreshToken: string): Promise<{ token: string }>`\n\nRefreshes an expired JWT token using a refresh token.\n\n#### `logout(token: string): Promise<void>`\n\nLogs out a user and invalidates their token.\n\n#### `middleware(options?: { required?: boolean }): RequestHandler`\n\nExpress.js middleware for route authentication.\n\n**Options:**\n- `required` (boolean, default: true): Whether authentication is required\n\n## Error Handling\n\nAll methods throw descriptive errors that can be caught and handled:\n\n```typescript\ntry {\n  const session = await auth.login(email, password);\n} catch (error) {\n  console.error('Login failed:', error.message);\n}\n```\n\n## TypeScript Types\n\nThe package includes full TypeScript definitions:\n\n```typescript\ninterface AuthSession {\n  token: string;\n  user: {\n    id: string;\n    email: string;\n    tenantId: string;\n    isActive: boolean;\n  };\n  expiresAt: Date;\n}\n```\n\n## License\n\nMIT\n\n## Support\n\nFor issues and questions, please visit: [GitHub Issues](https://github.com/saas-framework/auth/issues)","readmeFilename":"README.md"}