@supersymmetrysoftware/slider-captcha-backend
v1.1.2
Published
Backend support for the React puzzle slider captcha
Maintainers
Readme
@supersymmetrysoftware/slider-captcha-react
Backend support for the React puzzle slider captcha.
This package is a fork of @adrsch/slider-captcha. All credit goes to the original author for their excellent work. This fork aims to maintain and enhance the project while preserving its core functionality.
Installation
To install the package, run:
npm install @supersymmetrysoftware/slider-captcha-backendUsage
Express Integration
const sliderCaptcha = require('@supersymmetrysoftware/slider-captcha-backend');
app.get('/captcha/create', async (req, res) => {
try {
const { data, solution } = await sliderCaptcha.create();
req.session.captcha = solution;
await req.session.save();
res.status(200).json(data);
} catch (error) {
console.error('Error creating captcha:', error);
res.status(500).json({ error: 'Captcha creation failed' });
}
});
app.post('/captcha/verify', async (req, res) => {
try {
if (!req.session.captcha) {
return res.status(400).json({ error: 'No captcha session found' });
}
const verification = await sliderCaptcha.verify(
req.session.captcha,
req.body
);
if (verification.result === 'success') {
req.session.token = verification.token;
await req.session.save();
}
res.status(200).json(verification);
} catch (error) {
console.error('Error verifying captcha:', error);
res.status(500).json({ error: 'Captcha verification failed' });
}
});Credits
This package is based on the original work by @adrsch. If you find this package useful, consider checking out the original repository and giving it a star. 🙌
Maintained by SupersymmetrySoftware to ensure continued updates and improvements.
