Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@nestlab/google-recaptcha
Advanced tools
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 {
}
@Controller('feedback')
export class FeedbackController {
@Recaptcha()
@Post('send')
async send(): Promise<any> {
// TODO: Implement it.
}
}
Example error customization. You can return or throw HttpException or return string.
If you will return string, then response will have status code 400 (Bad request).
GoogleRecaptchaModule.forRoot({
secretKey: process.env.GOOGLE_RECAPTCHA_SECRET_KEY,
response: req => req.headers.recaptcha,
skipIf: () => process.env.NODE_ENV !== 'production',
onError: (errorCodes: ErrorCode[]) => {
switch (errorCodes.shift()) {
case ErrorCode.MissingInputSecret:
return 'The secret parameter is missing.';
case ErrorCode.InvalidInputSecret:
return 'The secret parameter is invalid or malformed.';
case ErrorCode.MissingInputResponse:
return 'The response parameter is missing.';
case ErrorCode.InvalidInputResponse:
return 'The response parameter is invalid or malformed.';
case ErrorCode.BadRequest:
return 'The request is invalid or malformed.';
case ErrorCode.TimeoutOrDuplicate:
return 'The response is no longer valid: either is too old or has been used previously.';
case ErrorCode.UnknownError:
default:
return new BadGatewayException('Unknown error when checking captcha.');
}
},
})
Enjoy!
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.
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.