@nestlab/google-recaptcha 2.1.2 → 3.0.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/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/README.md +1 -3
- package/dist/CONTRIBUTING.md +58 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +277 -0
- package/{decorators → dist/decorators}/recaptcha-result.d.ts +0 -0
- package/{decorators → dist/decorators}/recaptcha-result.js +2 -2
- package/dist/decorators/recaptcha-result.js.map +1 -0
- package/{decorators → dist/decorators}/recaptcha.d.ts +0 -0
- package/{decorators → dist/decorators}/recaptcha.js +1 -1
- package/{decorators → dist/decorators}/recaptcha.js.map +1 -1
- package/{decorators → dist/decorators}/set-recaptcha-options.d.ts +0 -0
- package/{decorators → dist/decorators}/set-recaptcha-options.js +1 -1
- package/{decorators → dist/decorators}/set-recaptcha-options.js.map +1 -1
- package/{enums → dist/enums}/application-type.d.ts +0 -0
- package/{enums → dist/enums}/application-type.js +0 -0
- package/{enums → dist/enums}/application-type.js.map +0 -0
- package/{enums → dist/enums}/error-code.d.ts +0 -0
- package/{enums → dist/enums}/error-code.js +0 -0
- package/{enums → dist/enums}/error-code.js.map +0 -0
- package/{enums → dist/enums}/google-recaptcha-network.d.ts +0 -0
- package/{enums → dist/enums}/google-recaptcha-network.js +0 -0
- package/{enums → dist/enums}/google-recaptcha-network.js.map +0 -0
- package/{exceptions → dist/exceptions}/google-recaptcha-network.exception.d.ts +0 -0
- package/{exceptions → dist/exceptions}/google-recaptcha-network.exception.js +0 -0
- package/{exceptions → dist/exceptions}/google-recaptcha-network.exception.js.map +0 -0
- package/{exceptions → dist/exceptions}/google-recaptcha.exception.d.ts +0 -0
- package/{exceptions → dist/exceptions}/google-recaptcha.exception.js +0 -0
- package/{exceptions → dist/exceptions}/google-recaptcha.exception.js.map +0 -0
- package/{google-recaptcha.module.d.ts → dist/google-recaptcha.module.d.ts} +1 -0
- package/{google-recaptcha.module.js → dist/google-recaptcha.module.js} +11 -6
- package/dist/google-recaptcha.module.js.map +1 -0
- package/{guards → dist/guards}/google-recaptcha.guard.d.ts +0 -0
- package/{guards → dist/guards}/google-recaptcha.guard.js +5 -6
- package/dist/guards/google-recaptcha.guard.js.map +1 -0
- package/{helpers → dist/helpers}/load-module.d.ts +0 -0
- package/{helpers → dist/helpers}/load-module.js +0 -0
- package/{helpers → dist/helpers}/load-module.js.map +0 -0
- package/{index.d.ts → dist/index.d.ts} +0 -0
- package/{index.js → dist/index.js} +1 -0
- package/dist/index.js.map +1 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-guard-options.d.ts +0 -5
- package/{interfaces → dist/interfaces}/google-recaptcha-guard-options.js +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-guard-options.js.map +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-module-options.d.ts +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-module-options.js +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-module-options.js.map +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-validation-result.d.ts +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-validation-result.js +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-validation-result.js.map +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-validator-options.d.ts +0 -9
- package/{interfaces → dist/interfaces}/google-recaptcha-validator-options.js +0 -0
- package/{interfaces → dist/interfaces}/google-recaptcha-validator-options.js.map +0 -0
- package/{interfaces → dist/interfaces}/verify-response-decorator-options.d.ts +0 -0
- package/{interfaces → dist/interfaces}/verify-response-decorator-options.js +0 -0
- package/{interfaces → dist/interfaces}/verify-response-decorator-options.js.map +0 -0
- package/{interfaces → dist/interfaces}/verify-response.d.ts +0 -0
- package/{interfaces → dist/interfaces}/verify-response.js +0 -0
- package/{interfaces → dist/interfaces}/verify-response.js.map +0 -0
- package/{models → dist/models}/recaptcha-verification-result.d.ts +0 -0
- package/{models → dist/models}/recaptcha-verification-result.js +0 -0
- package/{models → dist/models}/recaptcha-verification-result.js.map +0 -0
- package/dist/package.json +78 -0
- package/{provider.declarations.d.ts → dist/provider.declarations.d.ts} +0 -0
- package/{provider.declarations.js → dist/provider.declarations.js} +0 -0
- package/{provider.declarations.js.map → dist/provider.declarations.js.map} +0 -0
- package/{services → dist/services}/google-recaptcha.validator.d.ts +1 -1
- package/{services → dist/services}/google-recaptcha.validator.js +5 -7
- package/dist/services/google-recaptcha.validator.js.map +1 -0
- package/dist/services/recaptcha-request.resolver.d.ts +4 -0
- package/{services → dist/services}/recaptcha-request.resolver.js +3 -19
- package/dist/services/recaptcha-request.resolver.js.map +1 -0
- package/{types.d.ts → dist/types.d.ts} +0 -0
- package/{types.js → dist/types.js} +0 -0
- package/{types.js.map → dist/types.js.map} +0 -0
- package/package.json +19 -17
- package/tsconfig.json +20 -0
- package/decorators/recaptcha-result.js.map +0 -1
- package/google-recaptcha.module.js.map +0 -1
- package/guards/google-recaptcha.guard.js.map +0 -1
- package/index.js.map +0 -1
- package/services/google-recaptcha.validator.js.map +0 -1
- package/services/recaptcha-request.resolver.d.ts +0 -9
- package/services/recaptcha-request.resolver.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
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.
|
|
@@ -0,0 +1,20 @@
|
|
|
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/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... |
|
|
@@ -0,0 +1,58 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
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!
|
|
File without changes
|
|
@@ -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;
|
|
@@ -0,0 +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,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"}
|
|
File without changes
|
|
@@ -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"}
|
|
File without changes
|
|
@@ -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"}
|
|
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
|
|
@@ -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
|
|
@@ -0,0 +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;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,kBAAk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,CAAC,wBAAwB,CAAC,cAAc,CAAC,EAAE;oBAChD,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAA;iBAC5F;gBACD,OAAO,cAAc,CAAC,4BAA4B,EAAE,CAAC;YACzD,CAAC;YACD,MAAM,EAAE,CAAC,OAAO,CAAC,WAAY,IAAI,OAAO,CAAC,QAAS,CAAC;SACtD,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,wBAAwB,CAAC,MAAW;QAC/C,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,4BAA4B,KAAK,UAAU,CAAC;IACjF,CAAC;;AA9JL,sDA+JC;AA9JkB,wCAAkB,GAA6B;IAC1D,OAAO,EAAE,KAAM;IACf,UAAU,EAAE,IAAI,aAAK,CAAC,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC;CAC3C,CAAC"}
|
|
File without changes
|
|
@@ -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])
|
|
@@ -0,0 +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,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,MA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|
@@ -1,5 +1,6 @@
|
|
|
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; } });
|
|
5
6
|
var set_recaptcha_options_1 = require("./decorators/set-recaptcha-options");
|
|
@@ -0,0 +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,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
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
}
|
|
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
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nestlab/google-recaptcha",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Google recaptcha module for 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
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAA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,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"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestlab/google-recaptcha",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
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": [
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,CAAC,IAAI,EA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,"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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-recaptcha.validator.js","sourceRoot":"","sources":["../../src/services/google-recaptcha.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AAEjE,oEAAqF;AACrF,kCAAkC;AAGlC,gFAA2E;AAI3E,oDAAgD;AAChD,yGAAmG;AAGnG,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,CAAC,QAAQ,CAAC,OAA8B;QACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAmB,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE7E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,OAAO,MAAM,CAAC;SACjB;QAED,IAAI,CAAC,IAAI,CAAC,aAAa,CA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KI,WAAA,eAAM,CAAC,8CAAsB,CAAC,CAAA;IAC9B,WAAA,eAAM,CAAC,yCAAiB,CAAC,CAAA;qCAD6B,oBAAW;GAJrE,wBAAwB,CAiGpC;AAjGY,4DAAwB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { ApplicationType } from '../enums/application-type';
|
|
3
|
-
export declare class RecaptchaRequestResolver {
|
|
4
|
-
resolve<T = any>(context: ExecutionContext): T;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
resolveByApplicationType<T = any>(context: ExecutionContext, type: ApplicationType): T;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recaptcha-request.resolver.js","sourceRoot":"","sources":["../../src/services/recaptcha-request.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8D;AAC9D,gEAA4D;AAC5D,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,wBAAU,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;gBAC1D,yBAAO,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,0CAAE,UAAU,0CAAE,YAAY,0CAAE,GAAG,CAAC;YAC7G;gBACI,MAAM,IAAI,KAAK,CAAC,6BAA6B,WAAW,IAAI,CAAC,CAAC;SACrE;IACL,CAAC;IAED;;OAEG;IACH,wBAAwB,CAAU,OAAyB,EAAE,IAAqB;;QAC9E,QAAQ,IA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