Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@nestlab/google-recaptcha
Advanced tools
The NestJS module to protect your endpoints via google recaptcha.
Usage example here
$ npm i @nestlab/google-recaptcha
@Module({
imports: [
GoogleRecaptchaModule.forRoot({
secretKey: process.env.GOOGLE_RECAPTCHA_SECRET_KEY,
response: req => req.headers.recaptcha,
skipIf: () => process.env.NODE_ENV !== 'production',
})
],
})
export class AppModule {
}
If you want import configs from your ConfigService via custom getter function that will return GoogleRecaptchaModuleOptions
object.
@Module({
imports: [
GoogleRecaptchaModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => configService.googleRecaptchaOptions,
inject: [ConfigService],
})
],
})
export class AppModule {
}
Use @Recaptcha
decorator to protect your endpoints.
@Controller('feedback')
export class FeedbackController {
@Recaptcha()
@Post('send')
async send(): Promise<any> {
// TODO: Your implementation.
}
}
You can override default property that contain recaptcha for specific endpoint.
@Controller('feedback')
export class FeedbackController {
@Recaptcha(req => req.body.recaptha)
@Post('send')
async send(): Promise<any> {
// TODO: Your implementation.
}
}
If you want use google recaptcha guard in combination with another guards then you can use @UseGuards
decorator.
@Controller('feedback')
export class FeedbackController {
@UseGuards(Guard1, GoogleRecaptchaGuard, Guard2)
@Post('send')
async send(): Promise<any> {
// TODO: Your implementation.
}
}
Google recaptcha guard will throw GoogleRecaptchaException on error.
GoogleRecaptchaException
has data with google recaptcha error codes.
GoogleRecaptchaException
← HttpException
← Error
.
You can handle it via ExceptionFilter.
Example exception filter implementation.
@Catch(GoogleRecaptchaException)
export class GoogleRecaptchaFilter implements ExceptionFilter {
catch(exception: GoogleRecaptchaException, host: ArgumentsHost): any {
// TODO: Your exception filter implementation
}
}
And add your filter to application
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalFilters(new ErrorFilter(), new GoogleRecaptchaFilter());
await app.listen(3000);
}
bootstrap();
Enjoy!
v1.1.3
FAQs
Google recaptcha module for NestJS.
The npm package @nestlab/google-recaptcha receives a total of 10,897 weekly downloads. As such, @nestlab/google-recaptcha popularity was classified as popular.
We found that @nestlab/google-recaptcha demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.