{"_id":"@api-craft/oauth","_rev":"3-33c017754db8589261dd7f48b7b5bcb2","name":"@api-craft/oauth","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@api-craft/oauth","version":"1.0.0","keywords":["oauth","express","middleware","passport","google-oauth","apple-oauth","facebook-oauth","meta","authentication","login"],"author":{"name":"P. Thamilselven"},"license":"MIT","_id":"@api-craft/oauth@1.0.0","maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"homepage":"https://github.com/api-craft/api-craft-oauth#readme","bugs":{"url":"https://github.com/api-craft/api-craft-oauth/issues"},"dist":{"shasum":"b4111d4c8b5182d239daa44ba6f4fa376a5f1bb9","tarball":"https://registry.npmjs.org/@api-craft/oauth/-/oauth-1.0.0.tgz","fileCount":6,"integrity":"sha512-ztVXEkZzmP2VLsNyiXvnoisEsHESVWYY5+qdtSxH/m7+TWfY2uG/T2vifiAYs4KsjSxR4ufRyrrtzCWflG0X/A==","signatures":[{"sig":"MEUCIQDVdwaMhcKbjS1xjdrk0fjiS+g/gAZIhgEEcRvB0xLjNgIgW2m2NhV+i8C0XHDvyFOcrsuKZhFdurFpvdtYn4G21XU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10746},"main":"index.js","_from":"file:api-craft-oauth-1.0.0.tgz","engines":{"node":">=16"},"scripts":{"lint":"eslint .","test":"echo \"No tests specified\" && exit 0","start":"node example.js"},"_npmUser":{"name":"tselven_me","actor":{"name":"tselven_me","type":"user","email":"tselven13@gmail.com"},"email":"tselven13@gmail.com"},"_resolved":"C:\\Users\\DELL\\AppData\\Local\\Temp\\4861b82c4f86e769330dca22d2991133\\api-craft-oauth-1.0.0.tgz","_integrity":"sha512-ztVXEkZzmP2VLsNyiXvnoisEsHESVWYY5+qdtSxH/m7+TWfY2uG/T2vifiAYs4KsjSxR4ufRyrrtzCWflG0X/A==","repository":{"url":"git+https://github.com/api-craft/api-craft-oauth.git","type":"git"},"_npmVersion":"10.9.2","description":"Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"passport":"^0.6.0","passport-apple":"^1.2.0","express-session":"^1.17.3","passport-facebook":"^3.0.0","passport-google-oauth20":"^2.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/oauth_1.0.0_1750740521888_0.5794723956545522","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@api-craft/oauth","version":"1.0.1","keywords":["oauth","express","middleware","passport","google-oauth","apple-oauth","facebook-oauth","meta","authentication","login"],"author":{"name":"P. Thamilselven"},"license":"MIT","_id":"@api-craft/oauth@1.0.1","maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"homepage":"https://github.com/api-craft/api-craft-oauth#readme","bugs":{"url":"https://github.com/api-craft/api-craft-oauth/issues"},"dist":{"shasum":"dc06d30483396c6be9e970b01bf083c2da900444","tarball":"https://registry.npmjs.org/@api-craft/oauth/-/oauth-1.0.1.tgz","fileCount":6,"integrity":"sha512-zavTikvUIj2lSZZxbWbhNqKKLqQ+2CMCteEdJCRw9Bpt7M/4kw5MfEEemfVnaKnR+JR/oG/c6Zsu+wVGQ6mZ/g==","signatures":[{"sig":"MEQCIAPSt5/V24x7rI58VKYIlOMAKKssrnHo2dAp+jqIFoA7AiAq5Yo6DANW84OFDojz7//yzMovdfTYYZO37kf8geXClQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10774},"main":"index.js","_from":"file:api-craft-oauth-1.0.1.tgz","engines":{"node":">=16"},"scripts":{"lint":"eslint .","test":"echo \"No tests specified\" && exit 0","start":"node example.js"},"_npmUser":{"name":"tselven_me","actor":{"name":"tselven_me","type":"user","email":"tselven13@gmail.com"},"email":"tselven13@gmail.com"},"_resolved":"C:\\Users\\DELL\\AppData\\Local\\Temp\\30d7beeb73424e3c459b1c230250a14a\\api-craft-oauth-1.0.1.tgz","_integrity":"sha512-zavTikvUIj2lSZZxbWbhNqKKLqQ+2CMCteEdJCRw9Bpt7M/4kw5MfEEemfVnaKnR+JR/oG/c6Zsu+wVGQ6mZ/g==","repository":{"url":"git+https://github.com/api-craft/api-craft-oauth.git","type":"git"},"_npmVersion":"10.9.2","description":"Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"passport":"^0.6.0","express-session":"^1.17.3"},"_hasShrinkwrap":false,"peerDependencies":{"passport-apple":"^1.2.0","passport-facebook":"^3.0.0","passport-google-oauth20":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/oauth_1.0.1_1750740980275_0.18923639584555874","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@api-craft/oauth","version":"1.0.2","description":"Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.","main":"index.js","keywords":["oauth","express","middleware","passport","google-oauth","apple-oauth","facebook-oauth","meta","authentication","login"],"author":{"name":"P. Thamilselven"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/api-craft/api-craft-oauth.git"},"dependencies":{"@api-craft/oauth":"link:","express-session":"^1.17.3","passport":"^0.6.0"},"peerDependencies":{"passport-apple":"^2.0.2","passport-facebook":"^3.0.0","passport-google-oauth20":"^2.0.0"},"engines":{"node":">=16"},"scripts":{"test":"echo \"No tests specified\" && exit 0","lint":"eslint .","start":"node example.js"},"_id":"@api-craft/oauth@1.0.2","bugs":{"url":"https://github.com/api-craft/api-craft-oauth/issues"},"homepage":"https://github.com/api-craft/api-craft-oauth#readme","_integrity":"sha512-pNmC7iz1w8i/sf6e8xRve2S8f7I1TT3y9iFNRp/gDQbKwDDTawvckZNIvPu1gMjOWP/YxQUYqztx0qmH9Dz92w==","_resolved":"C:\\Users\\DELL\\AppData\\Local\\Temp\\06a8c4060ca943911364b3fde9b2ed5a\\api-craft-oauth-1.0.2.tgz","_from":"file:api-craft-oauth-1.0.2.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-pNmC7iz1w8i/sf6e8xRve2S8f7I1TT3y9iFNRp/gDQbKwDDTawvckZNIvPu1gMjOWP/YxQUYqztx0qmH9Dz92w==","shasum":"951ef7b4446578fbc2b88778fafb5ff9ccf6329d","tarball":"https://registry.npmjs.org/@api-craft/oauth/-/oauth-1.0.2.tgz","fileCount":6,"unpackedSize":10807,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHSGtjGbkxtmtKU8A43oVTl+ab08BSad2hFjHL7hcEsOAiBg5oMF3HBtDsR4t8Y+KhDkGGd+ym9gZQQdUnsq5+8T/Q=="}]},"_npmUser":{"name":"tselven_me","email":"tselven13@gmail.com","actor":{"name":"tselven_me","email":"tselven13@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/oauth_1.0.2_1750741237226_0.3158292486660137"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-24T04:48:41.771Z","modified":"2025-06-24T05:00:37.665Z","1.0.0":"2025-06-24T04:48:42.072Z","1.0.1":"2025-06-24T04:56:20.440Z","1.0.2":"2025-06-24T05:00:37.432Z"},"bugs":{"url":"https://github.com/api-craft/api-craft-oauth/issues"},"author":{"name":"P. Thamilselven"},"license":"MIT","homepage":"https://github.com/api-craft/api-craft-oauth#readme","keywords":["oauth","express","middleware","passport","google-oauth","apple-oauth","facebook-oauth","meta","authentication","login"],"repository":{"type":"git","url":"git+https://github.com/api-craft/api-craft-oauth.git"},"description":"Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.","maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"readme":"# @api-craft/oauth\r\n\r\nExpress middleware plugin to easily integrate OAuth login with Google, Apple, and Meta (Facebook & Instagram).  \r\nAutomatically exposes OAuth routes and callback URLs with a configurable filter for selected providers.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- Plug-and-play OAuth login for **Google**, **Apple**, and **Meta (Facebook + Instagram)**\r\n- Auto-registers all necessary routes:\r\n  - `/auth/google`, `/auth/google/callback`\r\n  - `/auth/apple`, `/auth/apple/callback`\r\n  - `/auth/meta`, `/auth/meta/callback`\r\n- Filter to enable only needed providers\r\n- Hooks to run custom logic after login success or failure\r\n- Built on **passport.js** for extensibility and stability\r\n- Session support included via `express-session`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @api-craft/oauth passport passport-google-oauth20 passport-facebook passport-apple express-session\r\n```\r\n\r\n## Quick Start\r\n\r\n``` js\r\nimport express from 'express';\r\nimport { createOAuthRouter } from '@api-craft/oauth';\r\n\r\nconst app = express();\r\n\r\nconst oauthRouter = createOAuthRouter({\r\n  baseUrl: 'https://yourdomain.com/auth',\r\n  providers: {\r\n    google: {\r\n      clientId: process.env.GOOGLE_CLIENT_ID,\r\n      clientSecret: process.env.GOOGLE_CLIENT_SECRET,\r\n      scopes: ['profile', 'email']\r\n    },\r\n    apple: {\r\n      clientId: process.env.APPLE_CLIENT_ID,\r\n      teamId: process.env.APPLE_TEAM_ID,\r\n      keyId: process.env.APPLE_KEY_ID,\r\n      privateKey: process.env.APPLE_PRIVATE_KEY,\r\n    },\r\n    meta: {\r\n      clientId: process.env.META_CLIENT_ID,\r\n      clientSecret: process.env.META_CLIENT_SECRET,\r\n      scopes: ['public_profile', 'email']\r\n    }\r\n  },\r\n  filter: ['google', 'meta'], // Only enable Google and Meta providers\r\n  onSuccess: (req, res, user) => {\r\n    // Custom logic after successful OAuth login\r\n    res.json({ user });\r\n  },\r\n  onFailure: (req, res, error) => {\r\n    // Handle OAuth failure\r\n    res.status(401).json({ error: error.message });\r\n  }\r\n});\r\n\r\napp.use('/auth', oauthRouter);\r\n\r\napp.listen(3000, () => {\r\n  console.log('Server started on http://localhost:3000');\r\n});\r\n```\r\n\r\n## Available Routes \r\n\r\n| Route                       | Method   | Description               |\r\n| --------------------------- | -------- | ------------------------- |\r\n| `/auth/{provider}`          | GET      | Initiate OAuth login flow |\r\n| `/auth/{provider}/callback` | GET/POST | OAuth callback handler    |\r\n| `/auth/failure`             | GET      | OAuth failure handler     |\r\n\r\n## Example : Custom On Success\r\n\r\n``` js\r\nonSuccess: async (req, res, user) => {\r\n  // Example: Save or update user in your database\r\n  const existingUser = await User.findOne({ oauthId: user.id });\r\n  if (!existingUser) {\r\n    await User.create({ oauthId: user.id, profile: user });\r\n  }\r\n\r\n  // Issue JWT token\r\n  const token = createJwtToken(user);\r\n\r\n  // Send response\r\n  res.json({ token, user });\r\n}\r\n```\r\n\r\n## Licence\r\n\r\nMIT License\r\n\r\n## Contributions\r\nContributions and feedback are welcome! Feel free to open issues or pull requests.\r\n\r\n## Author\r\n`@api-craft/oauth` by P. Thamilselven\r\nFeel free to reach out for any questions or customizations.","readmeFilename":"README.md"}