forked from produck/svg-captcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
118 lines (118 loc) · 2.33 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* config captcha generation options
*/
declare class ConfigObject {
/**
* default: true
* The length of the random string
*/
size?: number;
/**
* width of captcha
*/
width?: number;
/**
* height of captcha
*/
height?: number;
/**
* captcha text size
*/
fontSize?: number;
/**
* random character preset
*/
charPreset?: string;
/**
* default: false
* if false, captcha will be black and white
* otherwise, it will be randomly colorized
*/
color?: boolean;
/**
* default: false
* if set to true, it will draw with light grey color
* use if you have a site with dark theme
* only active when color is set to false
*/
inverse?: boolean;
/**
* default: ''
* filter out some characters
*/
ignoreChars?: string;
/**
* default: 1
* number of noise lines
*/
noise?: number;
/**
* default: white
* background color of svg image
*/
background?: string;
/**
* default: +
* the math operator to use, "+", "-" or "+/-"
* if unknown operator passed defaults to "+/-"
*/
mathOperator?: string;
/**
* default: 1
* min value of the math expression
*/
mathMin?: number;
/**
* default: 9
* max value of the math expression
*/
mathMax?: number;
}
/**
* result of captcha generation
*/
interface CaptchaObj {
/**
* the captcha text,
* store this in your session
*/
text: string,
/**
* the svg image in string,
* set type of image/svg before send to client side
*/
data: string
}
/**
* This method returns a object that has two props:
* data: svg image string
* text: captcha text
* @param {ConfigObject} [options]
* @return {CaptchaObj}
*/
export function create(options?: ConfigObject): CaptchaObj;
/**
* This method returns a object that has two props:
* data: svg image string
* text: captcha text
* note that this method generate a math expression
* this means that text is the result of the math expression
* @param {ConfigObject} [options]
* @return {CaptchaObj}
*/
export function createMathExpr(options?: ConfigObject): CaptchaObj;
/**
* Override the default font with your own
* @param {string} url
*/
export function loadFont(url: string): void;
/**
* captcha generation global setting
*/
export const options: ConfigObject;
/**
* return a random string
* @param {number} size
* @return {string}
*/
export function randomText(size: number): string;