@nestlab/google-recaptcha 2.1.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/decorators/recaptcha-result.js +2 -2
- package/decorators/recaptcha-result.js.map +1 -1
- package/decorators/recaptcha.js +1 -1
- package/decorators/recaptcha.js.map +1 -1
- package/decorators/set-recaptcha-options.js +1 -1
- package/decorators/set-recaptcha-options.js.map +1 -1
- package/google-recaptcha.module.d.ts +1 -0
- package/google-recaptcha.module.js +11 -6
- package/google-recaptcha.module.js.map +1 -1
- package/guards/google-recaptcha.guard.js +5 -6
- package/guards/google-recaptcha.guard.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/interfaces/google-recaptcha-guard-options.d.ts +0 -5
- package/interfaces/google-recaptcha-validator-options.d.ts +0 -9
- package/package.json +19 -17
- package/services/google-recaptcha.validator.d.ts +1 -1
- package/services/google-recaptcha.validator.js +5 -7
- package/services/google-recaptcha.validator.js.map +1 -1
- package/services/recaptcha-request.resolver.d.ts +0 -5
- package/services/recaptcha-request.resolver.js +3 -19
- package/services/recaptcha-request.resolver.js.map +1 -1
package/README.md
CHANGED
|
@@ -69,9 +69,7 @@ export class AppModule {
|
|
|
69
69
|
| `secretKey` | **Required.**<br> Type: `string`<br> Google recaptcha secret key |
|
|
70
70
|
| `response` | **Required.**<br> Type: `(request) => string`<br> Function that returns response (recaptcha token) by request |
|
|
71
71
|
| `skipIf` | Optional.<br> Type: `boolean` \| `(request) => boolean \| Promise<boolean>` <br> Function that returns true if you allow the request to skip the recaptcha verification. Useful for involing other check methods (e.g. custom privileged API key) or for development or testing |
|
|
72
|
-
| `network` | Optional.<br> Type: `GoogleRecaptchaNetwork` \| `
|
|
73
|
-
| `applicationType` | **Deprecated.** Module detects it automatically from execution context. Optional.<br> Type: `ApplicationType` <br> Application type affect on type of request argument on `response` provider function <br> Context types:<br> `http` - `(req: express.Request \| fastify.Request) => string \| Promise<string>` <br> `graphql` - `(req: http.IncommingMessage) => string \| Promise<string>` |
|
|
74
|
-
| `agent` | **Deprecated.** Use `axiosConfig` option <br> Optional.<br> Type: `https.Agent`<br> If you need to use an agent |
|
|
72
|
+
| `network` | Optional.<br> Type: `GoogleRecaptchaNetwork` \| `string`<br> Default: `GoogleRecaptchaNetwork.Google` <br> If your server has trouble connecting to https://google.com then you can set networks:<br> `GoogleRecaptchaNetwork.Google` = 'https://www.google.com/recaptcha/api/siteverify'<br>`GoogleRecaptchaNetwork.Recaptcha` = 'https://recaptcha.net/recaptcha/api/siteverify'<br> or set any api url |
|
|
75
73
|
| `score` | Optional.<br> Type: `number` \| `(score: number) => boolean`<br> Score validator for reCAPTCHA v3. <br> `number` - minimum available score. <br> `(score: number) => boolean` - function with custom validation rules. |
|
|
76
74
|
| `actions` | Optional.<br> Type: `string[]`<br> Available action list for reCAPTCHA v3. <br> You can make this check stricter by passing the action property parameter to `@Recaptcha(...)` decorator. |
|
|
77
75
|
| `axiosConfig` | Optional.<br> Type: `AxiosRequestConfig`<br> Allows to setup proxy, response timeout, https agent etc... |
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RecaptchaResult = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const load_module_1 = require("../helpers/load-module");
|
|
6
|
-
exports.RecaptchaResult = common_1.createParamDecorator((data, context) => {
|
|
6
|
+
exports.RecaptchaResult = (0, common_1.createParamDecorator)((data, context) => {
|
|
7
7
|
var _a, _b, _c, _d;
|
|
8
8
|
switch (context.getType()) {
|
|
9
9
|
case 'http':
|
|
10
10
|
return context.switchToHttp().getRequest().recaptchaValidationResult;
|
|
11
11
|
case 'graphql':
|
|
12
|
-
const graphqlModule = load_module_1.loadModule('@nestjs/graphql', true);
|
|
12
|
+
const graphqlModule = (0, load_module_1.loadModule)('@nestjs/graphql', true);
|
|
13
13
|
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;
|
|
14
14
|
default:
|
|
15
15
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recaptcha-result.js","sourceRoot":"","sources":["../../src/decorators/recaptcha-result.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,wDAAoD;AAEvC,QAAA,eAAe,GAAG,6BAAoB,
|
|
1
|
+
{"version":3,"file":"recaptcha-result.js","sourceRoot":"","sources":["../../src/decorators/recaptcha-result.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,wDAAoD;AAEvC,QAAA,eAAe,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAI,EAAE,OAAyB,EAAE,EAAE;;IACpF,QAAQ,OAAO,CAAC,OAAO,EAAsB,EAAE;QAC3C,KAAK,MAAM;YACP,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC,yBAAyB,CAAC;QACzE,KAAK,SAAS;YACV,MAAM,aAAa,GAAG,IAAA,wBAAU,EAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YAC1D,OAAO,MAAA,MAAA,MAAA,MAAA,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,0CAAE,UAAU,0CAAE,YAAY,0CAAE,GAAG,0CAAE,yBAAyB,CAAC;QACxI;YACI,OAAO,IAAI,CAAC;KACnB;AACL,CAAC,CAAC,CAAC"}
|
package/decorators/recaptcha.js
CHANGED
|
@@ -5,7 +5,7 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const google_recaptcha_guard_1 = require("../guards/google-recaptcha.guard");
|
|
6
6
|
const set_recaptcha_options_1 = require("./set-recaptcha-options");
|
|
7
7
|
function Recaptcha(options) {
|
|
8
|
-
return common_1.applyDecorators(set_recaptcha_options_1.SetRecaptchaOptions(options), common_1.UseGuards(google_recaptcha_guard_1.GoogleRecaptchaGuard));
|
|
8
|
+
return (0, common_1.applyDecorators)((0, set_recaptcha_options_1.SetRecaptchaOptions)(options), (0, common_1.UseGuards)(google_recaptcha_guard_1.GoogleRecaptchaGuard));
|
|
9
9
|
}
|
|
10
10
|
exports.Recaptcha = Recaptcha;
|
|
11
11
|
//# sourceMappingURL=recaptcha.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recaptcha.js","sourceRoot":"","sources":["../../src/decorators/recaptcha.ts"],"names":[],"mappings":";;;AAAA,2CAA4D;AAC5D,6EAAwE;AAExE,mEAA8D;AAE9D,SAAgB,SAAS,CAAC,OAAwC;IAC9D,OAAO,wBAAe,
|
|
1
|
+
{"version":3,"file":"recaptcha.js","sourceRoot":"","sources":["../../src/decorators/recaptcha.ts"],"names":[],"mappings":";;;AAAA,2CAA4D;AAC5D,6EAAwE;AAExE,mEAA8D;AAE9D,SAAgB,SAAS,CAAC,OAAwC;IAC9D,OAAO,IAAA,wBAAe,EAClB,IAAA,2CAAmB,EAAC,OAAO,CAAC,EAC5B,IAAA,kBAAS,EAAC,6CAAoB,CAAC,CAClC,CAAC;AACN,CAAC;AALD,8BAKC"}
|
|
@@ -4,7 +4,7 @@ exports.SetRecaptchaOptions = void 0;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const provider_declarations_1 = require("../provider.declarations");
|
|
6
6
|
function SetRecaptchaOptions(options) {
|
|
7
|
-
return common_1.SetMetadata(provider_declarations_1.RECAPTCHA_VALIDATION_OPTIONS, options);
|
|
7
|
+
return (0, common_1.SetMetadata)(provider_declarations_1.RECAPTCHA_VALIDATION_OPTIONS, options);
|
|
8
8
|
}
|
|
9
9
|
exports.SetRecaptchaOptions = SetRecaptchaOptions;
|
|
10
10
|
//# sourceMappingURL=set-recaptcha-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-recaptcha-options.js","sourceRoot":"","sources":["../../src/decorators/set-recaptcha-options.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,oEAAwE;AAExE,SAAgB,mBAAmB,CAAC,OAAwC;IACxE,OAAO,oBAAW,
|
|
1
|
+
{"version":3,"file":"set-recaptcha-options.js","sourceRoot":"","sources":["../../src/decorators/set-recaptcha-options.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,oEAAwE;AAExE,SAAgB,mBAAmB,CAAC,OAAwC;IACxE,OAAO,IAAA,oBAAW,EAAC,oDAA4B,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAFD,kDAEC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import { GoogleRecaptchaModuleAsyncOptions, GoogleRecaptchaModuleOptions } from './interfaces/google-recaptcha-module-options';
|
|
3
3
|
export declare class GoogleRecaptchaModule {
|
|
4
|
+
private static axiosDefaultConfig;
|
|
4
5
|
static forRoot(options: GoogleRecaptchaModuleOptions): DynamicModule;
|
|
5
6
|
static forRootAsync(options: GoogleRecaptchaModuleAsyncOptions): DynamicModule;
|
|
6
7
|
private static resolveHttpModule;
|
|
@@ -19,9 +19,11 @@ const recaptcha_request_resolver_1 = require("./services/recaptcha-request.resol
|
|
|
19
19
|
const load_module_1 = require("./helpers/load-module");
|
|
20
20
|
const core_1 = require("@nestjs/core");
|
|
21
21
|
const axios = require("axios");
|
|
22
|
+
const https_1 = require("https");
|
|
22
23
|
class GoogleRecaptchaModule {
|
|
23
24
|
static forRoot(options) {
|
|
24
25
|
const providers = [
|
|
26
|
+
core_1.Reflector,
|
|
25
27
|
google_recaptcha_guard_1.GoogleRecaptchaGuard,
|
|
26
28
|
google_recaptcha_validator_1.GoogleRecaptchaValidator,
|
|
27
29
|
recaptcha_request_resolver_1.RecaptchaRequestResolver,
|
|
@@ -32,7 +34,6 @@ class GoogleRecaptchaModule {
|
|
|
32
34
|
];
|
|
33
35
|
const httpModule = this.resolveHttpModule();
|
|
34
36
|
const internalProviders = [
|
|
35
|
-
core_1.Reflector,
|
|
36
37
|
{
|
|
37
38
|
provide: provider_declarations_1.RECAPTCHA_HTTP_SERVICE,
|
|
38
39
|
useFactory: (axiosInstance) => new httpModule.HttpService(axiosInstance),
|
|
@@ -42,7 +43,7 @@ class GoogleRecaptchaModule {
|
|
|
42
43
|
},
|
|
43
44
|
{
|
|
44
45
|
provide: provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE,
|
|
45
|
-
useFactory: () => axios.default.create(this.transformAxiosConfig(options.axiosConfig)),
|
|
46
|
+
useFactory: () => axios.default.create(this.transformAxiosConfig(Object.assign(Object.assign(Object.assign({}, this.axiosDefaultConfig), options.axiosConfig), { headers: null }))),
|
|
46
47
|
},
|
|
47
48
|
];
|
|
48
49
|
return {
|
|
@@ -57,6 +58,7 @@ class GoogleRecaptchaModule {
|
|
|
57
58
|
}
|
|
58
59
|
static forRootAsync(options) {
|
|
59
60
|
const providers = [
|
|
61
|
+
core_1.Reflector,
|
|
60
62
|
google_recaptcha_guard_1.GoogleRecaptchaGuard,
|
|
61
63
|
google_recaptcha_validator_1.GoogleRecaptchaValidator,
|
|
62
64
|
recaptcha_request_resolver_1.RecaptchaRequestResolver,
|
|
@@ -64,7 +66,6 @@ class GoogleRecaptchaModule {
|
|
|
64
66
|
];
|
|
65
67
|
const httpModule = this.resolveHttpModule();
|
|
66
68
|
const internalProviders = [
|
|
67
|
-
core_1.Reflector,
|
|
68
69
|
{
|
|
69
70
|
provide: provider_declarations_1.RECAPTCHA_HTTP_SERVICE,
|
|
70
71
|
useFactory: (axiosInstance) => new httpModule.HttpService(axiosInstance),
|
|
@@ -75,7 +76,7 @@ class GoogleRecaptchaModule {
|
|
|
75
76
|
{
|
|
76
77
|
provide: provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE,
|
|
77
78
|
useFactory: (options) => {
|
|
78
|
-
const transformedAxiosConfig = this.transformAxiosConfig(options.axiosConfig);
|
|
79
|
+
const transformedAxiosConfig = this.transformAxiosConfig(Object.assign(Object.assign(Object.assign({}, this.axiosDefaultConfig), options.axiosConfig), { headers: null }));
|
|
79
80
|
return axios.default.create(transformedAxiosConfig);
|
|
80
81
|
},
|
|
81
82
|
inject: [
|
|
@@ -96,10 +97,10 @@ class GoogleRecaptchaModule {
|
|
|
96
97
|
}
|
|
97
98
|
static resolveHttpModule() {
|
|
98
99
|
try {
|
|
99
|
-
return load_module_1.loadModule('@nestjs/axios');
|
|
100
|
+
return (0, load_module_1.loadModule)('@nestjs/axios');
|
|
100
101
|
}
|
|
101
102
|
catch (e) {
|
|
102
|
-
return load_module_1.loadModule('@nestjs/common');
|
|
103
|
+
return (0, load_module_1.loadModule)('@nestjs/common');
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
static transformAxiosConfig(axiosConfig) {
|
|
@@ -140,4 +141,8 @@ class GoogleRecaptchaModule {
|
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
exports.GoogleRecaptchaModule = GoogleRecaptchaModule;
|
|
144
|
+
GoogleRecaptchaModule.axiosDefaultConfig = {
|
|
145
|
+
timeout: 60000,
|
|
146
|
+
httpsAgent: new https_1.Agent({ keepAlive: true }),
|
|
147
|
+
};
|
|
143
148
|
//# sourceMappingURL=google-recaptcha.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha.module.js","sourceRoot":"","sources":["../src/google-recaptcha.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4EAAuE;AACvE,sFAAiF;AAKjF,mEAA8G;AAC9G,sFAAiF;AACjF,uDAAmD;AACnD,uCAAyC;AACzC,+BAA+B;
|
|
1
|
+
{"version":3,"file":"google-recaptcha.module.js","sourceRoot":"","sources":["../src/google-recaptcha.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4EAAuE;A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AE,IAAI,EAAC,CAAC;CAC3C,CAAC"}
|
|
@@ -27,9 +27,7 @@ let GoogleRecaptchaGuard = class GoogleRecaptchaGuard {
|
|
|
27
27
|
this.options = options;
|
|
28
28
|
}
|
|
29
29
|
async canActivate(context) {
|
|
30
|
-
const request = this.
|
|
31
|
-
? this.requestResolver.resolveByApplicationType(context, this.options.applicationType)
|
|
32
|
-
: this.requestResolver.resolve(context);
|
|
30
|
+
const request = this.requestResolver.resolve(context);
|
|
33
31
|
const skip = typeof this.options.skipIf === 'function'
|
|
34
32
|
? await this.options.skipIf(request)
|
|
35
33
|
: !!this.options.skipIf;
|
|
@@ -37,7 +35,8 @@ let GoogleRecaptchaGuard = class GoogleRecaptchaGuard {
|
|
|
37
35
|
return true;
|
|
38
36
|
}
|
|
39
37
|
const options = this.reflector.get(provider_declarations_1.RECAPTCHA_VALIDATION_OPTIONS, context.getHandler());
|
|
40
|
-
const response = (options === null || options === void 0 ? void 0 : options.response)
|
|
38
|
+
const response = (options === null || options === void 0 ? void 0 : options.response)
|
|
39
|
+
? await (options === null || options === void 0 ? void 0 : options.response(request))
|
|
41
40
|
: await this.options.response(request);
|
|
42
41
|
const score = (options === null || options === void 0 ? void 0 : options.score) || this.options.score;
|
|
43
42
|
const action = options === null || options === void 0 ? void 0 : options.action;
|
|
@@ -49,8 +48,8 @@ let GoogleRecaptchaGuard = class GoogleRecaptchaGuard {
|
|
|
49
48
|
}
|
|
50
49
|
};
|
|
51
50
|
GoogleRecaptchaGuard = __decorate([
|
|
52
|
-
common_1.Injectable(),
|
|
53
|
-
__param(3, common_1.Inject(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
51
|
+
(0, common_1.Injectable)(),
|
|
52
|
+
__param(3, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
54
53
|
__metadata("design:paramtypes", [google_recaptcha_validator_1.GoogleRecaptchaValidator,
|
|
55
54
|
core_1.Reflector,
|
|
56
55
|
recaptcha_request_resolver_1.RecaptchaRequestResolver, Object])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha.guard.js","sourceRoot":"","sources":["../../src/guards/google-recaptcha.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,uFAAkF;AAElF,oEAA2F;AAC3F,yFAAoF;AACpF,uCAAyC;AACzC,uFAAkF;AAIlF,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAC7B,YAA6B,SAAmC,EACnC,SAAoB,EACpB,eAAyC,EACd,OAAoC;QAH/D,cAAS,GAAT,SAAS,CAA0B;QACnC,cAAS,GAAT,SAAS,CAAW;QACpB,oBAAe,GAAf,eAAe,CAA0B;QACd,YAAO,GAAP,OAAO,CAA6B;IAC5F,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAyB;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"google-recaptcha.guard.js","sourceRoot":"","sources":["../../src/guards/google-recaptcha.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,uFAAkF;AAElF,oEAA2F;AAC3F,yFAAoF;AACpF,uCAAyC;AACzC,uFAAkF;AAIlF,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAC7B,YAA6B,SAAmC,EACnC,SAAoB,EACpB,eAAyC,EACd,OAAoC;QAH/D,cAAS,GAAT,SAAS,CAA0B;QACnC,cAAS,GAAT,SAAS,CAAW;QACpB,oBAAe,GAAf,eAAe,CAA0B;QACd,YAAO,GAAP,OAAO,CAA6B;IAC5F,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAyB;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtD,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU;YAClD,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC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|
|
|
1
1
|
export { Recaptcha } from './decorators/recaptcha';
|
|
2
|
+
export { SetRecaptchaOptions } from './decorators/set-recaptcha-options';
|
|
3
|
+
export { RecaptchaResult } from './decorators/recaptcha-result';
|
|
2
4
|
export { GoogleRecaptchaGuard } from './guards/google-recaptcha.guard';
|
|
3
5
|
export { GoogleRecaptchaModule } from './google-recaptcha.module';
|
|
4
6
|
export { GoogleRecaptchaModuleOptions } from './interfaces/google-recaptcha-module-options';
|
package/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoogleRecaptchaNetworkException = exports.GoogleRecaptchaException = exports.GoogleRecaptchaNetwork = exports.ApplicationType = exports.ErrorCode = exports.GoogleRecaptchaModule = exports.GoogleRecaptchaGuard = exports.RecaptchaResult = exports.SetRecaptchaOptions = exports.Recaptcha = void 0;
|
|
3
4
|
var recaptcha_1 = require("./decorators/recaptcha");
|
|
4
5
|
Object.defineProperty(exports, "Recaptcha", { enumerable: true, get: function () { return recaptcha_1.Recaptcha; } });
|
|
6
|
+
var set_recaptcha_options_1 = require("./decorators/set-recaptcha-options");
|
|
7
|
+
Object.defineProperty(exports, "SetRecaptchaOptions", { enumerable: true, get: function () { return set_recaptcha_options_1.SetRecaptchaOptions; } });
|
|
8
|
+
var recaptcha_result_1 = require("./decorators/recaptcha-result");
|
|
9
|
+
Object.defineProperty(exports, "RecaptchaResult", { enumerable: true, get: function () { return recaptcha_result_1.RecaptchaResult; } });
|
|
5
10
|
var google_recaptcha_guard_1 = require("./guards/google-recaptcha.guard");
|
|
6
11
|
Object.defineProperty(exports, "GoogleRecaptchaGuard", { enumerable: true, get: function () { return google_recaptcha_guard_1.GoogleRecaptchaGuard; } });
|
|
7
12
|
var google_recaptcha_module_1 = require("./google-recaptcha.module");
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AAA1C,sGAAA,SAAS,OAAA;AAClB,4EAAyE;AAAhE,4HAAA,mBAAmB,OAAA;AAC5B,kEAAgE;AAAvD,mHAAA,eAAe,OAAA;AACxB,0EAAuE;AAA9D,8HAAA,oBAAoB,OAAA;AAC7B,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAE9B,iDAA+C;AAAtC,uGAAA,SAAS,OAAA;AAClB,6DAA2D;AAAlD,mHAAA,eAAe,OAAA;AACxB,6EAAyE;AAAhE,kIAAA,sBAAsB,OAAA;AAC/B,sFAAmF;AAA1E,sIAAA,wBAAwB,OAAA;AACjC,sGAAkG;AAAzF,qJAAA,+BAA+B,OAAA"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { RecaptchaResponseProvider, ScoreValidator } from '../types';
|
|
2
|
-
import { ApplicationType } from '../enums/application-type';
|
|
3
2
|
export interface GoogleRecaptchaGuardOptions {
|
|
4
3
|
response: RecaptchaResponseProvider;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
applicationType?: ApplicationType;
|
|
9
4
|
skipIf?: boolean | ((request: any) => boolean | Promise<boolean>);
|
|
10
5
|
score?: ScoreValidator;
|
|
11
6
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as https from 'https';
|
|
3
1
|
import { GoogleRecaptchaNetwork } from '../enums/google-recaptcha-network';
|
|
4
2
|
import { ScoreValidator } from '../types';
|
|
5
3
|
import { AxiosRequestConfig } from 'axios';
|
|
@@ -14,12 +12,5 @@ export interface GoogleRecaptchaValidatorOptions {
|
|
|
14
12
|
* or set any api url
|
|
15
13
|
*/
|
|
16
14
|
network?: GoogleRecaptchaNetwork | string;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated
|
|
19
|
-
* Use axiosConfig for setup agent.
|
|
20
|
-
* If your server has trouble connecting to https://www.google.com,
|
|
21
|
-
* you can use an agent (`proxy-agent` or other NPM modules)
|
|
22
|
-
*/
|
|
23
|
-
agent?: https.Agent;
|
|
24
15
|
axiosConfig?: AxiosRequestConfig;
|
|
25
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestlab/google-recaptcha",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Google recaptcha module for NestJS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nest",
|
|
@@ -33,25 +33,27 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/chvarkov/google-recaptcha",
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@nestjs/
|
|
37
|
-
"@nestjs/common": ">=
|
|
36
|
+
"@nestjs/axios": ">=0.0.1 <1.0.0",
|
|
37
|
+
"@nestjs/common": ">=8.0.0 <10.0.0",
|
|
38
|
+
"@nestjs/core": ">=8.0.0 <10.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@nestjs/
|
|
41
|
-
"@nestjs/
|
|
42
|
-
"@nestjs/
|
|
43
|
-
"@nestjs/
|
|
44
|
-
"@nestjs/
|
|
45
|
-
"@
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/
|
|
48
|
-
"
|
|
41
|
+
"@nestjs/axios": "^0.1.0",
|
|
42
|
+
"@nestjs/common": "^9.0.5",
|
|
43
|
+
"@nestjs/core": "^9.0.5",
|
|
44
|
+
"@nestjs/graphql": "^10.0.21",
|
|
45
|
+
"@nestjs/platform-express": "^9.0.5",
|
|
46
|
+
"@nestjs/testing": "^9.0.5",
|
|
47
|
+
"@types/express": "^4.17.13",
|
|
48
|
+
"@types/jest": "^28.1.6",
|
|
49
|
+
"@types/node": "^18.0.6",
|
|
50
|
+
"jest": "^28.1.3",
|
|
49
51
|
"reflect-metadata": "^0.1.13",
|
|
50
|
-
"rxjs": "^
|
|
51
|
-
"ts-jest": "^
|
|
52
|
-
"ts-loader": "^
|
|
53
|
-
"ts-node": "^
|
|
54
|
-
"typescript": "^
|
|
52
|
+
"rxjs": "^7.5.6",
|
|
53
|
+
"ts-jest": "^28.0.7",
|
|
54
|
+
"ts-loader": "^9.3.1",
|
|
55
|
+
"ts-node": "^10.9.1",
|
|
56
|
+
"typescript": "^4.7.4"
|
|
55
57
|
},
|
|
56
58
|
"jest": {
|
|
57
59
|
"moduleFileExtensions": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpService } from '@nestjs/common';
|
|
2
1
|
import { GoogleRecaptchaValidatorOptions } from '../interfaces/google-recaptcha-validator-options';
|
|
3
2
|
import { GoogleRecaptchaValidationResult } from '../interfaces/google-recaptcha-validation-result';
|
|
4
3
|
import { VerifyResponseOptions } from '../interfaces/verify-response-decorator-options';
|
|
4
|
+
import { HttpService } from "@nestjs/axios";
|
|
5
5
|
export declare class GoogleRecaptchaValidator {
|
|
6
6
|
private readonly http;
|
|
7
7
|
private readonly options;
|
|
@@ -19,6 +19,7 @@ const qs = require("querystring");
|
|
|
19
19
|
const google_recaptcha_network_1 = require("../enums/google-recaptcha-network");
|
|
20
20
|
const error_code_1 = require("../enums/error-code");
|
|
21
21
|
const google_recaptcha_network_exception_1 = require("../exceptions/google-recaptcha-network.exception");
|
|
22
|
+
const axios_1 = require("@nestjs/axios");
|
|
22
23
|
let GoogleRecaptchaValidator = class GoogleRecaptchaValidator {
|
|
23
24
|
constructor(http, options) {
|
|
24
25
|
this.http = http;
|
|
@@ -51,9 +52,6 @@ let GoogleRecaptchaValidator = class GoogleRecaptchaValidator {
|
|
|
51
52
|
const config = {
|
|
52
53
|
headers: this.headers,
|
|
53
54
|
};
|
|
54
|
-
if (this.options.agent) {
|
|
55
|
-
config.httpsAgent = this.options.agent;
|
|
56
|
-
}
|
|
57
55
|
return this.http.post(url, data, config)
|
|
58
56
|
.toPromise()
|
|
59
57
|
.then(res => res.data)
|
|
@@ -97,10 +95,10 @@ let GoogleRecaptchaValidator = class GoogleRecaptchaValidator {
|
|
|
97
95
|
}
|
|
98
96
|
};
|
|
99
97
|
GoogleRecaptchaValidator = __decorate([
|
|
100
|
-
common_1.Injectable(),
|
|
101
|
-
__param(0, common_1.Inject(provider_declarations_1.RECAPTCHA_HTTP_SERVICE)),
|
|
102
|
-
__param(1, common_1.Inject(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
103
|
-
__metadata("design:paramtypes", [
|
|
98
|
+
(0, common_1.Injectable)(),
|
|
99
|
+
__param(0, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_HTTP_SERVICE)),
|
|
100
|
+
__param(1, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
101
|
+
__metadata("design:paramtypes", [axios_1.HttpService, Object])
|
|
104
102
|
], GoogleRecaptchaValidator);
|
|
105
103
|
exports.GoogleRecaptchaValidator = GoogleRecaptchaValidator;
|
|
106
104
|
//# sourceMappingURL=google-recaptcha.validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha.validator.js","sourceRoot":"","sources":["../../src/services/google-recaptcha.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"google-recaptcha.validator.js","sourceRoot":"","sources":["../../src/services/google-recaptcha.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,oEAAqF;AACrF,kCAAkC;AAGlC,gFAA2E;AAI3E,oDAAgD;AAChD,yGAAmG;AACnG,yCAA4C;AAG5C,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAIjC,YAA6D,IAAiB,EACtB,OAAwC;QADnC,SAAI,GAAJ,IAAI,CAAa;QACtB,YAAO,GAAP,OAAO,CAAiC;QAJ/E,mBAAc,GA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C/B,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;YACnD,CAAC,QAAQ,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AA7FY,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAKI,WAAA,IAAA,eAAM,EAAC,8CAAsB,CAAC,CAAA;IAC9B,WAAA,IAAA,eAAM,EAAC,yCAAiB,CAAC,CAAA;qCAD6B,mBAAW;GAJrE,wBAAwB,CA6FpC;AA7FY,4DAAwB"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { ApplicationType } from '../enums/application-type';
|
|
3
2
|
export declare class RecaptchaRequestResolver {
|
|
4
3
|
resolve<T = any>(context: ExecutionContext): T;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
resolveByApplicationType<T = any>(context: ExecutionContext, type: ApplicationType): T;
|
|
9
4
|
}
|
|
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.RecaptchaRequestResolver = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
const application_type_1 = require("../enums/application-type");
|
|
12
11
|
const load_module_1 = require("../helpers/load-module");
|
|
13
12
|
let RecaptchaRequestResolver = class RecaptchaRequestResolver {
|
|
14
13
|
resolve(context) {
|
|
@@ -18,30 +17,15 @@ let RecaptchaRequestResolver = class RecaptchaRequestResolver {
|
|
|
18
17
|
case 'http':
|
|
19
18
|
return context.switchToHttp().getRequest();
|
|
20
19
|
case 'graphql':
|
|
21
|
-
const graphqlModule = load_module_1.loadModule('@nestjs/graphql', true);
|
|
22
|
-
return (_c = (_b = (_a = graphqlModule.GqlExecutionContext.create(context).getContext().req) === null || _a === void 0 ? void 0 : _a.
|
|
20
|
+
const graphqlModule = (0, load_module_1.loadModule)('@nestjs/graphql', true);
|
|
21
|
+
return (_c = (_b = (_a = graphqlModule.GqlExecutionContext.create(context).getContext().req) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b._httpMessage) === null || _c === void 0 ? void 0 : _c.req;
|
|
23
22
|
default:
|
|
24
23
|
throw new Error(`Unsupported request type '${contextType}'.`);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated
|
|
29
|
-
*/
|
|
30
|
-
resolveByApplicationType(context, type) {
|
|
31
|
-
var _a, _b, _c;
|
|
32
|
-
switch (type) {
|
|
33
|
-
case application_type_1.ApplicationType.Rest:
|
|
34
|
-
return context.switchToHttp().getRequest();
|
|
35
|
-
case application_type_1.ApplicationType.GraphQL:
|
|
36
|
-
const graphqlModule = load_module_1.loadModule('@nestjs/graphql', true);
|
|
37
|
-
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;
|
|
38
|
-
default:
|
|
39
|
-
throw new Error(`Unsupported request type '${type}'.`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
26
|
};
|
|
43
27
|
RecaptchaRequestResolver = __decorate([
|
|
44
|
-
common_1.Injectable()
|
|
28
|
+
(0, common_1.Injectable)()
|
|
45
29
|
], RecaptchaRequestResolver);
|
|
46
30
|
exports.RecaptchaRequestResolver = RecaptchaRequestResolver;
|
|
47
31
|
//# sourceMappingURL=recaptcha-request.resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recaptcha-request.resolver.js","sourceRoot":"","sources":["../../src/services/recaptcha-request.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"recaptcha-request.resolver.js","sourceRoot":"","sources":["../../src/services/recaptcha-request.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8D;AAC9D,wDAAoD;AAIpD,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IACjC,OAAO,CAAU,OAAyB;;QACtC,MAAM,WAAW,GAAyB,OAAO,CAAC,OAAO,EAAE,CAAC;QAE5D,QAAQ,WAAW,EAAE;YACjB,KAAK,MAAM;gBACP,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;YAE/C,KAAK,SAAS;gBACV,MAAM,aAAa,GAAG,IAAA,wBAAU,EAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;gBAC1D,OAAO,MAAA,MAAA,MAAA,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,0CAAE,MAAM,0CAAE,YAAY,0CAAE,GAAG,CAAC;YACzG;gBACI,MAAM,IAAI,KAAK,CAAC,6BAA6B,WAAW,IAAI,CAAC,CAAC;SACrE;IACL,CAAC;CACJ,CAAA;AAfY,wBAAwB;IADpC,IAAA,mBAAU,GAAE;GACA,wBAAwB,CAepC;AAfY,4DAAwB"}
|