
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@api-craft/oauth
Advanced tools
Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.
Express middleware plugin to easily integrate OAuth login with Google, Apple, and Meta (Facebook & Instagram).
Automatically exposes OAuth routes and callback URLs with a configurable filter for selected providers.
/auth/google, /auth/google/callback/auth/apple, /auth/apple/callback/auth/meta, /auth/meta/callbackexpress-sessionnpm install @api-craft/oauth passport passport-google-oauth20 passport-facebook passport-apple express-session
import express from 'express';
import { createOAuthRouter } from '@api-craft/oauth';
const app = express();
const oauthRouter = createOAuthRouter({
baseUrl: 'https://yourdomain.com/auth',
providers: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
scopes: ['profile', 'email']
},
apple: {
clientId: process.env.APPLE_CLIENT_ID,
teamId: process.env.APPLE_TEAM_ID,
keyId: process.env.APPLE_KEY_ID,
privateKey: process.env.APPLE_PRIVATE_KEY,
},
meta: {
clientId: process.env.META_CLIENT_ID,
clientSecret: process.env.META_CLIENT_SECRET,
scopes: ['public_profile', 'email']
}
},
filter: ['google', 'meta'], // Only enable Google and Meta providers
onSuccess: (req, res, user) => {
// Custom logic after successful OAuth login
res.json({ user });
},
onFailure: (req, res, error) => {
// Handle OAuth failure
res.status(401).json({ error: error.message });
}
});
app.use('/auth', oauthRouter);
app.listen(3000, () => {
console.log('Server started on http://localhost:3000');
});
| Route | Method | Description |
|---|---|---|
/auth/{provider} | GET | Initiate OAuth login flow |
/auth/{provider}/callback | GET/POST | OAuth callback handler |
/auth/failure | GET | OAuth failure handler |
onSuccess: async (req, res, user) => {
// Example: Save or update user in your database
const existingUser = await User.findOne({ oauthId: user.id });
if (!existingUser) {
await User.create({ oauthId: user.id, profile: user });
}
// Issue JWT token
const token = createJwtToken(user);
// Send response
res.json({ token, user });
}
MIT License
Contributions and feedback are welcome! Feel free to open issues or pull requests.
@api-craft/oauth by P. Thamilselven
Feel free to reach out for any questions or customizations.
FAQs
Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.
We found that @api-craft/oauth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.