@midwayjs/captcha 3.20.5 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,8 @@ const cacheComponent = require("@midwayjs/cache-manager");
12
12
  const DefaultConfig = require("./config/config.default");
13
13
  let CaptchaConfiguration = class CaptchaConfiguration {
14
14
  };
15
- CaptchaConfiguration = __decorate([
15
+ exports.CaptchaConfiguration = CaptchaConfiguration;
16
+ exports.CaptchaConfiguration = CaptchaConfiguration = __decorate([
16
17
  (0, core_1.Configuration)({
17
18
  namespace: 'captcha',
18
19
  imports: [cacheComponent],
@@ -23,5 +24,4 @@ CaptchaConfiguration = __decorate([
23
24
  ],
24
25
  })
25
26
  ], CaptchaConfiguration);
26
- exports.CaptchaConfiguration = CaptchaConfiguration;
27
27
  //# sourceMappingURL=configuration.js.map
package/dist/service.js CHANGED
@@ -22,7 +22,6 @@ const DEFAULT_IMAGE_IGNORE_CHARS = {
22
22
  };
23
23
  let CaptchaService = class CaptchaService {
24
24
  async image(options, cacheOption) {
25
- var _a;
26
25
  // const { expirationTime, idPrefix } = this.captcha;
27
26
  const { type, ...others } = {
28
27
  ...this.captcha.default,
@@ -30,7 +29,7 @@ let CaptchaService = class CaptchaService {
30
29
  ...options,
31
30
  };
32
31
  const { data, text } = svgCaptcha.create({
33
- ignoreChars: (_a = DEFAULT_IMAGE_IGNORE_CHARS[type]) !== null && _a !== void 0 ? _a : '',
32
+ ignoreChars: DEFAULT_IMAGE_IGNORE_CHARS[type] ?? '',
34
33
  ...others,
35
34
  });
36
35
  const id = await this.set(text, cacheOption);
@@ -74,9 +73,8 @@ let CaptchaService = class CaptchaService {
74
73
  return { id, text };
75
74
  }
76
75
  async set(text, cacheOptions) {
77
- var _a;
78
76
  const id = (0, nanoid_1.nanoid)();
79
- await this.captchaCaching.set(this.getStoreId(id, cacheOptions), (text || '').toLowerCase(), ((_a = cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.expirationTime) !== null && _a !== void 0 ? _a : this.captcha.expirationTime) * 1000);
77
+ await this.captchaCaching.set(this.getStoreId(id, cacheOptions), (text || '').toLowerCase(), (cacheOptions?.expirationTime ?? this.captcha.expirationTime) * 1000);
80
78
  return id;
81
79
  }
82
80
  async check(id, value, cacheOptions) {
@@ -92,14 +90,14 @@ let CaptchaService = class CaptchaService {
92
90
  return true;
93
91
  }
94
92
  getStoreId(id, cacheOptions) {
95
- var _a;
96
- const idPrefix = (_a = cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.idPrefix) !== null && _a !== void 0 ? _a : this.captcha.idPrefix;
93
+ const idPrefix = cacheOptions?.idPrefix ?? this.captcha.idPrefix;
97
94
  if (!idPrefix) {
98
95
  return id;
99
96
  }
100
97
  return `${idPrefix}:${id}`;
101
98
  }
102
99
  };
100
+ exports.CaptchaService = CaptchaService;
103
101
  __decorate([
104
102
  (0, core_1.InjectClient)(cache_manager_1.CachingFactory, 'captcha'),
105
103
  __metadata("design:type", Object)
@@ -108,9 +106,8 @@ __decorate([
108
106
  (0, core_1.Config)('captcha'),
109
107
  __metadata("design:type", Object)
110
108
  ], CaptchaService.prototype, "captcha", void 0);
111
- CaptchaService = __decorate([
109
+ exports.CaptchaService = CaptchaService = __decorate([
112
110
  (0, core_1.Provide)(),
113
111
  (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
114
112
  ], CaptchaService);
115
- exports.CaptchaService = CaptchaService;
116
113
  //# sourceMappingURL=service.js.map
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/captcha",
3
- "version": "3.20.5",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "Midway Component for Captcha(Verification Code)",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
9
+ "test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
10
+ "cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
11
11
  "ci": "npm run test"
12
12
  },
13
13
  "keywords": [],
@@ -22,15 +22,15 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@midwayjs/cache-manager": "^3.20.4",
25
+ "@midwayjs/cache-manager": "^4.0.0-beta.1",
26
26
  "mini-svg-data-uri": "1.4.4",
27
27
  "nanoid": "3.3.11",
28
28
  "svg-captcha-fixed": "1.5.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@midwayjs/core": "^3.20.4",
32
- "@midwayjs/koa": "^3.20.5",
33
- "@midwayjs/mock": "^3.20.4"
31
+ "@midwayjs/core": "^4.0.0-beta.1",
32
+ "@midwayjs/koa": "^4.0.0-beta.1",
33
+ "@midwayjs/mock": "^4.0.0-beta.1"
34
34
  },
35
- "gitHead": "7ce57281bd3ef5d18dc50b47ff9bffb8a27c071e"
35
+ "gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
36
36
  }