@nestlab/google-recaptcha
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -12,3 +12,3 @@ "use strict"; | ||
case 'graphql': | ||
const graphqlModule = load_module_1.loadModule('@nestjs/graphql'); | ||
const graphqlModule = load_module_1.loadModule('@nestjs/graphql', true); | ||
return (_d = (_c = (_b = (_a = graphqlModule.GqlExecutionContext.create(context).getContext().req) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b._httpMessage) === null || _c === void 0 ? void 0 : _c.req) === null || _d === void 0 ? void 0 : _d.recaptchaValidationResult; | ||
@@ -15,0 +15,0 @@ default: |
@@ -6,2 +6,3 @@ import { DynamicModule } from '@nestjs/common'; | ||
static forRootAsync(options: GoogleRecaptchaModuleAsyncOptions): DynamicModule; | ||
private static resolveHttpModule; | ||
private static createAsyncProviders; | ||
@@ -8,0 +9,0 @@ private static createAsyncOptionsProvider; |
@@ -16,2 +16,4 @@ "use strict"; | ||
const recaptcha_request_resolver_1 = require("./services/recaptcha-request.resolver"); | ||
const load_module_1 = require("./helpers/load-module"); | ||
const core_1 = require("@nestjs/core"); | ||
let GoogleRecaptchaModule = GoogleRecaptchaModule_1 = class GoogleRecaptchaModule { | ||
@@ -28,2 +30,10 @@ static forRoot(options) { | ||
]; | ||
const httpModule = this.resolveHttpModule(); | ||
const internalProviders = [ | ||
core_1.Reflector, | ||
{ | ||
provide: provider_declarations_1.RECAPTCHA_HTTP_SERVICE, | ||
useExisting: httpModule.HttpService, | ||
} | ||
]; | ||
return { | ||
@@ -33,5 +43,5 @@ global: true, | ||
imports: [ | ||
common_1.HttpModule | ||
httpModule.HttpModule, | ||
], | ||
providers: providers, | ||
providers: providers.concat(internalProviders), | ||
exports: providers, | ||
@@ -47,2 +57,10 @@ }; | ||
]; | ||
const httpModule = this.resolveHttpModule(); | ||
const internalProviders = [ | ||
core_1.Reflector, | ||
{ | ||
provide: provider_declarations_1.RECAPTCHA_HTTP_SERVICE, | ||
useExisting: httpModule.HttpService, | ||
} | ||
]; | ||
return { | ||
@@ -52,9 +70,17 @@ global: true, | ||
imports: [ | ||
common_1.HttpModule, | ||
httpModule.HttpModule, | ||
...options.imports || [] | ||
], | ||
providers: providers, | ||
providers: providers.concat(internalProviders), | ||
exports: providers, | ||
}; | ||
} | ||
static resolveHttpModule() { | ||
try { | ||
return load_module_1.loadModule('@nestjs/axios'); | ||
} | ||
catch (e) { | ||
return load_module_1.loadModule('@nestjs/common'); | ||
} | ||
} | ||
static createAsyncProviders(options) { | ||
@@ -61,0 +87,0 @@ const providers = [this.createAsyncOptionsProvider(options)]; |
@@ -1,1 +0,1 @@ | ||
export declare function loadModule(moduleName: string): any; | ||
export declare function loadModule(moduleName: string, logError?: boolean): any; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const common_1 = require("@nestjs/common"); | ||
function loadModule(moduleName) { | ||
function loadModule(moduleName, logError = false) { | ||
try { | ||
@@ -11,3 +11,5 @@ return require(moduleName); | ||
catch (e) { | ||
common_1.Logger.error(`Module '${moduleName}' not found. \nPotential solution npm i ${moduleName}`); | ||
if (logError) { | ||
common_1.Logger.error(`Module '${moduleName}' not found. \nPotential solution npm i ${moduleName}`); | ||
} | ||
throw e; | ||
@@ -14,0 +16,0 @@ } |
{ | ||
"name": "@nestlab/google-recaptcha", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Google recaptcha module for NestJS.", | ||
@@ -36,4 +36,4 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@nestjs/core": ">=6.0.0 <8.0.0", | ||
"@nestjs/common": ">=6.0.0 <8.0.0" | ||
"@nestjs/core": ">=6.0.0 <9.0.0", | ||
"@nestjs/common": ">=6.0.0 <9.0.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "devDependencies": { |
export declare const RECAPTCHA_OPTIONS: unique symbol; | ||
export declare const RECAPTCHA_VALIDATION_OPTIONS: unique symbol; | ||
export declare const RECAPTCHA_HTTP_SERVICE = "RECAPTCHA_HTTP_SERVICE"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RECAPTCHA_VALIDATION_OPTIONS = exports.RECAPTCHA_OPTIONS = void 0; | ||
exports.RECAPTCHA_HTTP_SERVICE = exports.RECAPTCHA_VALIDATION_OPTIONS = exports.RECAPTCHA_OPTIONS = void 0; | ||
exports.RECAPTCHA_OPTIONS = Symbol('RECAPTCHA_OPTIONS'); | ||
exports.RECAPTCHA_VALIDATION_OPTIONS = Symbol('RECAPTCHA_VALIDATION_OPTIONS'); | ||
exports.RECAPTCHA_HTTP_SERVICE = 'RECAPTCHA_HTTP_SERVICE'; | ||
//# sourceMappingURL=provider.declarations.js.map |
@@ -87,2 +87,3 @@ "use strict"; | ||
common_1.Injectable(), | ||
__param(0, common_1.Inject(provider_declarations_1.RECAPTCHA_HTTP_SERVICE)), | ||
__param(1, common_1.Inject(provider_declarations_1.RECAPTCHA_OPTIONS)), | ||
@@ -89,0 +90,0 @@ __metadata("design:paramtypes", [common_1.HttpService, Object]) |
@@ -20,3 +20,3 @@ "use strict"; | ||
case application_type_1.ApplicationType.GraphQL: | ||
const graphqlModule = load_module_1.loadModule('@nestjs/graphql'); | ||
const graphqlModule = load_module_1.loadModule('@nestjs/graphql', true); | ||
return (_c = (_b = (_a = graphqlModule.GqlExecutionContext.create(context).getContext().req) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b._httpMessage) === null || _c === void 0 ? void 0 : _c.req; | ||
@@ -23,0 +23,0 @@ default: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58482
634