@adminforth/open-signup 1.2.25 → 1.3.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 +1 -1
- package/dist/index.js +35 -8
- package/index.ts +37 -9
- package/package.json +5 -4
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,17 @@ 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 AdminForth, { AdminForthPlugin, Filters, suggestIfTypo, AdminForthDataTypes } from "adminforth";
|
|
10
|
+
import AdminForth, { AdminForthPlugin, parseBody, Filters, suggestIfTypo, AdminForthDataTypes } from "adminforth";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
const completeVerifiedSignupBodySchema = z.object({
|
|
13
|
+
token: z.string(),
|
|
14
|
+
password: z.string(),
|
|
15
|
+
}).strict();
|
|
16
|
+
const signupBodySchema = z.object({
|
|
17
|
+
email: z.string(),
|
|
18
|
+
url: z.string(),
|
|
19
|
+
password: z.string().optional(),
|
|
20
|
+
}).strict();
|
|
11
21
|
export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
12
22
|
constructor(options) {
|
|
13
23
|
super(options, import.meta.url);
|
|
@@ -129,11 +139,20 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
129
139
|
path: `/plugin/${this.pluginInstanceId}/password-constraints`,
|
|
130
140
|
noAuth: true,
|
|
131
141
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ tr }) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
if (!this.passwordField) {
|
|
143
|
+
throw new Error(`passwordField is not defined in plugin options`);
|
|
144
|
+
}
|
|
145
|
+
const objectToReturn = {};
|
|
146
|
+
if (this.passwordField.minLength) {
|
|
147
|
+
objectToReturn.minLength = this.passwordField.minLength;
|
|
148
|
+
}
|
|
149
|
+
if (this.passwordField.maxLength) {
|
|
150
|
+
objectToReturn.maxLength = this.passwordField.maxLength;
|
|
151
|
+
}
|
|
152
|
+
if (this.passwordField.validation) {
|
|
153
|
+
objectToReturn.validation = yield Promise.all(this.passwordField.validation.map((_a) => __awaiter(this, [_a], void 0, function* ({ regExp, message }) { return ({ regExp, message: yield tr(message, 'opensignup') }); })));
|
|
154
|
+
}
|
|
155
|
+
return objectToReturn;
|
|
137
156
|
})
|
|
138
157
|
});
|
|
139
158
|
server.endpoint({
|
|
@@ -141,7 +160,11 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
141
160
|
path: `/plugin/${this.pluginInstanceId}/complete-verified-signup`,
|
|
142
161
|
noAuth: true,
|
|
143
162
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response, headers, query, cookies, tr, requestUrl }) {
|
|
144
|
-
const
|
|
163
|
+
const parsed = parseBody(completeVerifiedSignupBodySchema, body, response);
|
|
164
|
+
if ('error' in parsed)
|
|
165
|
+
return parsed.error;
|
|
166
|
+
const data = parsed.data;
|
|
167
|
+
const { token, password } = data;
|
|
145
168
|
if (!token) {
|
|
146
169
|
return { error: yield tr('Invalid token', 'opensignup'), ok: false };
|
|
147
170
|
}
|
|
@@ -173,7 +196,11 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
173
196
|
noAuth: true,
|
|
174
197
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response, headers, query, cookies, tr, requestUrl }) {
|
|
175
198
|
var _b, _c;
|
|
176
|
-
const
|
|
199
|
+
const parsed = parseBody(signupBodySchema, body, response);
|
|
200
|
+
if ('error' in parsed)
|
|
201
|
+
return parsed.error;
|
|
202
|
+
const data = parsed.data;
|
|
203
|
+
const { email, url, password } = data;
|
|
177
204
|
if (!email || typeof email !== 'string') {
|
|
178
205
|
return { error: yield tr('Email is required', 'opensignup'), ok: false };
|
|
179
206
|
}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import AdminForth, { AdminForthPlugin, Filters, suggestIfTypo, AdminForthDataTypes } from "adminforth";
|
|
1
|
+
import AdminForth, { AdminForthPlugin, parseBody, Filters, suggestIfTypo, AdminForthDataTypes } from "adminforth";
|
|
2
2
|
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthResource, BeforeLoginConfirmationFunction, HttpExtra } from "adminforth";
|
|
3
3
|
import type { PluginOptions } from './types.js';
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
const completeVerifiedSignupBodySchema = z.object({
|
|
7
|
+
token: z.string(),
|
|
8
|
+
password: z.string(),
|
|
9
|
+
}).strict();
|
|
10
|
+
|
|
11
|
+
const signupBodySchema = z.object({
|
|
12
|
+
email: z.string(),
|
|
13
|
+
url: z.string(),
|
|
14
|
+
password: z.string().optional(),
|
|
15
|
+
}).strict();
|
|
4
16
|
|
|
5
17
|
|
|
6
18
|
export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
@@ -149,13 +161,23 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
149
161
|
path: `/plugin/${this.pluginInstanceId}/password-constraints`,
|
|
150
162
|
noAuth: true,
|
|
151
163
|
handler: async ({tr}) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
164
|
+
if (!this.passwordField) {
|
|
165
|
+
throw new Error(`passwordField is not defined in plugin options`);
|
|
166
|
+
}
|
|
167
|
+
const objectToReturn: any = {};
|
|
168
|
+
|
|
169
|
+
if (this.passwordField.minLength) {
|
|
170
|
+
objectToReturn.minLength = this.passwordField.minLength;
|
|
171
|
+
}
|
|
172
|
+
if (this.passwordField.maxLength) {
|
|
173
|
+
objectToReturn.maxLength = this.passwordField.maxLength;
|
|
174
|
+
}
|
|
175
|
+
if (this.passwordField.validation) {
|
|
176
|
+
objectToReturn.validation = await Promise.all(
|
|
156
177
|
this.passwordField.validation.map(async ({ regExp, message }) => ({ regExp, message: await tr(message, 'opensignup') }))
|
|
157
|
-
)
|
|
158
|
-
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return objectToReturn;
|
|
159
181
|
}
|
|
160
182
|
});
|
|
161
183
|
|
|
@@ -164,7 +186,10 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
164
186
|
path: `/plugin/${this.pluginInstanceId}/complete-verified-signup`,
|
|
165
187
|
noAuth: true,
|
|
166
188
|
handler: async ({ body, response, headers, query, cookies, tr, requestUrl }) => {
|
|
167
|
-
const
|
|
189
|
+
const parsed = parseBody(completeVerifiedSignupBodySchema, body, response);
|
|
190
|
+
if ('error' in parsed) return parsed.error;
|
|
191
|
+
const data = parsed.data;
|
|
192
|
+
const { token, password } = data;
|
|
168
193
|
if (!token) {
|
|
169
194
|
return { error: await tr('Invalid token', 'opensignup'), ok: false };
|
|
170
195
|
}
|
|
@@ -199,7 +224,10 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
|
|
|
199
224
|
path: `/plugin/${this.pluginInstanceId}/signup`,
|
|
200
225
|
noAuth: true,
|
|
201
226
|
handler: async ({ body, response, headers, query, cookies, tr, requestUrl }) => {
|
|
202
|
-
const
|
|
227
|
+
const parsed = parseBody(signupBodySchema, body, response);
|
|
228
|
+
if ('error' in parsed) return parsed.error;
|
|
229
|
+
const data = parsed.data;
|
|
230
|
+
const { email, url, password } = data;
|
|
203
231
|
if (!email || typeof email !== 'string') {
|
|
204
232
|
return { error: await tr('Email is required', 'opensignup'), ok: false };
|
|
205
233
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/open-signup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -23,14 +23,15 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"description": "Open signup for adminforth",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/client-ses": "^3.654.0"
|
|
26
|
+
"@aws-sdk/client-ses": "^3.654.0",
|
|
27
|
+
"zod": "^4.3.6"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
|
-
"adminforth": "^3.
|
|
30
|
+
"adminforth": "^3.7.1"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/node": "^22.10.7",
|
|
33
|
-
"adminforth": "^3.
|
|
34
|
+
"adminforth": "^3.7.1",
|
|
34
35
|
"semantic-release": "^24.2.1",
|
|
35
36
|
"semantic-release-slack-bot": "^4.0.2",
|
|
36
37
|
"typescript": "^5.7.3"
|