@jayfong/x-server 1.12.0 → 1.13.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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.13.0](https://github.com/jfWorks/x-server/compare/v1.12.0...v1.13.0) (2022-04-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **CaptchaService:** generate, generateImage ([22bf340](https://github.com/jfWorks/x-server/commit/22bf3404cfb7d3a530714471fe004fcd9ee60760))
|
|
11
|
+
|
|
5
12
|
## [1.12.0](https://github.com/jfWorks/x-server/compare/v1.11.6...v1.12.0) (2022-04-25)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -16,6 +16,15 @@ class CaptchaService {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async generate() {
|
|
19
|
+
const text = Math.random().toString().slice(0 - this.options.size);
|
|
20
|
+
const token = await _x.x.cache.save(text, this.options.ttl);
|
|
21
|
+
return {
|
|
22
|
+
text: text,
|
|
23
|
+
token: token
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async generateImage() {
|
|
19
28
|
const res = _svgCaptcha.default.create({
|
|
20
29
|
size: this.options.size
|
|
21
30
|
});
|
|
@@ -11,6 +11,10 @@ export interface CaptchaOptions {
|
|
|
11
11
|
ttl: MsValue;
|
|
12
12
|
}
|
|
13
13
|
export interface CaptchaGenerateResult {
|
|
14
|
+
text: string;
|
|
15
|
+
token: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CaptchaGenerateImageResult {
|
|
14
18
|
text: string;
|
|
15
19
|
svg: string;
|
|
16
20
|
token: string;
|
|
@@ -24,6 +28,7 @@ export declare class CaptchaService implements BaseService {
|
|
|
24
28
|
serviceName: string;
|
|
25
29
|
constructor(options: CaptchaOptions);
|
|
26
30
|
generate(): Promise<CaptchaGenerateResult>;
|
|
31
|
+
generateImage(): Promise<CaptchaGenerateImageResult>;
|
|
27
32
|
verify(options: CaptchaVerifyOptions): Promise<boolean>;
|
|
28
33
|
}
|
|
29
34
|
declare module '../x' {
|
package/lib/services/captcha.js
CHANGED
|
@@ -7,6 +7,15 @@ export class CaptchaService {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async generate() {
|
|
10
|
+
const text = Math.random().toString().slice(0 - this.options.size);
|
|
11
|
+
const token = await x.cache.save(text, this.options.ttl);
|
|
12
|
+
return {
|
|
13
|
+
text: text,
|
|
14
|
+
token: token
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async generateImage() {
|
|
10
19
|
const res = svgCaptcha.create({
|
|
11
20
|
size: this.options.size
|
|
12
21
|
});
|