@adminforth/login-captcha 1.1.23 → 1.2.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/build.log +2 -2
- package/dist/index.js +10 -2
- package/index.ts +10 -2
- package/package.json +6 -3
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { AdminForthPlugin } from "adminforth";
|
|
10
|
+
import { AdminForthPlugin, parseBody } from "adminforth";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
const setTokenBodySchema = z.object({
|
|
13
|
+
token: z.string(),
|
|
14
|
+
}).strict();
|
|
11
15
|
export default class CaptchaPlugin extends AdminForthPlugin {
|
|
12
16
|
constructor(options) {
|
|
13
17
|
super(options, import.meta.url);
|
|
@@ -85,7 +89,11 @@ export default class CaptchaPlugin extends AdminForthPlugin {
|
|
|
85
89
|
path: `/plugin/${this.pluginInstanceId}/setToken`,
|
|
86
90
|
noAuth: true,
|
|
87
91
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response }) {
|
|
88
|
-
const
|
|
92
|
+
const parsed = parseBody(setTokenBodySchema, body, response);
|
|
93
|
+
if ('error' in parsed)
|
|
94
|
+
return parsed.error;
|
|
95
|
+
const data = parsed.data;
|
|
96
|
+
const { token } = data;
|
|
89
97
|
if (!token) {
|
|
90
98
|
return { ok: false, error: 'Token is required' };
|
|
91
99
|
}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { AdminForthPlugin } from "adminforth";
|
|
1
|
+
import { AdminForthPlugin, parseBody } from "adminforth";
|
|
2
2
|
import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthHttpResponse } from "adminforth";
|
|
3
3
|
import type { PluginOptions } from './types.js';
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
const setTokenBodySchema = z.object({
|
|
7
|
+
token: z.string(),
|
|
8
|
+
}).strict();
|
|
4
9
|
|
|
5
10
|
export default class CaptchaPlugin extends AdminForthPlugin {
|
|
6
11
|
options: PluginOptions;
|
|
@@ -92,7 +97,10 @@ export default class CaptchaPlugin extends AdminForthPlugin {
|
|
|
92
97
|
path: `/plugin/${this.pluginInstanceId}/setToken`,
|
|
93
98
|
noAuth: true,
|
|
94
99
|
handler: async ({ body, response }) => {
|
|
95
|
-
const
|
|
100
|
+
const parsed = parseBody(setTokenBodySchema, body, response);
|
|
101
|
+
if ('error' in parsed) return parsed.error;
|
|
102
|
+
const data = parsed.data;
|
|
103
|
+
const { token } = data;
|
|
96
104
|
|
|
97
105
|
if (!token) {
|
|
98
106
|
return { ok: false, error: 'Token is required' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/login-captcha",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -15,15 +15,18 @@
|
|
|
15
15
|
"author": "DevForth (https://devforth.io)",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"description": "",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^4.3.6"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@types/node": "latest",
|
|
20
|
-
"adminforth": "^3.
|
|
23
|
+
"adminforth": "^3.7.1",
|
|
21
24
|
"semantic-release": "^24.2.1",
|
|
22
25
|
"semantic-release-slack-bot": "^4.0.2",
|
|
23
26
|
"typescript": "^5.7.3"
|
|
24
27
|
},
|
|
25
28
|
"peerDependencies": {
|
|
26
|
-
"adminforth": "^3.
|
|
29
|
+
"adminforth": "^3.7.1"
|
|
27
30
|
},
|
|
28
31
|
"release": {
|
|
29
32
|
"plugins": [
|