@nestlab/google-recaptcha 3.0.0 → 3.0.3
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 +2 -0
- package/constants.d.ts +1 -0
- package/constants.js +5 -0
- package/constants.js.map +1 -0
- package/{dist/decorators → decorators}/recaptcha-result.d.ts +0 -0
- package/{dist/decorators → decorators}/recaptcha-result.js +0 -0
- package/{dist/decorators → decorators}/recaptcha-result.js.map +0 -0
- package/{dist/decorators → decorators}/recaptcha.d.ts +0 -0
- package/{dist/decorators → decorators}/recaptcha.js +0 -0
- package/{dist/decorators → decorators}/recaptcha.js.map +0 -0
- package/{dist/decorators → decorators}/set-recaptcha-options.d.ts +0 -0
- package/{dist/decorators → decorators}/set-recaptcha-options.js +0 -0
- package/{dist/decorators → decorators}/set-recaptcha-options.js.map +0 -0
- package/{dist/enums → enums}/error-code.d.ts +0 -0
- package/{dist/enums → enums}/error-code.js +0 -0
- package/{dist/enums → enums}/error-code.js.map +0 -0
- package/{dist/enums → enums}/google-recaptcha-network.d.ts +0 -0
- package/{dist/enums → enums}/google-recaptcha-network.js +0 -0
- package/{dist/enums → enums}/google-recaptcha-network.js.map +0 -0
- package/{dist/exceptions → exceptions}/google-recaptcha-network.exception.d.ts +0 -0
- package/{dist/exceptions → exceptions}/google-recaptcha-network.exception.js +0 -0
- package/{dist/exceptions → exceptions}/google-recaptcha-network.exception.js.map +0 -0
- package/{dist/exceptions → exceptions}/google-recaptcha.exception.d.ts +0 -0
- package/{dist/exceptions → exceptions}/google-recaptcha.exception.js +0 -0
- package/{dist/exceptions → exceptions}/google-recaptcha.exception.js.map +0 -0
- package/{dist/google-recaptcha.module.d.ts → google-recaptcha.module.d.ts} +0 -0
- package/{dist/google-recaptcha.module.js → google-recaptcha.module.js} +12 -0
- package/google-recaptcha.module.js.map +1 -0
- package/{dist/guards → guards}/google-recaptcha.guard.d.ts +4 -3
- package/{dist/guards → guards}/google-recaptcha.guard.js +10 -3
- package/guards/google-recaptcha.guard.js.map +1 -0
- package/{dist/helpers → helpers}/load-module.d.ts +0 -0
- package/{dist/helpers → helpers}/load-module.js +0 -0
- package/{dist/helpers → helpers}/load-module.js.map +0 -0
- package/{dist/index.d.ts → index.d.ts} +0 -1
- package/{dist/index.js → index.js} +1 -3
- package/{dist/index.js.map → index.js.map} +1 -1
- package/{dist/interfaces → interfaces}/google-recaptcha-guard-options.d.ts +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-guard-options.js +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-guard-options.js.map +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-module-options.d.ts +3 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-module-options.js +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-module-options.js.map +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-validation-result.d.ts +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-validation-result.js +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-validation-result.js.map +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-validator-options.d.ts +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-validator-options.js +0 -0
- package/{dist/interfaces → interfaces}/google-recaptcha-validator-options.js.map +0 -0
- package/{dist/interfaces → interfaces}/verify-response-decorator-options.d.ts +0 -0
- package/{dist/interfaces → interfaces}/verify-response-decorator-options.js +0 -0
- package/{dist/interfaces → interfaces}/verify-response-decorator-options.js.map +0 -0
- package/{dist/interfaces → interfaces}/verify-response.d.ts +0 -0
- package/{dist/interfaces → interfaces}/verify-response.js +0 -0
- package/{dist/interfaces → interfaces}/verify-response.js.map +0 -0
- package/{dist/models → models}/recaptcha-verification-result.d.ts +0 -0
- package/{dist/models → models}/recaptcha-verification-result.js +0 -0
- package/{dist/models → models}/recaptcha-verification-result.js.map +0 -0
- package/package.json +1 -1
- package/{dist/provider.declarations.d.ts → provider.declarations.d.ts} +1 -0
- package/{dist/provider.declarations.js → provider.declarations.js} +2 -1
- package/{dist/provider.declarations.js.map → provider.declarations.js.map} +1 -1
- package/{dist/services → services}/google-recaptcha.validator.d.ts +4 -2
- package/{dist/services → services}/google-recaptcha.validator.js +22 -5
- package/services/google-recaptcha.validator.js.map +1 -0
- package/{dist/services → services}/recaptcha-request.resolver.d.ts +0 -0
- package/{dist/services → services}/recaptcha-request.resolver.js +0 -0
- package/{dist/services → services}/recaptcha-request.resolver.js.map +0 -0
- package/{dist/types.d.ts → types.d.ts} +0 -0
- package/{dist/types.js → types.js} +0 -0
- package/{dist/types.js.map → types.js.map} +0 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/dist/CONTRIBUTING.md +0 -58
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -277
- package/dist/enums/application-type.d.ts +0 -4
- package/dist/enums/application-type.js +0 -9
- package/dist/enums/application-type.js.map +0 -1
- package/dist/google-recaptcha.module.js.map +0 -1
- package/dist/guards/google-recaptcha.guard.js.map +0 -1
- package/dist/package.json +0 -78
- package/dist/services/google-recaptcha.validator.js.map +0 -1
- package/tsconfig.json +0 -20
package/README.md
CHANGED
|
@@ -68,6 +68,8 @@ export class AppModule {
|
|
|
68
68
|
|-------------------|-------------|
|
|
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
|
+
| `debug` | Optional.<br> Type: `boolean` <br> Enables logging requests, responses, errors and transformed results |
|
|
72
|
+
| `logger` | Optional.<br> Type: `Logger` <br> Instance of custom logger that extended from Logger (@nestjs/common) |
|
|
71
73
|
| `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
74
|
| `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 |
|
|
73
75
|
| `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. |
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RECAPTCHA_LOG_CONTEXT = "GoogleRecaptcha";
|
package/constants.js
ADDED
package/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,iBAAiB,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -12,6 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.GoogleRecaptchaModule = void 0;
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
15
16
|
const google_recaptcha_guard_1 = require("./guards/google-recaptcha.guard");
|
|
16
17
|
const google_recaptcha_validator_1 = require("./services/google-recaptcha.validator");
|
|
17
18
|
const provider_declarations_1 = require("./provider.declarations");
|
|
@@ -31,6 +32,10 @@ class GoogleRecaptchaModule {
|
|
|
31
32
|
provide: provider_declarations_1.RECAPTCHA_OPTIONS,
|
|
32
33
|
useValue: options,
|
|
33
34
|
},
|
|
35
|
+
{
|
|
36
|
+
provide: provider_declarations_1.RECAPTCHA_LOGGER,
|
|
37
|
+
useFactory: () => options.logger || new common_1.Logger(),
|
|
38
|
+
},
|
|
34
39
|
];
|
|
35
40
|
const httpModule = this.resolveHttpModule();
|
|
36
41
|
const internalProviders = [
|
|
@@ -59,6 +64,13 @@ class GoogleRecaptchaModule {
|
|
|
59
64
|
static forRootAsync(options) {
|
|
60
65
|
const providers = [
|
|
61
66
|
core_1.Reflector,
|
|
67
|
+
{
|
|
68
|
+
provide: provider_declarations_1.RECAPTCHA_LOGGER,
|
|
69
|
+
useFactory: (options) => options.logger || new common_1.Logger(),
|
|
70
|
+
inject: [
|
|
71
|
+
provider_declarations_1.RECAPTCHA_OPTIONS,
|
|
72
|
+
],
|
|
73
|
+
},
|
|
62
74
|
google_recaptcha_guard_1.GoogleRecaptchaGuard,
|
|
63
75
|
google_recaptcha_validator_1.GoogleRecaptchaValidator,
|
|
64
76
|
recaptcha_request_resolver_1.RecaptchaRequestResolver,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-recaptcha.module.js","sourceRoot":"","sources":["../src/google-recaptcha.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAAiE;AACjE,4EAAuE;AACvE,sFAAiF;AAKjF,mEAKiC;AACjC,sFAAiF;AACjF,uDAAmD;AACnD,uCAAyC;AACzC,+BAA+B;AAC/B,iCAA8B;AAE9B,MAAa,qBAAqB;IAM9B,MAAM,CAAC,OAAO,CAAC,OAAqC;QAChD,MAAM,SAAS,GAAe;YAC1B,gBAAS;YACT,6CAAoB;YACpB,qDAAwB;YACxB,qDAAwB;YACxB;gBACI,OAAO,EAAE,yCAAiB;gBAC1B,QAAQ,EAAE,OAAO;aACpB;YACD;gBACI,OAAO,EAAE,wCAAgB;gBACzB,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAA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estjs/common';
|
|
1
|
+
import { CanActivate, ExecutionContext, Logger } from '@nestjs/common';
|
|
2
2
|
import { GoogleRecaptchaValidator } from '../services/google-recaptcha.validator';
|
|
3
|
-
import { GoogleRecaptchaGuardOptions } from '../interfaces/google-recaptcha-guard-options';
|
|
4
3
|
import { Reflector } from '@nestjs/core';
|
|
5
4
|
import { RecaptchaRequestResolver } from '../services/recaptcha-request.resolver';
|
|
5
|
+
import { GoogleRecaptchaModuleOptions } from '../interfaces/google-recaptcha-module-options';
|
|
6
6
|
export declare class GoogleRecaptchaGuard implements CanActivate {
|
|
7
7
|
private readonly validator;
|
|
8
8
|
private readonly reflector;
|
|
9
9
|
private readonly requestResolver;
|
|
10
|
+
private readonly logger;
|
|
10
11
|
private readonly options;
|
|
11
|
-
constructor(validator: GoogleRecaptchaValidator, reflector: Reflector, requestResolver: RecaptchaRequestResolver, options:
|
|
12
|
+
constructor(validator: GoogleRecaptchaValidator, reflector: Reflector, requestResolver: RecaptchaRequestResolver, logger: Logger, options: GoogleRecaptchaModuleOptions);
|
|
12
13
|
canActivate(context: ExecutionContext): Promise<true | never>;
|
|
13
14
|
}
|
|
@@ -19,11 +19,13 @@ const provider_declarations_1 = require("../provider.declarations");
|
|
|
19
19
|
const google_recaptcha_exception_1 = require("../exceptions/google-recaptcha.exception");
|
|
20
20
|
const core_1 = require("@nestjs/core");
|
|
21
21
|
const recaptcha_request_resolver_1 = require("../services/recaptcha-request.resolver");
|
|
22
|
+
const constants_1 = require("../constants");
|
|
22
23
|
let GoogleRecaptchaGuard = class GoogleRecaptchaGuard {
|
|
23
|
-
constructor(validator, reflector, requestResolver, options) {
|
|
24
|
+
constructor(validator, reflector, requestResolver, logger, options) {
|
|
24
25
|
this.validator = validator;
|
|
25
26
|
this.reflector = reflector;
|
|
26
27
|
this.requestResolver = requestResolver;
|
|
28
|
+
this.logger = logger;
|
|
27
29
|
this.options = options;
|
|
28
30
|
}
|
|
29
31
|
async canActivate(context) {
|
|
@@ -41,6 +43,9 @@ let GoogleRecaptchaGuard = class GoogleRecaptchaGuard {
|
|
|
41
43
|
const score = (options === null || options === void 0 ? void 0 : options.score) || this.options.score;
|
|
42
44
|
const action = options === null || options === void 0 ? void 0 : options.action;
|
|
43
45
|
request.recaptchaValidationResult = await this.validator.validate({ response, score, action });
|
|
46
|
+
if (this.options.debug) {
|
|
47
|
+
this.logger.debug(request.recaptchaValidationResult, `${constants_1.RECAPTCHA_LOG_CONTEXT}.result`);
|
|
48
|
+
}
|
|
44
49
|
if (request.recaptchaValidationResult.success) {
|
|
45
50
|
return true;
|
|
46
51
|
}
|
|
@@ -49,10 +54,12 @@ let GoogleRecaptchaGuard = class GoogleRecaptchaGuard {
|
|
|
49
54
|
};
|
|
50
55
|
GoogleRecaptchaGuard = __decorate([
|
|
51
56
|
(0, common_1.Injectable)(),
|
|
52
|
-
__param(3, (0, common_1.Inject)(provider_declarations_1.
|
|
57
|
+
__param(3, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_LOGGER)),
|
|
58
|
+
__param(4, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
53
59
|
__metadata("design:paramtypes", [google_recaptcha_validator_1.GoogleRecaptchaValidator,
|
|
54
60
|
core_1.Reflector,
|
|
55
|
-
recaptcha_request_resolver_1.RecaptchaRequestResolver,
|
|
61
|
+
recaptcha_request_resolver_1.RecaptchaRequestResolver,
|
|
62
|
+
common_1.Logger, Object])
|
|
56
63
|
], GoogleRecaptchaGuard);
|
|
57
64
|
exports.GoogleRecaptchaGuard = GoogleRecaptchaGuard;
|
|
58
65
|
//# sourceMappingURL=google-recaptcha.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-recaptcha.guard.js","sourceRoot":"","sources":["../../src/guards/google-recaptcha.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2F;AAC3F,uFAAkF;AAClF,oEAA6G;AAC7G,yFAAoF;AACpF,uCAAyC;AACz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MAAM,CAAC;QAE/B,OAAO,CAAC,yBAAyB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAC,CAAC,CAAC;QAE7F,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,iCAAqB,SAAS,CAAC,CAAC;SAC3F;QAED,IAAI,OAAO,CAAC,yBAAyB,CAAC,OAAO,EAAE;YAC3C,OAAO,IAAI,CAAC;SACf;QAED,MAAM,IAAI,qDAAwB,CAAC,OAAO,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACjF,CAAC;CACJ,CAAA;AAxCY,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKI,WAAA,IAAA,eAAM,EAAC,wCAAgB,CAAC,CAAA;IACxB,WAAA,IAAA,eAAM,EAAC,yCAAiB,CAAC,CAAA;qCAJE,qDAAwB;QACxB,gBAAS;QACH,qDAAwB;QACP,eAAM;GAJ5D,oBAAoB,CAwChC;AAxCY,oDAAoB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,6 @@ export { GoogleRecaptchaGuard } from './guards/google-recaptcha.guard';
|
|
|
5
5
|
export { GoogleRecaptchaModule } from './google-recaptcha.module';
|
|
6
6
|
export { GoogleRecaptchaModuleOptions } from './interfaces/google-recaptcha-module-options';
|
|
7
7
|
export { ErrorCode } from './enums/error-code';
|
|
8
|
-
export { ApplicationType } from './enums/application-type';
|
|
9
8
|
export { GoogleRecaptchaNetwork } from './enums/google-recaptcha-network';
|
|
10
9
|
export { GoogleRecaptchaException } from './exceptions/google-recaptcha.exception';
|
|
11
10
|
export { GoogleRecaptchaNetworkException } from './exceptions/google-recaptcha-network.exception';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GoogleRecaptchaNetworkException = exports.GoogleRecaptchaException = exports.GoogleRecaptchaNetwork = exports.
|
|
3
|
+
exports.GoogleRecaptchaNetworkException = exports.GoogleRecaptchaException = exports.GoogleRecaptchaNetwork = exports.ErrorCode = exports.GoogleRecaptchaModule = exports.GoogleRecaptchaGuard = exports.RecaptchaResult = exports.SetRecaptchaOptions = exports.Recaptcha = void 0;
|
|
4
4
|
var recaptcha_1 = require("./decorators/recaptcha");
|
|
5
5
|
Object.defineProperty(exports, "Recaptcha", { enumerable: true, get: function () { return recaptcha_1.Recaptcha; } });
|
|
6
6
|
var set_recaptcha_options_1 = require("./decorators/set-recaptcha-options");
|
|
@@ -13,8 +13,6 @@ var google_recaptcha_module_1 = require("./google-recaptcha.module");
|
|
|
13
13
|
Object.defineProperty(exports, "GoogleRecaptchaModule", { enumerable: true, get: function () { return google_recaptcha_module_1.GoogleRecaptchaModule; } });
|
|
14
14
|
var error_code_1 = require("./enums/error-code");
|
|
15
15
|
Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return error_code_1.ErrorCode; } });
|
|
16
|
-
var application_type_1 = require("./enums/application-type");
|
|
17
|
-
Object.defineProperty(exports, "ApplicationType", { enumerable: true, get: function () { return application_type_1.ApplicationType; } });
|
|
18
16
|
var google_recaptcha_network_1 = require("./enums/google-recaptcha-network");
|
|
19
17
|
Object.defineProperty(exports, "GoogleRecaptchaNetwork", { enumerable: true, get: function () { return google_recaptcha_network_1.GoogleRecaptchaNetwork; } });
|
|
20
18
|
var google_recaptcha_exception_1 = require("./exceptions/google-recaptcha.exception");
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,6EAAyE;AAAhE,kIAAA,sBAAsB,OAAA;AAC/B,sFAAmF;AAA1E,sIAAA,wBAAwB,OAAA;AACjC,sGAAkG;AAAzF,qJAAA,+BAA+B,OAAA"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { GoogleRecaptchaGuardOptions } from './google-recaptcha-guard-options';
|
|
2
2
|
import { GoogleRecaptchaValidatorOptions } from './google-recaptcha-validator-options';
|
|
3
3
|
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
|
4
|
+
import { Logger } from '@nestjs/common';
|
|
4
5
|
export interface GoogleRecaptchaModuleOptions extends GoogleRecaptchaValidatorOptions, GoogleRecaptchaGuardOptions {
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
logger?: Logger;
|
|
5
8
|
}
|
|
6
9
|
export interface GoogleRecaptchaOptionsFactory {
|
|
7
10
|
createGoogleRecaptchaOptions(): Promise<GoogleRecaptchaModuleOptions> | GoogleRecaptchaModuleOptions;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -2,3 +2,4 @@ export declare const RECAPTCHA_OPTIONS: unique symbol;
|
|
|
2
2
|
export declare const RECAPTCHA_VALIDATION_OPTIONS: unique symbol;
|
|
3
3
|
export declare const RECAPTCHA_AXIOS_INSTANCE = "RECAPTCHA_AXIOS_INSTANCE";
|
|
4
4
|
export declare const RECAPTCHA_HTTP_SERVICE = "RECAPTCHA_HTTP_SERVICE";
|
|
5
|
+
export declare const RECAPTCHA_LOGGER = "RECAPTCHA_LOGGER";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RECAPTCHA_HTTP_SERVICE = exports.RECAPTCHA_AXIOS_INSTANCE = exports.RECAPTCHA_VALIDATION_OPTIONS = exports.RECAPTCHA_OPTIONS = void 0;
|
|
3
|
+
exports.RECAPTCHA_LOGGER = exports.RECAPTCHA_HTTP_SERVICE = exports.RECAPTCHA_AXIOS_INSTANCE = exports.RECAPTCHA_VALIDATION_OPTIONS = exports.RECAPTCHA_OPTIONS = void 0;
|
|
4
4
|
exports.RECAPTCHA_OPTIONS = Symbol('RECAPTCHA_OPTIONS');
|
|
5
5
|
exports.RECAPTCHA_VALIDATION_OPTIONS = Symbol('RECAPTCHA_VALIDATION_OPTIONS');
|
|
6
6
|
exports.RECAPTCHA_AXIOS_INSTANCE = 'RECAPTCHA_AXIOS_INSTANCE';
|
|
7
7
|
exports.RECAPTCHA_HTTP_SERVICE = 'RECAPTCHA_HTTP_SERVICE';
|
|
8
|
+
exports.RECAPTCHA_LOGGER = 'RECAPTCHA_LOGGER';
|
|
8
9
|
//# sourceMappingURL=provider.declarations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.declarations.js","sourceRoot":"","sources":["../src/provider.declarations.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEhD,QAAA,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAEtE,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAEtD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"provider.declarations.js","sourceRoot":"","sources":["../src/provider.declarations.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEhD,QAAA,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAEtE,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAEtD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAElD,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
2
|
import { GoogleRecaptchaValidationResult } from '../interfaces/google-recaptcha-validation-result';
|
|
3
3
|
import { VerifyResponseOptions } from '../interfaces/verify-response-decorator-options';
|
|
4
4
|
import { HttpService } from "@nestjs/axios";
|
|
5
|
+
import { GoogleRecaptchaModuleOptions } from '../interfaces/google-recaptcha-module-options';
|
|
5
6
|
export declare class GoogleRecaptchaValidator {
|
|
6
7
|
private readonly http;
|
|
8
|
+
private readonly logger;
|
|
7
9
|
private readonly options;
|
|
8
10
|
private readonly defaultNetwork;
|
|
9
11
|
private readonly headers;
|
|
10
|
-
constructor(http: HttpService, options:
|
|
12
|
+
constructor(http: HttpService, logger: Logger, options: GoogleRecaptchaModuleOptions);
|
|
11
13
|
/**
|
|
12
14
|
* @throws GoogleRecaptchaNetworkException
|
|
13
15
|
* @param {VerifyResponseOptions} options
|
|
@@ -20,9 +20,11 @@ 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
22
|
const axios_1 = require("@nestjs/axios");
|
|
23
|
+
const constants_1 = require("../constants");
|
|
23
24
|
let GoogleRecaptchaValidator = class GoogleRecaptchaValidator {
|
|
24
|
-
constructor(http, options) {
|
|
25
|
+
constructor(http, logger, options) {
|
|
25
26
|
this.http = http;
|
|
27
|
+
this.logger = logger;
|
|
26
28
|
this.options = options;
|
|
27
29
|
this.defaultNetwork = google_recaptcha_network_1.GoogleRecaptchaNetwork.Google;
|
|
28
30
|
this.headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
@@ -47,20 +49,33 @@ let GoogleRecaptchaValidator = class GoogleRecaptchaValidator {
|
|
|
47
49
|
return result;
|
|
48
50
|
}
|
|
49
51
|
verifyResponse(response) {
|
|
50
|
-
const
|
|
52
|
+
const body = qs.stringify({ secret: this.options.secretKey, response });
|
|
51
53
|
const url = this.options.network || this.defaultNetwork;
|
|
52
54
|
const config = {
|
|
53
55
|
headers: this.headers,
|
|
54
56
|
};
|
|
55
|
-
|
|
57
|
+
if (this.options.debug) {
|
|
58
|
+
this.logger.debug({ body }, `${constants_1.RECAPTCHA_LOG_CONTEXT}.request`);
|
|
59
|
+
}
|
|
60
|
+
return this.http.post(url, body, config)
|
|
56
61
|
.toPromise()
|
|
57
62
|
.then(res => res.data)
|
|
63
|
+
.then(data => {
|
|
64
|
+
if (this.options.debug) {
|
|
65
|
+
this.logger.debug(data, `${constants_1.RECAPTCHA_LOG_CONTEXT}.response`);
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
})
|
|
58
69
|
.then(result => (Object.assign(Object.assign({}, result), { errors: result['error-codes'] || [] })))
|
|
59
70
|
.then(result => {
|
|
60
71
|
delete result['error-codes'];
|
|
61
72
|
return result;
|
|
62
73
|
})
|
|
63
74
|
.catch((err) => {
|
|
75
|
+
var _a;
|
|
76
|
+
if (this.options.debug) {
|
|
77
|
+
this.logger.debug(((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data) || err.code || { error: `${err === null || err === void 0 ? void 0 : err.name}: ${err === null || err === void 0 ? void 0 : err.message}`, stack: err === null || err === void 0 ? void 0 : err.stack }, `${constants_1.RECAPTCHA_LOG_CONTEXT}.error`);
|
|
78
|
+
}
|
|
64
79
|
const networkErrorCode = err.isAxiosError && err.code;
|
|
65
80
|
if (networkErrorCode) {
|
|
66
81
|
throw new google_recaptcha_network_exception_1.GoogleRecaptchaNetworkException(networkErrorCode);
|
|
@@ -97,8 +112,10 @@ let GoogleRecaptchaValidator = class GoogleRecaptchaValidator {
|
|
|
97
112
|
GoogleRecaptchaValidator = __decorate([
|
|
98
113
|
(0, common_1.Injectable)(),
|
|
99
114
|
__param(0, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_HTTP_SERVICE)),
|
|
100
|
-
__param(1, (0, common_1.Inject)(provider_declarations_1.
|
|
101
|
-
|
|
115
|
+
__param(1, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_LOGGER)),
|
|
116
|
+
__param(2, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
117
|
+
__metadata("design:paramtypes", [axios_1.HttpService,
|
|
118
|
+
common_1.Logger, Object])
|
|
102
119
|
], GoogleRecaptchaValidator);
|
|
103
120
|
exports.GoogleRecaptchaValidator = GoogleRecaptchaValidator;
|
|
104
121
|
//# sourceMappingURL=google-recaptcha.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-recaptcha.validator.js","sourceRoot":"","sources":["../../src/services/google-recaptcha.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,oEAAuG;AACvG,kCAAkC;AAGlC,gFAA2E;AAI3E,oDAAgD;AAChD,yGAAmG;AACnG,yCAA4C;AAC5C,4CAAqD;AAIrD,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAIjC,YAA6D,IAAiB,EACvB,M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AA,IAAA,eAAM,EAAC,wCAAgB,CAAC,CAAA;IACxB,WAAA,IAAA,eAAM,EAAC,yCAAiB,CAAC,CAAA;qCAF6B,mBAAW;QACf,eAAM;GAL5D,wBAAwB,CAgHpC;AAhHY,4DAAwB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: ''
|
|
5
|
-
labels: bug
|
|
6
|
-
assignees: chvarkov
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is.
|
|
12
|
-
|
|
13
|
-
**To Reproduce**
|
|
14
|
-
Describe steps to reproduce the behavior. Code examples.
|
|
15
|
-
|
|
16
|
-
**Expected behavior**
|
|
17
|
-
A clear and concise description of what you expected to happen.
|
|
18
|
-
|
|
19
|
-
**Screenshots**
|
|
20
|
-
If applicable, add screenshots to help explain your problem.
|
|
21
|
-
|
|
22
|
-
**Additional context**
|
|
23
|
-
Add any other context about the problem here.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: ''
|
|
5
|
-
labels: feature request
|
|
6
|
-
assignees: chvarkov
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Is your feature request related to a problem? Please describe.**
|
|
11
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
-
|
|
13
|
-
**Describe the solution you'd like**
|
|
14
|
-
A clear and concise description of what you want to happen.
|
|
15
|
-
|
|
16
|
-
**Describe alternatives you've considered**
|
|
17
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
-
|
|
19
|
-
**Additional context**
|
|
20
|
-
Add any other context or screenshots about the feature request here.
|
package/dist/CONTRIBUTING.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
Thanks for considering contributing to GoogleRecaptchaModule!
|
|
4
|
-
|
|
5
|
-
## Opening issues
|
|
6
|
-
|
|
7
|
-
If you find a bug, please feel free to [open an issue](https://github.com/chvarkov/google-recaptcha/issues).
|
|
8
|
-
|
|
9
|
-
If you taking the time to mention a problem, even a seemingly minor one, it is greatly appreciated, and a totally valid contribution to this project. Thank you!
|
|
10
|
-
|
|
11
|
-
## Fixing bugs
|
|
12
|
-
|
|
13
|
-
We love pull requests. Here’s a quick guide:
|
|
14
|
-
|
|
15
|
-
1. [Fork this repository](https://github.com/chvarkov/google-recaptcha/fork) and then clone it locally:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
git clone https://github.com/chvarkov/google-recaptcha.git
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
2. Create a topic branch for your changes:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
git checkout -b bugfix/for-that-thing
|
|
25
|
-
```
|
|
26
|
-
3. Commit a failing test for the bug:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
git commit -am "Adds a failing test to demonstrate that thing"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
4. Commit a fix that makes the test pass:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
git commit -am "Adds a fix for that thing!"
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
5. Run the tests:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm test
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
6. If everything looks good, push to your fork:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
git push origin fix-for-that-thing
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
7. [Submit a pull request.](https://help.github.com/articles/creating-a-pull-request)
|
|
51
|
-
|
|
52
|
-
8. Enjoy being the wonderful person you are
|
|
53
|
-
|
|
54
|
-
After you’ve opened your pull request, [you should email me](mailto:chvarkov.alexey@gmail.com) your mailing address so I can mail you a personal thank you note. Seriously!
|
|
55
|
-
|
|
56
|
-
## Adding new features
|
|
57
|
-
|
|
58
|
-
Thinking of adding a new feature? Cool! [Open an issue](https://github.com/chvarkov/google-recaptcha/issues) and let’s design it together.
|
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Alexey Chvarkov
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/README.md
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
# Google recaptcha module
|
|
2
|
-
|
|
3
|
-
The [NestJS](https://docs.nestjs.com/) module to protect your endpoints via [google recaptcha](https://www.google.com/recaptcha/about/).
|
|
4
|
-
|
|
5
|
-
Supported for HTTP and GraphQL [NestJS](https://docs.nestjs.com/) applications.
|
|
6
|
-
|
|
7
|
-
- [Installation](#installation)
|
|
8
|
-
- [Configuration](#configuration)
|
|
9
|
-
- [Usage](#usage)
|
|
10
|
-
- [Validate in service](#validate-in-service)
|
|
11
|
-
- [Guard](#guard)
|
|
12
|
-
- [GraphQL guard](#graphql-guard)
|
|
13
|
-
- [Error handling](#error-handling)
|
|
14
|
-
|
|
15
|
-
Usage example [here](https://github.com/chvarkov/google-recaptcha-example)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
$ npm i @nestlab/google-recaptcha
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Configuration
|
|
25
|
-
|
|
26
|
-
**Configuration for REST application**
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
@Module({
|
|
30
|
-
imports: [
|
|
31
|
-
GoogleRecaptchaModule.forRoot({
|
|
32
|
-
secretKey: process.env.GOOGLE_RECAPTCHA_SECRET_KEY,
|
|
33
|
-
response: req => req.headers.recaptcha,
|
|
34
|
-
skipIf: process.env.NODE_ENV !== 'production',
|
|
35
|
-
network: GoogleRecaptchaNetwork.Recaptcha,
|
|
36
|
-
})
|
|
37
|
-
],
|
|
38
|
-
})
|
|
39
|
-
export class AppModule {
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**Configuration for reCAPTCHA V3**
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
@Module({
|
|
47
|
-
imports: [
|
|
48
|
-
GoogleRecaptchaModule.forRoot({
|
|
49
|
-
secretKey: process.env.GOOGLE_RECAPTCHA_SECRET_KEY,
|
|
50
|
-
response: (req: IncomingMessage) => (req.headers.recaptcha || '').toString(),
|
|
51
|
-
skipIf: process.env.NODE_ENV !== 'production',
|
|
52
|
-
actions: ['SignUp', 'SignIn'],
|
|
53
|
-
score: 0.8,
|
|
54
|
-
})
|
|
55
|
-
],
|
|
56
|
-
})
|
|
57
|
-
export class AppModule {
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Tip: header names transforming to lower case.**
|
|
62
|
-
|
|
63
|
-
**For example:** If you send 'Recaptcha' header then use `(req) => req.headers.recaptcha`
|
|
64
|
-
|
|
65
|
-
**Configuration options**
|
|
66
|
-
|
|
67
|
-
| Property | Description |
|
|
68
|
-
|-------------------|-------------|
|
|
69
|
-
| `secretKey` | **Required.**<br> Type: `string`<br> Google recaptcha secret key |
|
|
70
|
-
| `response` | **Required.**<br> Type: `(request) => string`<br> Function that returns response (recaptcha token) by request |
|
|
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` \| `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 |
|
|
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. |
|
|
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. |
|
|
75
|
-
| `axiosConfig` | Optional.<br> Type: `AxiosRequestConfig`<br> Allows to setup proxy, response timeout, https agent etc... |
|
|
76
|
-
|
|
77
|
-
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.
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
@Module({
|
|
81
|
-
imports: [
|
|
82
|
-
GoogleRecaptchaModule.forRootAsync({
|
|
83
|
-
imports: [ConfigModule],
|
|
84
|
-
useFactory: (configService: ConfigService) => configService.googleRecaptchaOptions,
|
|
85
|
-
inject: [ConfigService],
|
|
86
|
-
})
|
|
87
|
-
],
|
|
88
|
-
})
|
|
89
|
-
export class AppModule {
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Usage
|
|
94
|
-
|
|
95
|
-
### Validate in service
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
@Injectable()
|
|
99
|
-
export class SomeService {
|
|
100
|
-
constructor(private readonly recaptchaValidator: GoogleRecaptchaValidator) {
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async someAction(recaptchaToken: string): Promise<void> {
|
|
104
|
-
const result = await this.recaptchaValidator.validate({
|
|
105
|
-
response: recaptchaToken,
|
|
106
|
-
score: 0.8,
|
|
107
|
-
action: 'SomeAction',
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (!result.success) {
|
|
111
|
-
throw new GoogleRecaptchaException(result.errors);
|
|
112
|
-
}
|
|
113
|
-
// TODO: Your implemetation
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Guard
|
|
119
|
-
|
|
120
|
-
Use `@Recaptcha` decorator to protect your endpoints.
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
|
|
124
|
-
@Controller('feedback')
|
|
125
|
-
export class FeedbackController {
|
|
126
|
-
@Recaptcha()
|
|
127
|
-
@Post('send')
|
|
128
|
-
async send(): Promise<any> {
|
|
129
|
-
// TODO: Your implementation.
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
You can override default property that contain recaptcha for specific endpoint.
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
|
|
139
|
-
@Controller('feedback')
|
|
140
|
-
export class FeedbackController {
|
|
141
|
-
@Recaptcha({response: req => req.body.recaptha})
|
|
142
|
-
@Post('send')
|
|
143
|
-
async send(): Promise<any> {
|
|
144
|
-
// TODO: Your implementation.
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Also you can override recaptcha v3 options.
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
|
|
154
|
-
@Controller('feedback')
|
|
155
|
-
export class FeedbackController {
|
|
156
|
-
@Recaptcha({response: req => req.body.recaptha, action: 'Send', score: 0.8})
|
|
157
|
-
@Post('send')
|
|
158
|
-
async send(): Promise<any> {
|
|
159
|
-
// TODO: Your implementation.
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Get verification result
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
|
|
169
|
-
@Controller('feedback')
|
|
170
|
-
export class FeedbackController {
|
|
171
|
-
@Recaptcha()
|
|
172
|
-
@Post('send')
|
|
173
|
-
async send(@RecaptchaResult() recaptchaResult: GoogleRecaptchaValidationResult): Promise<any> {
|
|
174
|
-
console.log(`Action: ${recaptchaResult.action} Score: ${recaptchaResult.score}`);
|
|
175
|
-
// TODO: Your implementation.
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
If you want use google recaptcha guard in combination with another guards then you can use `@UseGuards` decorator.
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
|
|
185
|
-
@Controller('feedback')
|
|
186
|
-
export class FeedbackController {
|
|
187
|
-
@SetRecaptchaOptions({action: 'Send', score: 0.8})
|
|
188
|
-
@UseGuards(Guard1, GoogleRecaptchaGuard, Guard2)
|
|
189
|
-
@Post('send')
|
|
190
|
-
async send(): Promise<any> {
|
|
191
|
-
// TODO: Your implementation.
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### GraphQL guard
|
|
198
|
-
|
|
199
|
-
Use `@Recaptcha` decorator to protect your resolver.
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
@Recaptcha()
|
|
203
|
-
@Resolver(of => Recipe)
|
|
204
|
-
export class RecipesResolver {
|
|
205
|
-
@Query(returns => Recipe)
|
|
206
|
-
async recipe(@Args('id') id: string): Promise<Recipe> {
|
|
207
|
-
// TODO: Your implementation.
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
You can override default property that contain recaptcha for specific query, mutation or subscription.
|
|
213
|
-
|
|
214
|
-
```typescript
|
|
215
|
-
@Recaptcha()
|
|
216
|
-
@Resolver(of => Recipe)
|
|
217
|
-
export class RecipesResolver {
|
|
218
|
-
@Query(returns => Recipe)
|
|
219
|
-
async recipe(@Args('id') id: string): Promise<Recipe> {
|
|
220
|
-
// TODO: Your implementation.
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Overridden default header. This query using X-Recaptcha header
|
|
224
|
-
@Recaptcha({response: (req: IncomingMessage) => (req.headers['x-recaptcha'] || '').toString()})
|
|
225
|
-
@Query(returns => [Recipe])
|
|
226
|
-
recipes(@Args() recipesArgs: RecipesArgs): Promise<Recipe[]> {
|
|
227
|
-
// TODO: Your implementation.
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Error handling
|
|
233
|
-
|
|
234
|
-
Google recaptcha guard will throw GoogleRecaptchaException on error.
|
|
235
|
-
|
|
236
|
-
**GoogleRecaptchaException**
|
|
237
|
-
|
|
238
|
-
`GoogleRecaptchaException` has data with google recaptcha error codes.
|
|
239
|
-
|
|
240
|
-
`GoogleRecaptchaException` ← `HttpException` ← `Error`.
|
|
241
|
-
|
|
242
|
-
**GoogleRecaptchaNetworkException**
|
|
243
|
-
|
|
244
|
-
`GoogleRecaptchaNetworkException` has error code `ErrorCode.NetworkError`.
|
|
245
|
-
|
|
246
|
-
`GoogleRecaptchaNetworkException` ← `GoogleRecaptchaException`
|
|
247
|
-
|
|
248
|
-
You can handle it via [ExceptionFilter](https://docs.nestjs.com/exception-filters).
|
|
249
|
-
|
|
250
|
-
Example exception filter implementation.
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
|
|
254
|
-
@Catch(GoogleRecaptchaException)
|
|
255
|
-
export class GoogleRecaptchaFilter implements ExceptionFilter {
|
|
256
|
-
catch(exception: GoogleRecaptchaException, host: ArgumentsHost): any {
|
|
257
|
-
// TODO: Your exception filter implementation
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
And add your filter to application
|
|
264
|
-
|
|
265
|
-
```typescript
|
|
266
|
-
|
|
267
|
-
async function bootstrap() {
|
|
268
|
-
const app = await NestFactory.create(AppModule);
|
|
269
|
-
app.useGlobalFilters(new ErrorFilter(), new GoogleRecaptchaFilter());
|
|
270
|
-
await app.listen(3000);
|
|
271
|
-
}
|
|
272
|
-
bootstrap();
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Enjoy!
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationType = void 0;
|
|
4
|
-
var ApplicationType;
|
|
5
|
-
(function (ApplicationType) {
|
|
6
|
-
ApplicationType["Rest"] = "REST";
|
|
7
|
-
ApplicationType["GraphQL"] = "GRAPH_QL";
|
|
8
|
-
})(ApplicationType = exports.ApplicationType || (exports.ApplicationType = {}));
|
|
9
|
-
//# sourceMappingURL=application-type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application-type.js","sourceRoot":"","sources":["../../src/enums/application-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,uCAAoB,CAAA;AACxB,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B"}
|
|
@@ -1 +0,0 @@
|
|
|
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;AAC/B,iCAA8B;AAE9B,MAAa,qBAAqB;IAM9B,MAAM,CAAC,OAAO,CAAC,OAAqC;QAChD,MAAM,SAAS,GAAe;YAC1B,gBAAS;YACT,6CAAoB;YACpB,qDAAwB;YACxB,qDAAwB;YACxB;gBACI,OAAO,EAAE,yCAAiB;gBAC1B,QAAQ,EAAE,OAAO;aACpB;SACJ,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE5C,MAAM,iBAAiB,GAAe;YAClC;gBACI,OAAO,EAAE,8CAAsB;gBAC/B,UAAU,EAAE,CAAC,aAAkC,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC;gBAC7F,MAAM,EAAE;oBACJ,gDAAwB;iBAC3B;aACJ;YACD;gBACI,OAAO,EAAE,gDAAwB;gBACjC,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,+CACzD,IAAI,CAAC,kBAAkB,GACvB,OAAO,CAAC,WAAW,KACtB,OAAO,EAAE,IAAI,IACf,CAAC;aACN;SACJ,CAAC;QAEF,OAAO;YACH,MAAM,EAAE,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NestJS.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"nest",
|
|
7
|
-
"nestjs",
|
|
8
|
-
"module",
|
|
9
|
-
"guard",
|
|
10
|
-
"google",
|
|
11
|
-
"recaptcha",
|
|
12
|
-
"captcha",
|
|
13
|
-
"google-recaptcha",
|
|
14
|
-
"nestjs captcha",
|
|
15
|
-
"nestjs recaptcha",
|
|
16
|
-
"graphql"
|
|
17
|
-
],
|
|
18
|
-
"private": false,
|
|
19
|
-
"main": "index.js",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "rimraf dist && tsc && cp package.json dist && cp README.md dist && cp LICENSE dist && cp CONTRIBUTING.md dist",
|
|
22
|
-
"test": "jest --silent=false",
|
|
23
|
-
"test:cov": "jest --coverage"
|
|
24
|
-
},
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "https://github.com/chvarkov/google-recaptcha.git"
|
|
28
|
-
},
|
|
29
|
-
"author": "Alexey Chvarkov",
|
|
30
|
-
"license": "MIT",
|
|
31
|
-
"bugs": {
|
|
32
|
-
"url": "https://github.com/chvarkov/google-recaptcha/issues"
|
|
33
|
-
},
|
|
34
|
-
"homepage": "https://github.com/chvarkov/google-recaptcha",
|
|
35
|
-
"peerDependencies": {
|
|
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"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
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",
|
|
51
|
-
"reflect-metadata": "^0.1.13",
|
|
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"
|
|
57
|
-
},
|
|
58
|
-
"jest": {
|
|
59
|
-
"moduleFileExtensions": [
|
|
60
|
-
"js",
|
|
61
|
-
"json",
|
|
62
|
-
"ts"
|
|
63
|
-
],
|
|
64
|
-
"rootDir": ".",
|
|
65
|
-
"roots": [
|
|
66
|
-
"<rootDir>/test"
|
|
67
|
-
],
|
|
68
|
-
"testRegex": ".spec.ts$",
|
|
69
|
-
"transform": {
|
|
70
|
-
"^.+\\.(t|j)s$": "ts-jest"
|
|
71
|
-
},
|
|
72
|
-
"coverageDirectory": "./coverage",
|
|
73
|
-
"testEnvironment": "node",
|
|
74
|
-
"collectCoverageFrom": [
|
|
75
|
-
"src/**/*.ts"
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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,GAAG,iDAAsB,CAAC,MAAM,CAAC;QAC/C,YAAO,GAAG,EAAC,cAAc,EAAE,mCAAmC,EAAC,CAAC;IAIjF,CAAC;IAED;;;OAGG;IACH,KAAK,CA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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"}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": false,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"declarationMap": false,
|
|
9
|
-
"target": "es2017",
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"baseUrl": "./src",
|
|
13
|
-
"rootDir": "./src"
|
|
14
|
-
},
|
|
15
|
-
"exclude": [
|
|
16
|
-
"node_modules",
|
|
17
|
-
"dist",
|
|
18
|
-
"test"
|
|
19
|
-
]
|
|
20
|
-
}
|