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.2 to 1.1.3

6

google-recaptcha.module.d.ts
import { DynamicModule } from '@nestjs/common';
import { GoogleRecaptchaModuleOptions } from './interfaces/google-recaptcha-module-options';
import { GoogleRecaptchaModuleAsyncOptions, GoogleRecaptchaModuleOptions } from './interfaces/google-recaptcha-module-options';
export declare class GoogleRecaptchaModule {
static forRoot(options: GoogleRecaptchaModuleOptions): DynamicModule;
static forRootAsync(options: GoogleRecaptchaModuleAsyncOptions): DynamicModule;
private static createAsyncProviders;
private static createAsyncOptionsProvider;
private static isGoogleRecaptchaFactory;
}

@@ -28,8 +28,56 @@ "use strict";

imports: [
common_1.HttpModule
],
providers: providers,
exports: providers,
};
}
static forRootAsync(options) {
const providers = [
google_recaptcha_guard_1.GoogleRecaptchaGuard,
google_recaptcha_validator_1.GoogleRecaptchaValidator,
...this.createAsyncProviders(options)
];
return {
module: GoogleRecaptchaModule_1,
imports: [
common_1.HttpModule,
...options.imports || []
],
providers,
providers: providers,
exports: providers,
};
}
static createAsyncProviders(options) {
const providers = [this.createAsyncOptionsProvider(options)];
if (options.useClass) {
providers.push({
provide: options.useClass,
useClass: options.useClass,
});
}
return providers;
}
static createAsyncOptionsProvider(options) {
if (options.useFactory) {
return {
provide: provider_declarations_1.RECAPTCHA_OPTIONS,
useFactory: options.useFactory,
inject: options.inject || [],
};
}
return {
provide: provider_declarations_1.RECAPTCHA_OPTIONS,
useFactory: (optionsFactory) => {
if (!this.isGoogleRecaptchaFactory(optionsFactory)) {
throw new Error('Factory must be implement \'GoogleRecaptchaOptionsFactory\' interface.');
}
return optionsFactory.createGoogleRecaptchaOptions();
},
inject: [options.useExisting || options.useClass],
};
}
static isGoogleRecaptchaFactory(object) {
return !!object && typeof object.createGoogleRecaptchaOptions === 'function';
}
};

@@ -36,0 +84,0 @@ GoogleRecaptchaModule = GoogleRecaptchaModule_1 = __decorate([

import { GoogleRecaptchaGuardOptions } from './google-recaptcha-guard-options';
import { GoogleRecaptchaValidatorOptions } from './google-recaptcha-validator-options';
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
export interface GoogleRecaptchaModuleOptions extends GoogleRecaptchaValidatorOptions, GoogleRecaptchaGuardOptions {
}
export interface GoogleRecaptchaOptionsFactory {
createGoogleRecaptchaOptions(): Promise<GoogleRecaptchaModuleOptions> | GoogleRecaptchaModuleOptions;
}
export interface GoogleRecaptchaModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
inject?: any[];
useClass?: Type<GoogleRecaptchaOptionsFactory>;
useExisting?: Type<GoogleRecaptchaOptionsFactory>;
useFactory?: (...args: any[]) => Promise<GoogleRecaptchaModuleOptions> | GoogleRecaptchaModuleOptions;
}

2

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

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

@@ -35,2 +35,18 @@ # Google recaptcha module

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.
```typescript
@Module({
imports: [
GoogleRecaptchaModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => configService.googleRecaptchaOptions,
inject: [ConfigService],
})
],
})
export class AppModule {
}
```
### Usage <a name="Usage"></a>

@@ -37,0 +53,0 @@

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