@midwayjs/captcha 3.7.3 → 3.8.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/config/config.default.js +6 -4
- package/dist/interface.d.ts +1 -0
- package/dist/service.js +6 -3
- package/package.json +6 -6
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.captcha = void 0;
|
|
4
4
|
exports.captcha = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
default: {
|
|
6
|
+
size: 4,
|
|
7
|
+
noise: 1,
|
|
8
|
+
width: 120,
|
|
9
|
+
height: 40,
|
|
10
|
+
},
|
|
9
11
|
image: {
|
|
10
12
|
type: 'mixed',
|
|
11
13
|
},
|
package/dist/interface.d.ts
CHANGED
package/dist/service.js
CHANGED
|
@@ -18,7 +18,7 @@ const nanoid_1 = require("nanoid");
|
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
19
|
let CaptchaService = class CaptchaService {
|
|
20
20
|
async image(options) {
|
|
21
|
-
const { width, height, type } = Object.assign({}, this.captcha, this.captcha.image, options);
|
|
21
|
+
const { width, height, type, size, noise } = Object.assign({}, this.captcha, this.captcha.default, this.captcha.image, options);
|
|
22
22
|
let ignoreChars = '';
|
|
23
23
|
switch (type) {
|
|
24
24
|
case 'letter':
|
|
@@ -32,23 +32,26 @@ let CaptchaService = class CaptchaService {
|
|
|
32
32
|
ignoreChars,
|
|
33
33
|
width,
|
|
34
34
|
height,
|
|
35
|
+
size,
|
|
36
|
+
noise,
|
|
35
37
|
});
|
|
36
38
|
const id = await this.set(text);
|
|
37
39
|
const imageBase64 = svgBase64(data);
|
|
38
40
|
return { id, imageBase64 };
|
|
39
41
|
}
|
|
40
42
|
async formula(options) {
|
|
41
|
-
const { width, height } = Object.assign({}, this.captcha, this.captcha.formula, options);
|
|
43
|
+
const { width, height, noise } = Object.assign({}, this.captcha, this.captcha.default, this.captcha.formula, options);
|
|
42
44
|
const { data, text } = svgCaptcha.createMathExpr({
|
|
43
45
|
width,
|
|
44
46
|
height,
|
|
47
|
+
noise,
|
|
45
48
|
});
|
|
46
49
|
const id = await this.set(text);
|
|
47
50
|
const imageBase64 = svgBase64(data);
|
|
48
51
|
return { id, imageBase64 };
|
|
49
52
|
}
|
|
50
53
|
async text(options) {
|
|
51
|
-
const textOptions = Object.assign({}, this.captcha, this.captcha.text, options);
|
|
54
|
+
const textOptions = Object.assign({}, this.captcha, this.captcha.default, this.captcha.text, options);
|
|
52
55
|
let chars = '';
|
|
53
56
|
switch (textOptions.type) {
|
|
54
57
|
case 'letter':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/captcha",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Midway Component for Captcha(Verification Code)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@midwayjs/cache": "^3.
|
|
25
|
+
"@midwayjs/cache": "^3.8.0",
|
|
26
26
|
"mini-svg-data-uri": "1.4.4",
|
|
27
27
|
"nanoid": "3.3.4",
|
|
28
28
|
"svg-captcha": "1.4.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@midwayjs/core": "^3.
|
|
32
|
-
"@midwayjs/koa": "^3.
|
|
33
|
-
"@midwayjs/mock": "^3.
|
|
31
|
+
"@midwayjs/core": "^3.8.0",
|
|
32
|
+
"@midwayjs/koa": "^3.8.0",
|
|
33
|
+
"@midwayjs/mock": "^3.8.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "5c640c7182923587139f9f9c0aecf50585798e1e"
|
|
36
36
|
}
|