@nestlab/google-recaptcha 3.2.0 → 3.3.0
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/LICENSE +1 -1
- package/README.md +1 -1
- package/google-recaptcha.module.d.ts +0 -1
- package/google-recaptcha.module.js +3 -17
- package/google-recaptcha.module.js.map +1 -1
- package/package.json +6 -6
- package/provider.declarations.d.ts +0 -1
- package/provider.declarations.js +1 -2
- package/provider.declarations.js.map +1 -1
- package/services/validators/google-recaptcha-enterprise.validator.d.ts +3 -3
- package/services/validators/google-recaptcha-enterprise.validator.js +5 -8
- package/services/validators/google-recaptcha-enterprise.validator.js.map +1 -1
- package/services/validators/google-recaptcha.validator.d.ts +3 -3
- package/services/validators/google-recaptcha.validator.js +5 -8
- package/services/validators/google-recaptcha.validator.js.map +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -235,7 +235,7 @@ Get verification result
|
|
|
235
235
|
export class FeedbackController {
|
|
236
236
|
@Recaptcha()
|
|
237
237
|
@Post('send')
|
|
238
|
-
async send(@RecaptchaResult() recaptchaResult:
|
|
238
|
+
async send(@RecaptchaResult() recaptchaResult: RecaptchaVerificationResult): Promise<any> {
|
|
239
239
|
console.log(`Action: ${recaptchaResult.action} Score: ${recaptchaResult.score}`);
|
|
240
240
|
// TODO: Your implementation.
|
|
241
241
|
}
|
|
@@ -8,12 +8,11 @@ const google_recaptcha_enterprise_validator_1 = require("./services/validators/g
|
|
|
8
8
|
const provider_declarations_1 = require("./provider.declarations");
|
|
9
9
|
const recaptcha_request_resolver_1 = require("./services/recaptcha-request.resolver");
|
|
10
10
|
const core_1 = require("@nestjs/core");
|
|
11
|
-
const
|
|
11
|
+
const axios_1 = require("axios");
|
|
12
12
|
const https_1 = require("https");
|
|
13
13
|
const recaptcha_validator_resolver_1 = require("./services/recaptcha-validator.resolver");
|
|
14
14
|
const enterprise_reason_transformer_1 = require("./services/enterprise-reason.transformer");
|
|
15
15
|
const xor_1 = require("./helpers/xor");
|
|
16
|
-
const axios_1 = require("@nestjs/axios");
|
|
17
16
|
class GoogleRecaptchaModule {
|
|
18
17
|
static forRoot(options) {
|
|
19
18
|
const providers = [
|
|
@@ -35,14 +34,9 @@ class GoogleRecaptchaModule {
|
|
|
35
34
|
];
|
|
36
35
|
this.validateOptions(options);
|
|
37
36
|
const internalProviders = [
|
|
38
|
-
{
|
|
39
|
-
provide: provider_declarations_1.RECAPTCHA_HTTP_SERVICE,
|
|
40
|
-
useFactory: (axiosInstance) => new axios_1.HttpService(axiosInstance),
|
|
41
|
-
inject: [provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE],
|
|
42
|
-
},
|
|
43
37
|
{
|
|
44
38
|
provide: provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE,
|
|
45
|
-
useFactory: () =>
|
|
39
|
+
useFactory: () => axios_1.default.create(this.transformAxiosConfig(Object.assign(Object.assign(Object.assign({}, this.axiosDefaultConfig), options.axiosConfig), { headers: null }))),
|
|
46
40
|
},
|
|
47
41
|
];
|
|
48
42
|
return {
|
|
@@ -69,17 +63,12 @@ class GoogleRecaptchaModule {
|
|
|
69
63
|
...this.createAsyncProviders(options),
|
|
70
64
|
];
|
|
71
65
|
const internalProviders = [
|
|
72
|
-
{
|
|
73
|
-
provide: provider_declarations_1.RECAPTCHA_HTTP_SERVICE,
|
|
74
|
-
useFactory: (axiosInstance) => new axios_1.HttpService(axiosInstance),
|
|
75
|
-
inject: [provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE],
|
|
76
|
-
},
|
|
77
66
|
{
|
|
78
67
|
provide: provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE,
|
|
79
68
|
useFactory: (options) => {
|
|
80
69
|
this.validateOptions(options);
|
|
81
70
|
const transformedAxiosConfig = this.transformAxiosConfig(Object.assign(Object.assign(Object.assign({}, this.axiosDefaultConfig), options.axiosConfig), { headers: null }));
|
|
82
|
-
return
|
|
71
|
+
return axios_1.default.create(transformedAxiosConfig);
|
|
83
72
|
},
|
|
84
73
|
inject: [provider_declarations_1.RECAPTCHA_OPTIONS],
|
|
85
74
|
},
|
|
@@ -144,9 +133,6 @@ class GoogleRecaptchaModule {
|
|
|
144
133
|
static isGoogleRecaptchaFactory(object) {
|
|
145
134
|
return !!object && typeof object.createGoogleRecaptchaOptions === 'function';
|
|
146
135
|
}
|
|
147
|
-
static createAxiosInstance(axiosConfig) {
|
|
148
|
-
return axios['create'](axiosConfig); // TODO: Updated when axios ts declaration will be fixed
|
|
149
|
-
}
|
|
150
136
|
}
|
|
151
137
|
exports.GoogleRecaptchaModule = GoogleRecaptchaModule;
|
|
152
138
|
GoogleRecaptchaModule.axiosDefaultConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha.module.js","sourceRoot":"","sources":["../src/google-recaptcha.module.ts"],"names":[],"mappings":";;;AAAA,2CAAiE;AACjE,4EAAuE;AACvE,iGAA4F;AAC5F,uHAAiH;AAMjH,
|
|
1
|
+
{"version":3,"file":"google-recaptcha.module.js","sourceRoot":"","sources":["../src/google-recaptcha.module.ts"],"names":[],"mappings":";;;AAAA,2CAAiE;AACjE,4EAAuE;AACvE,iGAA4F;AAC5F,uHAAiH;AAMjH,mEAAwG;AACxG,sFAAiF;AACjF,uCAAyC;AACzC,iCAAiE;AACjE,iCAA8B;AAC9B,0FAAqF;AACrF,4FAAuF;AACvF,uCAAoC;AAEpC,MAAa,qBAAqB;IAMjC,MAAM,CAAC,OAAO,CAAC,OAAqC;QACnD,MAAM,SAAS,GAAe;YAC7B,gBAAS;YACT,6CAAoB;YACpB,qDAAwB;YACxB,0EAAkC;YAClC,qDAAwB;YACxB,yDAA0B;YAC1B,2DAA2B;YAC3B;gBACC,OAAO,EAAE,yCAAiB;gBAC1B,QAAQ,EAAE,OAAO;aACjB;YACD;gBACC,OAAO,EAAE,wCAAgB;gBACzB,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,IAA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E,OAAO,CAAC,UAAU;gBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;aACtB,CAAC;SACF;QAED,OAAO;YACN,OAAO,EAAE,yCAAiB;YAC1B,UAAU,EAAE,KAAK,EAAE,cAA6C,EAAyC,EAAE;gBAC1G,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;iBACxF;gBACD,OAAO,cAAc,CAAC,4BAA4B,EAAE,CAAC;YACtD,CAAC;YACD,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;SACjD,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,OAAqC;QACnE,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QAC5E,IAAI,CAAC,IAAA,SAAG,EAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE;YACpD,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;SAC3F;IACF,CAAC;IAEO,MAAM,CAAC,wBAAwB,CAAC,MAAsC;QAC7E,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,4BAA4B,KAAK,UAAU,CAAC;IAC9E,CAAC;;AAvJF,sDAwJC;AAvJe,wCAAkB,GAAuB;IACvD,OAAO,EAAE,KAAM;IACf,UAAU,EAAE,IAAI,aAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;CAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestlab/google-recaptcha",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Google recaptcha module for NestJS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"url": "https://github.com/chvarkov/google-recaptcha/issues"
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/chvarkov/google-recaptcha",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"axios": "^1.3.4"
|
|
35
|
+
},
|
|
33
36
|
"peerDependencies": {
|
|
34
|
-
"@nestjs/axios": ">=1.0.0 <2.0.0",
|
|
35
37
|
"@nestjs/common": ">=8.0.0 <10.0.0",
|
|
36
|
-
"@nestjs/core": ">=8.0.0 <10.0.0"
|
|
37
|
-
"rxjs": ">=7.0.0 <8.0.0",
|
|
38
|
-
"axios": ">=1.0.0 <2.0.0"
|
|
38
|
+
"@nestjs/core": ">=8.0.0 <10.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@nestjs/graphql": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@nestjs/apollo": "^10.0.22",
|
|
47
|
-
"@nestjs/axios": "^
|
|
47
|
+
"@nestjs/axios": "^2.0.0",
|
|
48
48
|
"@nestjs/common": "^9.0.11",
|
|
49
49
|
"@nestjs/core": "^9.0.11",
|
|
50
50
|
"@nestjs/graphql": "^10.0.22",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
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
|
-
export declare const RECAPTCHA_HTTP_SERVICE = "RECAPTCHA_HTTP_SERVICE";
|
|
5
4
|
export declare const RECAPTCHA_LOGGER = "RECAPTCHA_LOGGER";
|
package/provider.declarations.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RECAPTCHA_LOGGER = exports.
|
|
3
|
+
exports.RECAPTCHA_LOGGER = 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
|
-
exports.RECAPTCHA_HTTP_SERVICE = 'RECAPTCHA_HTTP_SERVICE';
|
|
8
7
|
exports.RECAPTCHA_LOGGER = 'RECAPTCHA_LOGGER';
|
|
9
8
|
//# 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,
|
|
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,gBAAgB,GAAG,kBAAkB,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
|
-
import { HttpService } from '@nestjs/axios';
|
|
3
2
|
import { GoogleRecaptchaModuleOptions } from '../../interfaces/google-recaptcha-module-options';
|
|
4
3
|
import { VerifyResponseOptions } from '../../interfaces/verify-response-decorator-options';
|
|
5
4
|
import { AbstractGoogleRecaptchaValidator } from './abstract-google-recaptcha-validator';
|
|
6
5
|
import { RecaptchaVerificationResult } from '../../models/recaptcha-verification-result';
|
|
7
6
|
import { VerifyResponseEnterprise } from '../../interfaces/verify-response-enterprise';
|
|
8
7
|
import { EnterpriseReasonTransformer } from '../enterprise-reason.transformer';
|
|
8
|
+
import { AxiosInstance } from 'axios';
|
|
9
9
|
export declare class GoogleRecaptchaEnterpriseValidator extends AbstractGoogleRecaptchaValidator<VerifyResponseEnterprise> {
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly axios;
|
|
11
11
|
private readonly logger;
|
|
12
12
|
private readonly enterpriseReasonTransformer;
|
|
13
13
|
private readonly headers;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(axios: AxiosInstance, logger: Logger, options: GoogleRecaptchaModuleOptions, enterpriseReasonTransformer: EnterpriseReasonTransformer);
|
|
15
15
|
validate(options: VerifyResponseOptions): Promise<RecaptchaVerificationResult<VerifyResponseEnterprise>>;
|
|
16
16
|
private verifyResponse;
|
|
17
17
|
}
|
|
@@ -15,19 +15,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.GoogleRecaptchaEnterpriseValidator = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const provider_declarations_1 = require("../../provider.declarations");
|
|
18
|
-
const axios_1 = require("@nestjs/axios");
|
|
19
18
|
const abstract_google_recaptcha_validator_1 = require("./abstract-google-recaptcha-validator");
|
|
20
19
|
const recaptcha_verification_result_1 = require("../../models/recaptcha-verification-result");
|
|
21
20
|
const error_code_1 = require("../../enums/error-code");
|
|
22
21
|
const google_recaptcha_network_exception_1 = require("../../exceptions/google-recaptcha-network.exception");
|
|
23
22
|
const google_recaptcha_context_1 = require("../../enums/google-recaptcha-context");
|
|
24
23
|
const enterprise_reason_transformer_1 = require("../enterprise-reason.transformer");
|
|
25
|
-
const rxjs_1 = require("rxjs");
|
|
26
24
|
const get_error_info_1 = require("../../helpers/get-error-info");
|
|
27
25
|
let GoogleRecaptchaEnterpriseValidator = class GoogleRecaptchaEnterpriseValidator extends abstract_google_recaptcha_validator_1.AbstractGoogleRecaptchaValidator {
|
|
28
|
-
constructor(
|
|
26
|
+
constructor(axios, logger, options, enterpriseReasonTransformer) {
|
|
29
27
|
super(options);
|
|
30
|
-
this.
|
|
28
|
+
this.axios = axios;
|
|
31
29
|
this.logger = logger;
|
|
32
30
|
this.enterpriseReasonTransformer = enterpriseReasonTransformer;
|
|
33
31
|
this.headers = { 'Content-Type': 'application/json' };
|
|
@@ -86,7 +84,7 @@ let GoogleRecaptchaEnterpriseValidator = class GoogleRecaptchaEnterpriseValidato
|
|
|
86
84
|
if (this.options.debug) {
|
|
87
85
|
this.logger.debug({ body }, `${google_recaptcha_context_1.GoogleRecaptchaContext.GoogleRecaptchaEnterprise}.request`);
|
|
88
86
|
}
|
|
89
|
-
return
|
|
87
|
+
return this.axios.post(url, body, config)
|
|
90
88
|
.then((res) => res.data)
|
|
91
89
|
.then((data) => {
|
|
92
90
|
if (this.options.debug) {
|
|
@@ -112,11 +110,10 @@ let GoogleRecaptchaEnterpriseValidator = class GoogleRecaptchaEnterpriseValidato
|
|
|
112
110
|
};
|
|
113
111
|
GoogleRecaptchaEnterpriseValidator = __decorate([
|
|
114
112
|
(0, common_1.Injectable)(),
|
|
115
|
-
__param(0, (0, common_1.Inject)(provider_declarations_1.
|
|
113
|
+
__param(0, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE)),
|
|
116
114
|
__param(1, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_LOGGER)),
|
|
117
115
|
__param(2, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
118
|
-
__metadata("design:paramtypes", [
|
|
119
|
-
common_1.Logger, Object, enterprise_reason_transformer_1.EnterpriseReasonTransformer])
|
|
116
|
+
__metadata("design:paramtypes", [Function, common_1.Logger, Object, enterprise_reason_transformer_1.EnterpriseReasonTransformer])
|
|
120
117
|
], GoogleRecaptchaEnterpriseValidator);
|
|
121
118
|
exports.GoogleRecaptchaEnterpriseValidator = GoogleRecaptchaEnterpriseValidator;
|
|
122
119
|
//# sourceMappingURL=google-recaptcha-enterprise.validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha-enterprise.validator.js","sourceRoot":"","sources":["../../../src/services/validators/google-recaptcha-enterprise.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"google-recaptcha-enterprise.validator.js","sourceRoot":"","sources":["../../../src/services/validators/google-recaptcha-enterprise.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2E;AAC3E,uEAA4G;AAG5G,+FAAyF;AACzF,8FAAyF;AACzF,uDAAmD;AAEnD,4GAAsG;AACtG,mFAA8E;AAE9E,oFAA+E;AAC/E,iEAA4D;AAMrD,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,sEAA0D;IAGjH,YACoD,KAAoB,EAC5B,MAAc,EAC9B,OAAqC,EAC/C,2BAAwD;QAEzE,KAAK,CAAC,OAAO,CAAC,CAAC;QALoC,UAAK,GAAL,KAAK,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAQ;QAExC,gCAA2B,GAA3B,2BAA2B,CAA6B;QANzD,YAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;IASlE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAA8B;;QAC5C,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAE3F,MAAM,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B,CAAC,yBAAyB,WAAW,CAAC,CAAC;aACxF;YAED,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAqB,EAAkB,EAAE;YAChD,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,6BAAY,EAAC,GAAG,CAAC,EAAE,GAAG,iDAAsB,CAAC,yBAAyB,QAAQ,CAAC,CAAC;aAClG;YAED,MAAM,gBAAgB,GAAG,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,IAAI,CAAC;YAEtD,IAAI,gBAAgB,EAAE;gBACrB,MAAM,IAAI,oEAA+B,CAAC,gBAAgB,CAAC,CAAC;aAC5D;YAED,MAAM,OAAO,GAAkB;gBAC9B,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM;gBAC3B,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI;aACvB,CAAC;YAEF,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACD,CAAA;AAzGY,kCAAkC;IAD9C,IAAA,mBAAU,GAAE;IAKV,WAAA,IAAA,eAAM,EAAC,gDAAwB,CAAC,CAAA;IAChC,WAAA,IAAA,eAAM,EAAC,wCAAgB,CAAC,CAAA;IACxB,WAAA,IAAA,eAAM,EAAC,yCAAiB,CAAC,CAAA;+CADyB,eAAM,UAEX,2DAA2B;GAP9D,kCAAkC,CAyG9C;AAzGY,gFAAkC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
2
|
import { VerifyResponseOptions } from '../../interfaces/verify-response-decorator-options';
|
|
3
3
|
import { VerifyResponseV3 } from '../../interfaces/verify-response';
|
|
4
|
-
import { HttpService } from '@nestjs/axios';
|
|
5
4
|
import { GoogleRecaptchaModuleOptions } from '../../interfaces/google-recaptcha-module-options';
|
|
6
5
|
import { AbstractGoogleRecaptchaValidator } from './abstract-google-recaptcha-validator';
|
|
7
6
|
import { RecaptchaVerificationResult } from '../../models/recaptcha-verification-result';
|
|
7
|
+
import { AxiosInstance } from 'axios';
|
|
8
8
|
export declare class GoogleRecaptchaValidator extends AbstractGoogleRecaptchaValidator<VerifyResponseV3> {
|
|
9
|
-
private readonly
|
|
9
|
+
private readonly axios;
|
|
10
10
|
private readonly logger;
|
|
11
11
|
private readonly defaultNetwork;
|
|
12
12
|
private readonly headers;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(axios: AxiosInstance, logger: Logger, options: GoogleRecaptchaModuleOptions);
|
|
14
14
|
/**
|
|
15
15
|
* @throws GoogleRecaptchaNetworkException
|
|
16
16
|
* @param {VerifyResponseOptions} options
|
|
@@ -19,16 +19,14 @@ 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");
|
|
23
22
|
const abstract_google_recaptcha_validator_1 = require("./abstract-google-recaptcha-validator");
|
|
24
23
|
const recaptcha_verification_result_1 = require("../../models/recaptcha-verification-result");
|
|
25
24
|
const google_recaptcha_context_1 = require("../../enums/google-recaptcha-context");
|
|
26
|
-
const rxjs_1 = require("rxjs");
|
|
27
25
|
const get_error_info_1 = require("../../helpers/get-error-info");
|
|
28
26
|
let GoogleRecaptchaValidator = class GoogleRecaptchaValidator extends abstract_google_recaptcha_validator_1.AbstractGoogleRecaptchaValidator {
|
|
29
|
-
constructor(
|
|
27
|
+
constructor(axios, logger, options) {
|
|
30
28
|
super(options);
|
|
31
|
-
this.
|
|
29
|
+
this.axios = axios;
|
|
32
30
|
this.logger = logger;
|
|
33
31
|
this.defaultNetwork = google_recaptcha_network_1.GoogleRecaptchaNetwork.Google;
|
|
34
32
|
this.headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
@@ -77,7 +75,7 @@ let GoogleRecaptchaValidator = class GoogleRecaptchaValidator extends abstract_g
|
|
|
77
75
|
if (this.options.debug) {
|
|
78
76
|
this.logger.debug({ body }, `${google_recaptcha_context_1.GoogleRecaptchaContext.GoogleRecaptcha}.request`);
|
|
79
77
|
}
|
|
80
|
-
return
|
|
78
|
+
return this.axios.post(url, body, config)
|
|
81
79
|
.then((res) => res.data)
|
|
82
80
|
.then((data) => {
|
|
83
81
|
if (this.options.debug) {
|
|
@@ -110,11 +108,10 @@ let GoogleRecaptchaValidator = class GoogleRecaptchaValidator extends abstract_g
|
|
|
110
108
|
};
|
|
111
109
|
GoogleRecaptchaValidator = __decorate([
|
|
112
110
|
(0, common_1.Injectable)(),
|
|
113
|
-
__param(0, (0, common_1.Inject)(provider_declarations_1.
|
|
111
|
+
__param(0, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_AXIOS_INSTANCE)),
|
|
114
112
|
__param(1, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_LOGGER)),
|
|
115
113
|
__param(2, (0, common_1.Inject)(provider_declarations_1.RECAPTCHA_OPTIONS)),
|
|
116
|
-
__metadata("design:paramtypes", [
|
|
117
|
-
common_1.Logger, Object])
|
|
114
|
+
__metadata("design:paramtypes", [Function, common_1.Logger, Object])
|
|
118
115
|
], GoogleRecaptchaValidator);
|
|
119
116
|
exports.GoogleRecaptchaValidator = GoogleRecaptchaValidator;
|
|
120
117
|
//# sourceMappingURL=google-recaptcha.validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha.validator.js","sourceRoot":"","sources":["../../../src/services/validators/google-recaptcha.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"google-recaptcha.validator.js","sourceRoot":"","sources":["../../../src/services/validators/google-recaptcha.validator.ts"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