Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestlab/google-recaptcha

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestlab/google-recaptcha - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

4

interfaces/google-recaptcha-validator-options.d.ts

@@ -0,3 +1,7 @@

/// <reference types="node" />
import * as https from "https";
export interface GoogleRecaptchaValidatorOptions {
secretKey: string;
useRecaptchaNet?: boolean;
agent?: https.Agent;
}

2

package.json
{
"name": "@nestlab/google-recaptcha",
"version": "1.1.3",
"version": "1.1.4",
"description": "Google recaptcha module for NestJS.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -28,2 +28,4 @@ # Google recaptcha module

skipIf: () => process.env.NODE_ENV !== 'production',
useRecaptchaNet: false,
agent: null
})

@@ -36,2 +38,13 @@ ],

**Configuration options**
| Property | | Type | Description |
|-------------------|---|----------------------------|-------------|
| `secretKey` | ✔ | string | Google recaptcha secret key |
| `response` | ✔ | (request) => string | Function that returns response (recaptcha token) by request |
| `skipIf` | ✖ | () => boolean | Function that returns true if you need skip check for development or testing |
| `useRecaptchaNet` | ✖ | boolean | If your server has trouble connecting to https://www.google.com. You can use https://recaptcha.net instead, just set true |
| `agent` | ✖ | https.Agent | If you need to use an agent |
If you want import configs from your [ConfigService](https://docs.nestjs.com/techniques/configuration#getting-started) via [custom getter function](https://docs.nestjs.com/techniques/configuration#custom-getter-functions) that will return `GoogleRecaptchaModuleOptions` object.

@@ -38,0 +51,0 @@

@@ -8,2 +8,3 @@ import { HttpService } from '@nestjs/common';

private readonly apiUrl;
private readonly apiUrlUseRecaptchaNet;
private readonly headers;

@@ -10,0 +11,0 @@ constructor(http: HttpService, options: GoogleRecaptchaValidatorOptions);

@@ -25,2 +25,3 @@ "use strict";

this.apiUrl = 'https://www.google.com/recaptcha/api/siteverify';
this.apiUrlUseRecaptchaNet = 'https://recaptcha.net/recaptcha/api/siteverify';
this.headers = { 'Content-Type': 'application/x-www-form-urlencoded' };

@@ -30,3 +31,7 @@ }

const data = qs.stringify({ secret: this.options.secretKey, response });
return this.http.post(this.apiUrl, data, { headers: this.headers })
const url = this.options.useRecaptchaNet ? this.apiUrlUseRecaptchaNet : this.apiUrl;
return this.http.post(url, data, {
headers: this.headers,
httpsAgent: this.options.agent
})
.toPromise()

@@ -33,0 +38,0 @@ .then(res => res.data)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc