@mondart/nestjs-common-module 2.8.0 → 2.9.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/dist/lib/google-recaptcha/decorators/recaptcha-result.d.ts +1 -0
- package/dist/lib/google-recaptcha/decorators/recaptcha-result.js +16 -0
- package/dist/lib/google-recaptcha/decorators/recaptcha.d.ts +2 -0
- package/dist/lib/google-recaptcha/decorators/recaptcha.js +9 -0
- package/dist/lib/google-recaptcha/decorators/set-recaptcha-options.d.ts +2 -0
- package/dist/lib/google-recaptcha/decorators/set-recaptcha-options.js +8 -0
- package/dist/lib/google-recaptcha/enums/classification-reason.d.ts +8 -0
- package/dist/lib/google-recaptcha/enums/classification-reason.js +12 -0
- package/dist/lib/google-recaptcha/enums/error-code.d.ts +16 -0
- package/dist/lib/google-recaptcha/enums/error-code.js +20 -0
- package/dist/lib/google-recaptcha/enums/google-recaptcha-context.d.ts +4 -0
- package/dist/lib/google-recaptcha/enums/google-recaptcha-context.js +8 -0
- package/dist/lib/google-recaptcha/enums/google-recaptcha-enterprise-reason.d.ts +10 -0
- package/dist/lib/google-recaptcha/enums/google-recaptcha-enterprise-reason.js +14 -0
- package/dist/lib/google-recaptcha/enums/google-recaptcha-network.d.ts +4 -0
- package/dist/lib/google-recaptcha/enums/google-recaptcha-network.js +8 -0
- package/dist/lib/google-recaptcha/exceptions/google-recaptcha-network.exception.d.ts +5 -0
- package/dist/lib/google-recaptcha/exceptions/google-recaptcha-network.exception.js +14 -0
- package/dist/lib/google-recaptcha/exceptions/google-recaptcha.exception.d.ts +8 -0
- package/dist/lib/google-recaptcha/exceptions/google-recaptcha.exception.js +54 -0
- package/dist/lib/google-recaptcha/google-recaptcha.module.d.ts +12 -0
- package/dist/lib/google-recaptcha/google-recaptcha.module.js +159 -0
- package/dist/lib/google-recaptcha/guards/google-recaptcha.guard.d.ts +15 -0
- package/dist/lib/google-recaptcha/guards/google-recaptcha.guard.js +89 -0
- package/dist/lib/google-recaptcha/helpers/get-error-info.d.ts +4 -0
- package/dist/lib/google-recaptcha/helpers/get-error-info.js +13 -0
- package/dist/lib/google-recaptcha/helpers/load-module.d.ts +2 -0
- package/dist/lib/google-recaptcha/helpers/load-module.js +15 -0
- package/dist/lib/google-recaptcha/helpers/xor.d.ts +1 -0
- package/dist/lib/google-recaptcha/helpers/xor.js +6 -0
- package/dist/lib/google-recaptcha/index.d.ts +15 -0
- package/dist/lib/google-recaptcha/index.js +31 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-enterprise-options.d.ts +5 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-enterprise-options.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-guard-options.d.ts +7 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-guard-options.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-module-options.d.ts +21 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-module-options.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-validator-options.d.ts +12 -0
- package/dist/lib/google-recaptcha/interfaces/google-recaptcha-validator-options.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/literal-object.d.ts +3 -0
- package/dist/lib/google-recaptcha/interfaces/literal-object.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/verify-response-decorator-options.d.ts +13 -0
- package/dist/lib/google-recaptcha/interfaces/verify-response-decorator-options.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/verify-response-enterprise.d.ts +30 -0
- package/dist/lib/google-recaptcha/interfaces/verify-response-enterprise.js +2 -0
- package/dist/lib/google-recaptcha/interfaces/verify-response.d.ts +11 -0
- package/dist/lib/google-recaptcha/interfaces/verify-response.js +2 -0
- package/dist/lib/google-recaptcha/models/recaptcha-config-ref.d.ts +12 -0
- package/dist/lib/google-recaptcha/models/recaptcha-config-ref.js +30 -0
- package/dist/lib/google-recaptcha/models/recaptcha-verification-result.d.ts +26 -0
- package/dist/lib/google-recaptcha/models/recaptcha-verification-result.js +34 -0
- package/dist/lib/google-recaptcha/provider.declarations.d.ts +4 -0
- package/dist/lib/google-recaptcha/provider.declarations.js +7 -0
- package/dist/lib/google-recaptcha/services/enterprise-reason.transformer.d.ts +5 -0
- package/dist/lib/google-recaptcha/services/enterprise-reason.transformer.js +38 -0
- package/dist/lib/google-recaptcha/services/recaptcha-request.resolver.d.ts +4 -0
- package/dist/lib/google-recaptcha/services/recaptcha-request.resolver.js +32 -0
- package/dist/lib/google-recaptcha/services/recaptcha-validator.resolver.d.ts +11 -0
- package/dist/lib/google-recaptcha/services/recaptcha-validator.resolver.js +40 -0
- package/dist/lib/google-recaptcha/services/validators/abstract-google-recaptcha-validator.d.ts +11 -0
- package/dist/lib/google-recaptcha/services/validators/abstract-google-recaptcha-validator.js +27 -0
- package/dist/lib/google-recaptcha/services/validators/google-recaptcha-enterprise.validator.d.ts +17 -0
- package/dist/lib/google-recaptcha/services/validators/google-recaptcha-enterprise.validator.js +126 -0
- package/dist/lib/google-recaptcha/services/validators/google-recaptcha.validator.d.ts +17 -0
- package/dist/lib/google-recaptcha/services/validators/google-recaptcha.validator.js +128 -0
- package/dist/lib/google-recaptcha/types.d.ts +6 -0
- package/dist/lib/google-recaptcha/types.js +2 -0
- package/dist/lib/health-check/health-check.controller.d.ts +5 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/.github/workflows/npm-publish.yml +0 -34
- package/.github/workflows/npm-unpublish.yml +0 -35
- package/dist/lib/captcha/captcha.decorator.d.ts +0 -4
- package/dist/lib/captcha/captcha.decorator.js +0 -7
- package/dist/lib/captcha/captcha.exception.d.ts +0 -4
- package/dist/lib/captcha/captcha.exception.js +0 -11
- package/dist/lib/captcha/captcha.guard.d.ts +0 -16
- package/dist/lib/captcha/captcha.guard.js +0 -86
- package/dist/lib/captcha/captcha.interface.d.ts +0 -26
- package/dist/lib/captcha/captcha.interface.js +0 -4
- package/dist/lib/captcha/captcha.module.d.ts +0 -8
- package/dist/lib/captcha/captcha.module.js +0 -97
- package/dist/lib/captcha/enums/captcha-decorators.enum.d.ts +0 -3
- package/dist/lib/captcha/enums/captcha-decorators.enum.js +0 -7
- package/dist/lib/captcha/enums/captcha-messages.enum.d.ts +0 -3
- package/dist/lib/captcha/enums/captcha-messages.enum.js +0 -7
- package/dist/lib/captcha/index.d.ts +0 -5
- package/dist/lib/captcha/index.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondart/nestjs-common-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mondart"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build:docs": "npx compodoc -p tsconfig.build.json -d docs -o -s --theme material"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@keycloak/keycloak-admin-client": "
|
|
24
|
+
"@keycloak/keycloak-admin-client": "~26.5.0",
|
|
25
25
|
"@keyv/redis": "4.2.0",
|
|
26
26
|
"@nestjs/axios": "^4.0.0",
|
|
27
27
|
"@nestjs/cache-manager": "^3.0.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@sentry/nestjs": "^10.32.1",
|
|
38
38
|
"@sentry/profiling-node": "^10.32.1",
|
|
39
39
|
"@types/redis": "^4.0.11",
|
|
40
|
-
"axios": "1.
|
|
40
|
+
"axios": "~1.15.0",
|
|
41
41
|
"bottleneck": "^2.19.5",
|
|
42
42
|
"cache-manager": "6.4.0",
|
|
43
43
|
"cache-manager-ioredis-yet": "^2.1.1",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
name: Build and Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build-and-publish:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout repository
|
|
13
|
-
uses: actions/checkout@v3
|
|
14
|
-
|
|
15
|
-
- name: Set up Node.js
|
|
16
|
-
uses: actions/setup-node@v3
|
|
17
|
-
with:
|
|
18
|
-
node-version: '16' # Use the Node.js version your project requires
|
|
19
|
-
|
|
20
|
-
- name: Install dependencies
|
|
21
|
-
run: npm install --force
|
|
22
|
-
|
|
23
|
-
- name: Build project
|
|
24
|
-
run: npm run build # Adjust this if your build command is different
|
|
25
|
-
|
|
26
|
-
- name: Set NPM Token
|
|
27
|
-
run: npm config set _authToken=${{ secrets.NPM_TOKEN }}
|
|
28
|
-
env:
|
|
29
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
30
|
-
|
|
31
|
-
- name: Publish to npm
|
|
32
|
-
env:
|
|
33
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
34
|
-
run: npm publish --access public
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
name: Unpublish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [deleted]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
unpublish-package:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
steps:
|
|
12
|
-
- name: Check out the repository
|
|
13
|
-
uses: actions/checkout@v3
|
|
14
|
-
|
|
15
|
-
- name: Set up Node.js
|
|
16
|
-
uses: actions/setup-node@v3
|
|
17
|
-
with:
|
|
18
|
-
node-version: '16'
|
|
19
|
-
|
|
20
|
-
- name: Set NPM Token
|
|
21
|
-
run: npm config set _authToken=${{ secrets.NPM_TOKEN }}
|
|
22
|
-
env:
|
|
23
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
24
|
-
|
|
25
|
-
- name: Extract package name and version
|
|
26
|
-
id: extract-package-info
|
|
27
|
-
run: |
|
|
28
|
-
# Replace this logic with your specific way of determining the package name and version
|
|
29
|
-
echo "PACKAGE_NAME=@mondart/nestjs-common-module" >> $GITHUB_ENV
|
|
30
|
-
echo "PACKAGE_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
|
31
|
-
|
|
32
|
-
- name: Unpublish the package
|
|
33
|
-
env:
|
|
34
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
-
run: npm unpublish $PACKAGE_NAME@$PACKAGE_VERSION --force
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Captcha = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const captcha_decorators_enum_1 = require("./enums/captcha-decorators.enum");
|
|
6
|
-
const Captcha = (params) => (0, common_1.SetMetadata)(captcha_decorators_enum_1.CaptchaDecorators.CAPTCHA, params);
|
|
7
|
-
exports.Captcha = Captcha;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidCaptcha = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const captcha_messages_enum_1 = require("./enums/captcha-messages.enum");
|
|
6
|
-
class InvalidCaptcha extends common_1.UnauthorizedException {
|
|
7
|
-
constructor(cause) {
|
|
8
|
-
super(captcha_messages_enum_1.CaptchaErrors.INVALID_CAPTCHA, { cause });
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.InvalidCaptcha = InvalidCaptcha;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { CaptchaModuleOptions, IGoogleResponse } from './captcha.interface';
|
|
3
|
-
import { RequestService } from '../request';
|
|
4
|
-
import { Reflector } from '@nestjs/core';
|
|
5
|
-
import { CachingService } from '../caching';
|
|
6
|
-
export declare class CaptchaGuard implements CanActivate {
|
|
7
|
-
private reflector;
|
|
8
|
-
private captchaModuleOptions;
|
|
9
|
-
private readonly requestService;
|
|
10
|
-
private readonly cachingService;
|
|
11
|
-
constructor(reflector: Reflector, captchaModuleOptions: CaptchaModuleOptions, requestService: RequestService<IGoogleResponse>, cachingService: CachingService);
|
|
12
|
-
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
13
|
-
private getCaptchaDetails;
|
|
14
|
-
private incExecutionTimes;
|
|
15
|
-
private isCaptchaValid;
|
|
16
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CaptchaGuard = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const captcha_interface_1 = require("./captcha.interface");
|
|
18
|
-
const request_1 = require("../request");
|
|
19
|
-
const core_1 = require("@nestjs/core");
|
|
20
|
-
const captcha_decorators_enum_1 = require("./enums/captcha-decorators.enum");
|
|
21
|
-
const captcha_exception_1 = require("./captcha.exception");
|
|
22
|
-
const request_2 = require("../request");
|
|
23
|
-
const caching_1 = require("../caching");
|
|
24
|
-
const decorators_1 = require("../../decorators");
|
|
25
|
-
let CaptchaGuard = class CaptchaGuard {
|
|
26
|
-
constructor(reflector, captchaModuleOptions, requestService, cachingService) {
|
|
27
|
-
this.reflector = reflector;
|
|
28
|
-
this.captchaModuleOptions = captchaModuleOptions;
|
|
29
|
-
this.requestService = requestService;
|
|
30
|
-
this.cachingService = cachingService;
|
|
31
|
-
}
|
|
32
|
-
async canActivate(context) {
|
|
33
|
-
const captchaSettings = this.getCaptchaDetails(context);
|
|
34
|
-
const request = context.switchToHttp().getRequest();
|
|
35
|
-
const iamContext = (0, decorators_1.getIamContext)(request);
|
|
36
|
-
if (iamContext?.agentId || iamContext?.userId || !captchaSettings)
|
|
37
|
-
return true;
|
|
38
|
-
if (captchaSettings && captchaSettings.executeAfter) {
|
|
39
|
-
const ip = iamContext?.ip || null;
|
|
40
|
-
const result = await this.incExecutionTimes(ip, captchaSettings.executeAfter);
|
|
41
|
-
if (result)
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
const headers = typeof request?.headers === 'string'
|
|
45
|
-
? JSON.parse(request?.headers)
|
|
46
|
-
: request?.headers;
|
|
47
|
-
const text = headers?.['captcha-token'];
|
|
48
|
-
if (!text)
|
|
49
|
-
throw new captcha_exception_1.InvalidCaptcha();
|
|
50
|
-
await this.isCaptchaValid(text);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
getCaptchaDetails(context) {
|
|
54
|
-
const captchaDetailsForEndpoint = this.reflector.get(captcha_decorators_enum_1.CaptchaDecorators.CAPTCHA, context.getHandler());
|
|
55
|
-
const captchaDetailsForController = this.reflector.get(captcha_decorators_enum_1.CaptchaDecorators.CAPTCHA, context.getClass());
|
|
56
|
-
return captchaDetailsForEndpoint || captchaDetailsForController;
|
|
57
|
-
}
|
|
58
|
-
async incExecutionTimes(ip, executionCount) {
|
|
59
|
-
const cacheKey = `captcha-execution-count-${ip}`;
|
|
60
|
-
const executionTimes = await this.cachingService.get(cacheKey);
|
|
61
|
-
if (executionTimes < executionCount) {
|
|
62
|
-
await this.cachingService.set(cacheKey, (executionTimes || 0) + 1, this.captchaModuleOptions.executionAfterTtlSeconds);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async isCaptchaValid(text) {
|
|
67
|
-
const params = new URLSearchParams();
|
|
68
|
-
params.append('secret', this.captchaModuleOptions.secret);
|
|
69
|
-
params.append('response', text);
|
|
70
|
-
const result = await this.requestService.send({
|
|
71
|
-
path: this.captchaModuleOptions.verifyUrl,
|
|
72
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
73
|
-
params: params.toString(),
|
|
74
|
-
method: request_2.HttpMethods.POST,
|
|
75
|
-
});
|
|
76
|
-
if (!result.success)
|
|
77
|
-
throw new captcha_exception_1.InvalidCaptcha(result?.['error-codes']?.join(', '));
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
exports.CaptchaGuard = CaptchaGuard;
|
|
81
|
-
exports.CaptchaGuard = CaptchaGuard = __decorate([
|
|
82
|
-
(0, common_1.Injectable)(),
|
|
83
|
-
__param(1, (0, common_1.Inject)(captcha_interface_1.CAPTCHA_MODULE_OPTIONS)),
|
|
84
|
-
__metadata("design:paramtypes", [core_1.Reflector, Object, request_1.RequestService,
|
|
85
|
-
caching_1.CachingService])
|
|
86
|
-
], CaptchaGuard);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
-
export declare const CAPTCHA_MODULE_OPTIONS = "CAPTCHA_MODULE_OPTIONS";
|
|
3
|
-
export interface CaptchaModuleOptions {
|
|
4
|
-
secret: string;
|
|
5
|
-
verifyUrl: string;
|
|
6
|
-
executionAfterTtlSeconds: number;
|
|
7
|
-
}
|
|
8
|
-
export interface CaptchaModuleFactory {
|
|
9
|
-
createModuleOptions: () => Promise<CaptchaModuleOptions> | CaptchaModuleOptions;
|
|
10
|
-
}
|
|
11
|
-
export interface CaptchaModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
12
|
-
inject?: any[];
|
|
13
|
-
useClass?: Type<CaptchaModuleFactory>;
|
|
14
|
-
useExisting?: Type<CaptchaModuleFactory>;
|
|
15
|
-
useFactory?: (...args: any[]) => Promise<CaptchaModuleOptions> | CaptchaModuleOptions;
|
|
16
|
-
}
|
|
17
|
-
export interface IGoogleResponse {
|
|
18
|
-
success: boolean;
|
|
19
|
-
challenge_ts: Date;
|
|
20
|
-
hostname?: string;
|
|
21
|
-
apk_package_name?: string;
|
|
22
|
-
error_codes: Array<string>;
|
|
23
|
-
}
|
|
24
|
-
export interface ICaptchaSettings {
|
|
25
|
-
executeAfter: number;
|
|
26
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { CaptchaModuleAsyncOptions, CaptchaModuleOptions } from './captcha.interface';
|
|
3
|
-
export declare class CaptchaModule {
|
|
4
|
-
static register(options: CaptchaModuleOptions): DynamicModule;
|
|
5
|
-
static registerAsync(options: CaptchaModuleAsyncOptions): DynamicModule;
|
|
6
|
-
private static createAsyncOptionsProvider;
|
|
7
|
-
private static createAsyncProviders;
|
|
8
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var CaptchaModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.CaptchaModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const captcha_interface_1 = require("./captcha.interface");
|
|
13
|
-
const core_1 = require("@nestjs/core");
|
|
14
|
-
const captcha_guard_1 = require("./captcha.guard");
|
|
15
|
-
const request_1 = require("../request");
|
|
16
|
-
let CaptchaModule = CaptchaModule_1 = class CaptchaModule {
|
|
17
|
-
static register(options) {
|
|
18
|
-
return {
|
|
19
|
-
module: CaptchaModule_1,
|
|
20
|
-
imports: [request_1.RequestModule],
|
|
21
|
-
providers: [
|
|
22
|
-
{
|
|
23
|
-
provide: core_1.APP_GUARD,
|
|
24
|
-
useClass: captcha_guard_1.CaptchaGuard,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
provide: captcha_interface_1.CAPTCHA_MODULE_OPTIONS,
|
|
28
|
-
useValue: options,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
controllers: [],
|
|
32
|
-
exports: [],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
static registerAsync(options) {
|
|
36
|
-
const asyncOptionsProvider = this.createAsyncOptionsProvider(options);
|
|
37
|
-
return {
|
|
38
|
-
module: CaptchaModule_1,
|
|
39
|
-
imports: [...(options.imports || []), asyncOptionsProvider],
|
|
40
|
-
providers: [],
|
|
41
|
-
controllers: [],
|
|
42
|
-
exports: [],
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
static createAsyncOptionsProvider(options) {
|
|
46
|
-
const providers = this.createAsyncProviders(options);
|
|
47
|
-
return {
|
|
48
|
-
module: CaptchaModule_1,
|
|
49
|
-
imports: [request_1.RequestModule],
|
|
50
|
-
providers,
|
|
51
|
-
exports: [captcha_interface_1.CAPTCHA_MODULE_OPTIONS],
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
static createAsyncProviders(options) {
|
|
55
|
-
if (options.useFactory) {
|
|
56
|
-
return [
|
|
57
|
-
{
|
|
58
|
-
provide: core_1.APP_GUARD,
|
|
59
|
-
useClass: captcha_guard_1.CaptchaGuard,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
provide: captcha_interface_1.CAPTCHA_MODULE_OPTIONS,
|
|
63
|
-
useFactory: options.useFactory,
|
|
64
|
-
inject: options.inject || [],
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
}
|
|
68
|
-
const useClass = options.useClass || options.useExisting;
|
|
69
|
-
if (useClass) {
|
|
70
|
-
return [
|
|
71
|
-
{
|
|
72
|
-
provide: captcha_interface_1.CAPTCHA_MODULE_OPTIONS,
|
|
73
|
-
useFactory: async (optionsFactory) => await optionsFactory.createModuleOptions(),
|
|
74
|
-
inject: [options.useExisting || options.useClass],
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
provide: core_1.APP_GUARD,
|
|
78
|
-
useClass: captcha_guard_1.CaptchaGuard,
|
|
79
|
-
},
|
|
80
|
-
...(options.useClass
|
|
81
|
-
? [
|
|
82
|
-
{
|
|
83
|
-
provide: options.useClass,
|
|
84
|
-
useClass: options.useClass,
|
|
85
|
-
},
|
|
86
|
-
]
|
|
87
|
-
: []),
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
throw new Error('Invalid CaptchaModuleAsyncOptions');
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
exports.CaptchaModule = CaptchaModule;
|
|
94
|
-
exports.CaptchaModule = CaptchaModule = CaptchaModule_1 = __decorate([
|
|
95
|
-
(0, common_1.Global)(),
|
|
96
|
-
(0, common_1.Module)({})
|
|
97
|
-
], CaptchaModule);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CaptchaDecorators = void 0;
|
|
4
|
-
var CaptchaDecorators;
|
|
5
|
-
(function (CaptchaDecorators) {
|
|
6
|
-
CaptchaDecorators["CAPTCHA"] = "captcha";
|
|
7
|
-
})(CaptchaDecorators || (exports.CaptchaDecorators = CaptchaDecorators = {}));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CaptchaErrors = void 0;
|
|
4
|
-
var CaptchaErrors;
|
|
5
|
-
(function (CaptchaErrors) {
|
|
6
|
-
CaptchaErrors["INVALID_CAPTCHA"] = "captcha.INVALID_CAPTCHA";
|
|
7
|
-
})(CaptchaErrors || (exports.CaptchaErrors = CaptchaErrors = {}));
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CAPTCHA_MODULE_OPTIONS } from './captcha.interface';
|
|
2
|
-
import { CaptchaModule } from './captcha.module';
|
|
3
|
-
import { CaptchaModuleOptions } from './captcha.interface';
|
|
4
|
-
import { CaptchaGuard } from './captcha.guard';
|
|
5
|
-
export { CaptchaGuard, CaptchaModule, CAPTCHA_MODULE_OPTIONS, CaptchaModuleOptions, };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CAPTCHA_MODULE_OPTIONS = exports.CaptchaModule = exports.CaptchaGuard = void 0;
|
|
4
|
-
const captcha_interface_1 = require("./captcha.interface");
|
|
5
|
-
Object.defineProperty(exports, "CAPTCHA_MODULE_OPTIONS", { enumerable: true, get: function () { return captcha_interface_1.CAPTCHA_MODULE_OPTIONS; } });
|
|
6
|
-
const captcha_module_1 = require("./captcha.module");
|
|
7
|
-
Object.defineProperty(exports, "CaptchaModule", { enumerable: true, get: function () { return captcha_module_1.CaptchaModule; } });
|
|
8
|
-
const captcha_guard_1 = require("./captcha.guard");
|
|
9
|
-
Object.defineProperty(exports, "CaptchaGuard", { enumerable: true, get: function () { return captcha_guard_1.CaptchaGuard; } });
|