Skip to content

Commit

Permalink
Merge pull request #129 from chvarkov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chvarkov authored Oct 1, 2023
2 parents ba5e023 + 3fbd031 commit 10dabd9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v3.5.0
- Added `global?: boolean` module option

## v3.4.1
- Fixed import LiteralObject for NestJS 10

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @nestlab/google-recaptcha
# Google recaptcha module

This package provides protection for endpoints using [reCAPTCHA](https://www.google.com/recaptcha/about/) for [NestJS](https://docs.nestjs.com/) REST and GraphQL applications. By integrating with reCAPTCHA, this package helps to prevent automated abuse such as spam and bots, improving the security and reliability of your application.

Expand Down Expand Up @@ -62,6 +62,7 @@ The list of changes made in the project can be found in the [CHANGELOG.md](./CHA
| `score` | Optional.<br> Type: `number` \| `(score: number) => boolean`<br> Score validator for reCAPTCHA v3 or enterprise. <br> `number` - minimum available score. <br> `(score: number) => boolean` - function with custom validation rules. |
| `actions` | Optional.<br> Type: `string[]`<br> Available action list for reCAPTCHA v3 or enterprise. <br> You can make this check stricter by passing the action property parameter to `@Recaptcha(...)` decorator. |
| `axiosConfig` | Optional.<br> Type: `AxiosRequestConfig`<br> Allows to setup proxy, response timeout, https agent etc... |
| `global` | Optional.<br> Type: `boolean` <br> Default: `false` Defines a module in the [global scope](https://docs.nestjs.com/modules#global-modules). |

**GoogleRecaptchaEnterpriseOptions**

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestlab/google-recaptcha",
"version": "3.4.1",
"version": "3.5.0",
"description": "Google recaptcha module for NestJS.",
"keywords": [
"nestjs",
Expand Down
4 changes: 2 additions & 2 deletions src/google-recaptcha.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class GoogleRecaptchaModule {
];

return {
global: true,
global: options.global != null ? options.global : true,
module: GoogleRecaptchaModule,
providers: providers.concat(internalProviders),
exports: providers,
Expand Down Expand Up @@ -99,7 +99,7 @@ export class GoogleRecaptchaModule {
];

return {
global: true,
global: options.global != null ? options.global : true,
module: GoogleRecaptchaModule,
imports: options.imports,
providers: providers.concat(internalProviders),
Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/google-recaptcha-module-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OptionalFactoryDependency } from '@nestjs/common/interfaces/modules/opt
export interface GoogleRecaptchaModuleOptions extends GoogleRecaptchaValidatorOptions, GoogleRecaptchaGuardOptions {
debug?: boolean;
logger?: Logger;
global?: boolean;
}

export interface GoogleRecaptchaOptionsFactory {
Expand All @@ -19,5 +20,6 @@ export interface GoogleRecaptchaModuleAsyncOptions extends Pick<ModuleMetadata,
useClass?: Type<GoogleRecaptchaOptionsFactory>;
useExisting?: Type<GoogleRecaptchaOptionsFactory>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
useFactory?: (...args: any[]) => Promise<GoogleRecaptchaModuleOptions> | GoogleRecaptchaModuleOptions;
useFactory?: (...args: any[]) => Promise<Omit<GoogleRecaptchaModuleOptions, 'global'>> | Omit<GoogleRecaptchaModuleOptions, 'global'>;
global?: boolean;
}
1 change: 1 addition & 0 deletions test/google-recaptcha-async-module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('Google recaptcha async module', () => {
axiosConfig: { ...http.axiosRef.defaults, headers: {} },
}),
inject: [TestConfigService, HttpService],
global: false,
}),
],
}).compile();
Expand Down
1 change: 1 addition & 0 deletions test/google-recaptcha-module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Google recaptcha module', () => {
response: (req) => req.headers.authorization,
skipIf: () => process.env.NODE_ENV !== 'production',
network: customNetwork,
global: false,
});
});

Expand Down

0 comments on commit 10dabd9

Please sign in to comment.