@volcanicminds/backend 0.2.40 → 0.2.42
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/lib/api/auth/routes.js +21 -155
- package/dist/lib/api/auth/routes.js.map +1 -1
- package/dist/lib/api/health/routes.js +1 -7
- package/dist/lib/api/health/routes.js.map +1 -1
- package/dist/lib/api/token/controller/token.js +3 -1
- package/dist/lib/api/token/controller/token.js.map +1 -1
- package/dist/lib/api/token/routes.js +9 -27
- package/dist/lib/api/token/routes.js.map +1 -1
- package/dist/lib/hooks/onRequest.js +2 -5
- package/dist/lib/hooks/onRequest.js.map +1 -1
- package/dist/lib/schemas/auth.js +67 -0
- package/dist/lib/schemas/auth.js.map +1 -1
- package/dist/lib/schemas/common.js +35 -2
- package/dist/lib/schemas/common.js.map +1 -1
- package/dist/lib/schemas/token.js +1 -12
- package/dist/lib/schemas/token.js.map +1 -1
- package/lib/api/auth/routes.ts +21 -155
- package/lib/api/health/routes.ts +1 -7
- package/lib/api/token/controller/token.ts +6 -1
- package/lib/api/token/routes.ts +9 -27
- package/lib/hooks/onRequest.ts +2 -6
- package/lib/schemas/auth.ts +69 -0
- package/lib/schemas/common.ts +38 -1
- package/lib/schemas/token.ts +0 -12
- package/package.json +1 -1
|
@@ -19,30 +19,9 @@ module.exports = {
|
|
|
19
19
|
config: {
|
|
20
20
|
title: 'Register new user',
|
|
21
21
|
description: 'Register a new user',
|
|
22
|
-
body: {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
username: { type: 'string' },
|
|
26
|
-
email: { type: 'string' },
|
|
27
|
-
password1: { type: 'string' },
|
|
28
|
-
password2: { type: 'string' },
|
|
29
|
-
requiredRoles: { type: 'array', items: { type: 'string' } }
|
|
30
|
-
}
|
|
31
|
-
},
|
|
22
|
+
body: { $ref: 'authRegisterBodySchema#' },
|
|
32
23
|
response: {
|
|
33
|
-
200: {
|
|
34
|
-
description: 'Default response',
|
|
35
|
-
type: 'object',
|
|
36
|
-
properties: {
|
|
37
|
-
id: { type: 'string' },
|
|
38
|
-
_id: { type: 'string' },
|
|
39
|
-
externalId: { type: 'string' },
|
|
40
|
-
username: { type: 'string' },
|
|
41
|
-
email: { type: 'string' },
|
|
42
|
-
enabled: { type: 'boolean' },
|
|
43
|
-
roles: { type: 'array', items: { type: 'string' } }
|
|
44
|
-
}
|
|
45
|
-
}
|
|
24
|
+
200: { $ref: 'authRegisterResponseSchema#' }
|
|
46
25
|
}
|
|
47
26
|
}
|
|
48
27
|
},
|
|
@@ -55,21 +34,9 @@ module.exports = {
|
|
|
55
34
|
config: {
|
|
56
35
|
title: 'Unregister existing user (actually disables it)',
|
|
57
36
|
description: 'Unregister an existing user (actually disables it)',
|
|
58
|
-
body: {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
email: { type: 'string' },
|
|
62
|
-
password: { type: 'string' }
|
|
63
|
-
}
|
|
64
|
-
},
|
|
37
|
+
body: { $ref: 'authLoginBodySchema#' },
|
|
65
38
|
response: {
|
|
66
|
-
200: {
|
|
67
|
-
description: 'Default response',
|
|
68
|
-
type: 'object',
|
|
69
|
-
properties: {
|
|
70
|
-
ok: { type: 'boolean' }
|
|
71
|
-
}
|
|
72
|
-
}
|
|
39
|
+
200: { $ref: 'defaultResponse#' }
|
|
73
40
|
}
|
|
74
41
|
}
|
|
75
42
|
},
|
|
@@ -82,20 +49,9 @@ module.exports = {
|
|
|
82
49
|
config: {
|
|
83
50
|
title: 'Validate password',
|
|
84
51
|
description: 'Validate password if valid and usable',
|
|
85
|
-
body: {
|
|
86
|
-
type: 'object',
|
|
87
|
-
properties: {
|
|
88
|
-
password: { type: 'string' }
|
|
89
|
-
}
|
|
90
|
-
},
|
|
52
|
+
body: { $ref: 'onlyPasswordSchema#' },
|
|
91
53
|
response: {
|
|
92
|
-
200: {
|
|
93
|
-
description: 'Default response',
|
|
94
|
-
type: 'object',
|
|
95
|
-
properties: {
|
|
96
|
-
ok: { type: 'boolean' }
|
|
97
|
-
}
|
|
98
|
-
}
|
|
54
|
+
200: { $ref: 'defaultResponse#' }
|
|
99
55
|
}
|
|
100
56
|
}
|
|
101
57
|
},
|
|
@@ -108,23 +64,9 @@ module.exports = {
|
|
|
108
64
|
config: {
|
|
109
65
|
title: 'Change password',
|
|
110
66
|
description: 'Change password for an existing user',
|
|
111
|
-
body: {
|
|
112
|
-
type: 'object',
|
|
113
|
-
properties: {
|
|
114
|
-
email: { type: 'string' },
|
|
115
|
-
oldPassword: { type: 'string' },
|
|
116
|
-
newPassword1: { type: 'string' },
|
|
117
|
-
newPassword2: { type: 'string' }
|
|
118
|
-
}
|
|
119
|
-
},
|
|
67
|
+
body: { $ref: 'authChangePasswordBodySchema#' },
|
|
120
68
|
response: {
|
|
121
|
-
200: {
|
|
122
|
-
description: 'Default response',
|
|
123
|
-
type: 'object',
|
|
124
|
-
properties: {
|
|
125
|
-
ok: { type: 'boolean' }
|
|
126
|
-
}
|
|
127
|
-
}
|
|
69
|
+
200: { $ref: 'defaultResponse#' }
|
|
128
70
|
}
|
|
129
71
|
}
|
|
130
72
|
},
|
|
@@ -137,21 +79,9 @@ module.exports = {
|
|
|
137
79
|
config: {
|
|
138
80
|
title: 'Forgot password',
|
|
139
81
|
description: 'Forgot password for an existing user given the email or username',
|
|
140
|
-
body: {
|
|
141
|
-
type: 'object',
|
|
142
|
-
properties: {
|
|
143
|
-
username: { type: 'string' },
|
|
144
|
-
email: { type: 'string' }
|
|
145
|
-
}
|
|
146
|
-
},
|
|
82
|
+
body: { $ref: 'authForgotPasswordBodySchema#' },
|
|
147
83
|
response: {
|
|
148
|
-
200: {
|
|
149
|
-
description: 'Default response',
|
|
150
|
-
type: 'object',
|
|
151
|
-
properties: {
|
|
152
|
-
ok: { type: 'boolean' }
|
|
153
|
-
}
|
|
154
|
-
}
|
|
84
|
+
200: { $ref: 'defaultResponse#' }
|
|
155
85
|
}
|
|
156
86
|
}
|
|
157
87
|
},
|
|
@@ -164,20 +94,9 @@ module.exports = {
|
|
|
164
94
|
config: {
|
|
165
95
|
title: 'Confirm email',
|
|
166
96
|
description: 'Confirm email for an existing user',
|
|
167
|
-
body: {
|
|
168
|
-
type: 'object',
|
|
169
|
-
properties: {
|
|
170
|
-
code: { type: 'string' }
|
|
171
|
-
}
|
|
172
|
-
},
|
|
97
|
+
body: { $ref: 'onlyCodeSchema#' },
|
|
173
98
|
response: {
|
|
174
|
-
200: {
|
|
175
|
-
description: 'Default response',
|
|
176
|
-
type: 'object',
|
|
177
|
-
properties: {
|
|
178
|
-
ok: { type: 'boolean' }
|
|
179
|
-
}
|
|
180
|
-
}
|
|
99
|
+
200: { $ref: 'defaultResponse#' }
|
|
181
100
|
}
|
|
182
101
|
}
|
|
183
102
|
},
|
|
@@ -190,22 +109,9 @@ module.exports = {
|
|
|
190
109
|
config: {
|
|
191
110
|
title: 'Reset password',
|
|
192
111
|
description: 'Reset password for an existing user given the reset token',
|
|
193
|
-
body: {
|
|
194
|
-
type: 'object',
|
|
195
|
-
properties: {
|
|
196
|
-
code: { type: 'string' },
|
|
197
|
-
newPassword1: { type: 'string' },
|
|
198
|
-
newPassword2: { type: 'string' }
|
|
199
|
-
}
|
|
200
|
-
},
|
|
112
|
+
body: { $ref: 'resetPasswordBodySchema#' },
|
|
201
113
|
response: {
|
|
202
|
-
200: {
|
|
203
|
-
description: 'Default response',
|
|
204
|
-
type: 'object',
|
|
205
|
-
properties: {
|
|
206
|
-
ok: { type: 'boolean' }
|
|
207
|
-
}
|
|
208
|
-
}
|
|
114
|
+
200: { $ref: 'defaultResponse#' }
|
|
209
115
|
}
|
|
210
116
|
}
|
|
211
117
|
},
|
|
@@ -218,13 +124,7 @@ module.exports = {
|
|
|
218
124
|
config: {
|
|
219
125
|
title: 'Login',
|
|
220
126
|
description: 'Basic login authentication',
|
|
221
|
-
body: {
|
|
222
|
-
type: 'object',
|
|
223
|
-
properties: {
|
|
224
|
-
email: { type: 'string' },
|
|
225
|
-
password: { type: 'string' }
|
|
226
|
-
}
|
|
227
|
-
},
|
|
127
|
+
body: { $ref: 'authLoginBodySchema#' },
|
|
228
128
|
response: {
|
|
229
129
|
200: {
|
|
230
130
|
description: 'Default response',
|
|
@@ -252,13 +152,7 @@ module.exports = {
|
|
|
252
152
|
title: 'Invalidate all tokens',
|
|
253
153
|
description: 'Invalidate all tokens',
|
|
254
154
|
response: {
|
|
255
|
-
200: {
|
|
256
|
-
description: 'Default response',
|
|
257
|
-
type: 'object',
|
|
258
|
-
properties: {
|
|
259
|
-
ok: { type: 'boolean' }
|
|
260
|
-
}
|
|
261
|
-
}
|
|
155
|
+
200: { $ref: 'defaultResponse#' }
|
|
262
156
|
}
|
|
263
157
|
}
|
|
264
158
|
},
|
|
@@ -271,24 +165,10 @@ module.exports = {
|
|
|
271
165
|
config: {
|
|
272
166
|
title: 'Block a user by id',
|
|
273
167
|
description: 'Block a user by id',
|
|
274
|
-
params: {
|
|
275
|
-
|
|
276
|
-
properties: {
|
|
277
|
-
id: {
|
|
278
|
-
type: 'string',
|
|
279
|
-
description: 'User id'
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
body: { $ref: 'blockBodySchema' },
|
|
168
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
169
|
+
body: { $ref: 'blockBodySchema#' },
|
|
284
170
|
response: {
|
|
285
|
-
200: {
|
|
286
|
-
description: 'Default response',
|
|
287
|
-
type: 'object',
|
|
288
|
-
properties: {
|
|
289
|
-
ok: { type: 'boolean' }
|
|
290
|
-
}
|
|
291
|
-
}
|
|
171
|
+
200: { $ref: 'defaultResponse#' }
|
|
292
172
|
}
|
|
293
173
|
}
|
|
294
174
|
},
|
|
@@ -301,23 +181,9 @@ module.exports = {
|
|
|
301
181
|
config: {
|
|
302
182
|
title: 'Unblock a user by id',
|
|
303
183
|
description: 'Unblock a user by id',
|
|
304
|
-
params: {
|
|
305
|
-
type: 'object',
|
|
306
|
-
properties: {
|
|
307
|
-
id: {
|
|
308
|
-
type: 'string',
|
|
309
|
-
description: 'User id'
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
},
|
|
184
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
313
185
|
response: {
|
|
314
|
-
200: {
|
|
315
|
-
description: 'Default response',
|
|
316
|
-
type: 'object',
|
|
317
|
-
properties: {
|
|
318
|
-
ok: { type: 'boolean' }
|
|
319
|
-
}
|
|
320
|
-
}
|
|
186
|
+
200: { $ref: 'defaultResponse#' }
|
|
321
187
|
}
|
|
322
188
|
}
|
|
323
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/auth/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,0BAA0B;QACvC,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,MAAM,CAAC;QACd,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;YAClD,MAAM,EAAE;gBACN,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/auth/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,0BAA0B;QACvC,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,MAAM,CAAC;QACd,UAAU,EAAE,KAAK;QACjB,OAAO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,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,oBAAoB;gBAC3B,WAAW,EAAE,oBAAoB;gBACjC,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;gBACjC,IAAI,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;gBAClC,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;iBAClC;aACF;SACF;QACD;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,sBAAsB;gBAC7B,WAAW,EAAE,sBAAsB;gBACnC,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;gBACjC,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;iBAClC;aACF;SACF;KACF;CACF,CAAA"}
|
|
@@ -17,13 +17,7 @@ module.exports = {
|
|
|
17
17
|
title: 'Health check service',
|
|
18
18
|
description: 'Health check service',
|
|
19
19
|
response: {
|
|
20
|
-
200: {
|
|
21
|
-
description: 'Default response',
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: {
|
|
24
|
-
ok: { type: 'boolean' }
|
|
25
|
-
}
|
|
26
|
-
}
|
|
20
|
+
200: { $ref: 'defaultResponse#' }
|
|
27
21
|
}
|
|
28
22
|
}
|
|
29
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/health/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,kBAAkB;QAC/B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,QAAQ,CAAC;KACjB;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE;gBACN,KAAK,EAAE,sBAAsB;gBAC7B,WAAW,EAAE,sBAAsB;gBACnC,QAAQ,EAAE;oBACR,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/health/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,kBAAkB;QAC/B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,QAAQ,CAAC;KACjB;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,EAAE;YACT,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE;gBACN,KAAK,EAAE,sBAAsB;gBAC7B,WAAW,EAAE,sBAAsB;gBACnC,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;iBAClC;aACF;SACF;KACF;CACF,CAAA"}
|
|
@@ -47,7 +47,9 @@ function create(req, reply) {
|
|
|
47
47
|
if (!token || !token.getId() || !token.externalId) {
|
|
48
48
|
return reply.status(400).send(Error('Token not registered'));
|
|
49
49
|
}
|
|
50
|
-
const bearerToken = yield reply.jwtSign({ sub: token.externalId }
|
|
50
|
+
const bearerToken = yield reply.jwtSign({ sub: token.externalId }, {
|
|
51
|
+
sign: { expiresIn: undefined }
|
|
52
|
+
});
|
|
51
53
|
if (!bearerToken) {
|
|
52
54
|
return reply.status(400).send(Error('Token not signed'));
|
|
53
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../../../lib/api/token/controller/token.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,KAAK,CAAC,GAAmB,EAAE,KAAmB;;QAClE,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IAChE,CAAC;CAAA;AAFD,sBAEC;AAED,SAAsB,IAAI,CAAC,GAAmB,EAAE,KAAmB;;QACjE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;QACnF,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtE,CAAC;CAAA;AAHD,oBAGC;AAED,SAAsB,OAAO,CAAC,GAAmB,EAAE,KAAmB;;QACpE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAC,UAAU,EAAE,CAAA;QAE/B,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;QACpE,OAAO,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAC1C,CAAC;CAAA;AALD,0BAKC;AAED,SAAsB,MAAM,CAAC,GAAmB,EAAE,KAAmB;;;QACnE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;QAEvB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,I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UC"}
|
|
@@ -55,7 +55,7 @@ module.exports = {
|
|
|
55
55
|
config: {
|
|
56
56
|
title: 'Find token',
|
|
57
57
|
description: 'Get token by id',
|
|
58
|
-
params: { $ref: '
|
|
58
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
59
59
|
response: {
|
|
60
60
|
200: {
|
|
61
61
|
description: 'Default response',
|
|
@@ -91,7 +91,7 @@ module.exports = {
|
|
|
91
91
|
config: {
|
|
92
92
|
title: 'Update existing token',
|
|
93
93
|
description: 'Update an existing token',
|
|
94
|
-
params: { $ref: '
|
|
94
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
95
95
|
body: { $ref: 'tokenBodySchema' },
|
|
96
96
|
response: {
|
|
97
97
|
200: {
|
|
@@ -110,15 +110,9 @@ module.exports = {
|
|
|
110
110
|
config: {
|
|
111
111
|
title: 'Unregister existing token (actually disables it)',
|
|
112
112
|
description: 'Unregister an existing token (actually disables it)',
|
|
113
|
-
params: { $ref: '
|
|
113
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
114
114
|
response: {
|
|
115
|
-
200: {
|
|
116
|
-
description: 'Default response',
|
|
117
|
-
type: 'object',
|
|
118
|
-
properties: {
|
|
119
|
-
ok: { type: 'boolean' }
|
|
120
|
-
}
|
|
121
|
-
}
|
|
115
|
+
200: { $ref: 'defaultResponse#' }
|
|
122
116
|
}
|
|
123
117
|
}
|
|
124
118
|
},
|
|
@@ -131,16 +125,10 @@ module.exports = {
|
|
|
131
125
|
config: {
|
|
132
126
|
title: 'Block a token by id',
|
|
133
127
|
description: 'Block a token by id',
|
|
134
|
-
params: { $ref: '
|
|
135
|
-
body: { $ref: 'blockBodySchema' },
|
|
128
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
129
|
+
body: { $ref: 'blockBodySchema#' },
|
|
136
130
|
response: {
|
|
137
|
-
200: {
|
|
138
|
-
description: 'Default response',
|
|
139
|
-
type: 'object',
|
|
140
|
-
properties: {
|
|
141
|
-
ok: { type: 'boolean' }
|
|
142
|
-
}
|
|
143
|
-
}
|
|
131
|
+
200: { $ref: 'defaultResponse#' }
|
|
144
132
|
}
|
|
145
133
|
}
|
|
146
134
|
},
|
|
@@ -153,15 +141,9 @@ module.exports = {
|
|
|
153
141
|
config: {
|
|
154
142
|
title: 'Unblock a token by id',
|
|
155
143
|
description: 'Unblock a token by id',
|
|
156
|
-
params: { $ref: '
|
|
144
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
157
145
|
response: {
|
|
158
|
-
200: {
|
|
159
|
-
description: 'Default response',
|
|
160
|
-
type: 'object',
|
|
161
|
-
properties: {
|
|
162
|
-
ok: { type: 'boolean' }
|
|
163
|
-
}
|
|
164
|
-
}
|
|
146
|
+
200: { $ref: 'defaultResponse#' }
|
|
165
147
|
}
|
|
166
148
|
}
|
|
167
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/token/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,6BAA6B;QAC1C,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,OAAO,CAAC;QACf,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE;gBACN,KAAK,EAAE,aAAa;gBACpB,WAAW,EAAE,iBAAiB;gBAC9B,KAAK,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;gBACvC,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;qBAChC;iBACF;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE;gBACN,KAAK,EAAE,cAAc;gBACrB,WAAW,EAAE,cAAc;gBAC3B,QAAQ,EAAE;oBACR,GAAG,EAAE;wBACH,WAAW,EAAE,kBAAkB;wBAC/B,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;QACD;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE;gBACN,KAAK,EAAE,YAAY;gBACnB,WAAW,EAAE,iBAAiB;gBAC9B,MAAM,EAAE,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../../lib/api/token/routes.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE;QACN,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,6BAA6B;QAC1C,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,CAAC,OAAO,CAAC;QACf,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb;IACD,MAAM,EAAE;QACN;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG;YACT,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE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;YACtB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,qBAAqB;gBAC5B,WAAW,EAAE,qBAAqB;gBAClC,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;gBACjC,IAAI,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;gBAClC,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;iBAClC;aACF;SACF;QACD;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;YACtC,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,CAAC,wBAAwB,CAAC;YACvC,MAAM,EAAE;gBACN,KAAK,EAAE,uBAAuB;gBAC9B,WAAW,EAAE,uBAAuB;gBACpC,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;gBACjC,QAAQ,EAAE;oBACR,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;iBAClC;aACF;SACF;KACF;CACF,CAAA"}
|
|
@@ -21,16 +21,13 @@ module.exports = (req, reply) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
21
21
|
const [prefix, bearerToken] = auth.split(' ');
|
|
22
22
|
const isRoutePublic = (req.routeConfig.requiredRoles || []).some((role) => role.code === roles.public.code);
|
|
23
23
|
if (prefix === 'Bearer' && bearerToken != null) {
|
|
24
|
-
let user =
|
|
25
|
-
let token =
|
|
26
|
-
console.log('bearer ' + bearerToken);
|
|
24
|
+
let user = null;
|
|
25
|
+
let token = null;
|
|
27
26
|
try {
|
|
28
27
|
const tokenData = reply.server.jwt.verify(bearerToken);
|
|
29
28
|
user = yield req.server['userManager'].retrieveUserByExternalId(tokenData === null || tokenData === void 0 ? void 0 : tokenData.sub);
|
|
30
|
-
console.log(user);
|
|
31
29
|
if (!user) {
|
|
32
30
|
token = yield req.server['tokenManager'].retrieveTokenByExternalId(tokenData === null || tokenData === void 0 ? void 0 : tokenData.sub);
|
|
33
|
-
console.log(token);
|
|
34
31
|
}
|
|
35
32
|
if (!user && !token) {
|
|
36
33
|
return reply.status(404).send({ statusCode: 404, code: 'USER_NOT_FOUND', message: 'User not found' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onRequest.js","sourceRoot":"","sources":["../../../lib/hooks/onRequest.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAmD;AAGnD,MAAM,CAAC,OAAO,GAAG,CAAO,GAAG,EAAE,KAAK,EAAE,EAAE;;IAEpC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,CAAA;IACrC,GAAG,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,IAAA,gBAAO,EAAC,GAAG,CAAC,CAAA;IAC7B,GAAG,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAA;IACrC,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9D,GAAG,CAAC,OAAO,GAAG,CAAC,CAAO,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,CAAA,CAAC,CAAA;IAGxG,MAAM,IAAI,GAAG,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,aAAa,KAAI,EAAE,CAAA;I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,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,KAAI,QAAQ;SAC/B,CAAA;QACD,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAEzG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YACzB,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,WAAW,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;YACvE,OAAO,KAAK;iBACT,MAAM,CAAC,GAAG,CAAC;iBACX,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC,CAAA;SAClG;KACF;AACH,CAAC,CAAA,CAAA"}
|
package/dist/lib/schemas/auth.js
CHANGED
|
@@ -1,2 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetPasswordBodySchema = exports.authChangePasswordBodySchema = exports.authRegisterResponseSchema = exports.authRegisterBodySchema = exports.authForgotPasswordBodySchema = exports.authLoginBodySchema = void 0;
|
|
4
|
+
exports.authLoginBodySchema = {
|
|
5
|
+
$id: 'authLoginBodySchema',
|
|
6
|
+
type: 'object',
|
|
7
|
+
nullable: true,
|
|
8
|
+
properties: {
|
|
9
|
+
email: { type: 'string' },
|
|
10
|
+
password: { type: 'string' }
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.authForgotPasswordBodySchema = {
|
|
14
|
+
$id: 'authForgotPasswordBodySchema',
|
|
15
|
+
type: 'object',
|
|
16
|
+
nullable: true,
|
|
17
|
+
properties: {
|
|
18
|
+
username: { type: 'string' },
|
|
19
|
+
email: { type: 'string' }
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.authRegisterBodySchema = {
|
|
23
|
+
$id: 'authRegisterBodySchema',
|
|
24
|
+
type: 'object',
|
|
25
|
+
nullable: true,
|
|
26
|
+
properties: {
|
|
27
|
+
username: { type: 'string' },
|
|
28
|
+
email: { type: 'string' },
|
|
29
|
+
password1: { type: 'string' },
|
|
30
|
+
password2: { type: 'string' },
|
|
31
|
+
requiredRoles: { type: 'array', items: { type: 'string' } }
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.authRegisterResponseSchema = {
|
|
35
|
+
$id: 'authRegisterResponseSchema',
|
|
36
|
+
type: 'object',
|
|
37
|
+
nullable: true,
|
|
38
|
+
properties: {
|
|
39
|
+
id: { type: 'string' },
|
|
40
|
+
_id: { type: 'string' },
|
|
41
|
+
externalId: { type: 'string' },
|
|
42
|
+
username: { type: 'string' },
|
|
43
|
+
email: { type: 'string' },
|
|
44
|
+
enabled: { type: 'boolean' },
|
|
45
|
+
roles: { type: 'array', items: { type: 'string' } }
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.authChangePasswordBodySchema = {
|
|
49
|
+
$id: 'authChangePasswordBodySchema',
|
|
50
|
+
type: 'object',
|
|
51
|
+
nullable: true,
|
|
52
|
+
properties: {
|
|
53
|
+
email: { type: 'string' },
|
|
54
|
+
oldPassword: { type: 'string' },
|
|
55
|
+
newPassword1: { type: 'string' },
|
|
56
|
+
newPassword2: { type: 'string' }
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.resetPasswordBodySchema = {
|
|
60
|
+
$id: 'resetPasswordBodySchema',
|
|
61
|
+
type: 'object',
|
|
62
|
+
nullable: true,
|
|
63
|
+
properties: {
|
|
64
|
+
code: { type: 'string' },
|
|
65
|
+
newPassword1: { type: 'string' },
|
|
66
|
+
newPassword2: { type: 'string' }
|
|
67
|
+
}
|
|
68
|
+
};
|
|
2
69
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../lib/schemas/auth.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../lib/schemas/auth.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;IACjC,GAAG,EAAE,qBAAqB;IAC1B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC7B;CACF,CAAA;AACY,QAAA,4BAA4B,GAAG;IAC1C,GAAG,EAAE,8BAA8B;IACnC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1B;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAG;IACpC,GAAG,EAAE,wBAAwB;IAC7B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;KAC5D;CACF,CAAA;AAEY,QAAA,0BAA0B,GAAG;IACxC,GAAG,EAAE,4BAA4B;IACjC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACtB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC5B,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;KACpD;CACF,CAAA;AAEY,QAAA,4BAA4B,GAAG;IAC1C,GAAG,EAAE,8BAA8B;IACnC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC/B,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAChC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACjC;CACF,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,GAAG,EAAE,yBAAyB;IAC9B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAChC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACjC;CACF,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blockBodySchema = exports.getQueryParamsSchema = void 0;
|
|
3
|
+
exports.defaultResponse = exports.blockBodySchema = exports.onlyPasswordSchema = exports.onlyCodeSchema = exports.onlyIdSchema = exports.getQueryParamsSchema = void 0;
|
|
4
4
|
exports.getQueryParamsSchema = {
|
|
5
5
|
$id: 'getQueryParamsSchema',
|
|
6
6
|
type: 'object',
|
|
@@ -22,12 +22,45 @@ exports.getQueryParamsSchema = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
exports.onlyIdSchema = {
|
|
26
|
+
$id: 'onlyIdSchema',
|
|
27
|
+
type: 'object',
|
|
28
|
+
nullable: true,
|
|
29
|
+
properties: {
|
|
30
|
+
id: { type: 'string', description: 'Entity id' }
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.onlyCodeSchema = {
|
|
34
|
+
$id: 'onlyCodeSchema',
|
|
35
|
+
type: 'object',
|
|
36
|
+
nullable: true,
|
|
37
|
+
properties: {
|
|
38
|
+
code: { type: 'string', description: 'Code' }
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.onlyPasswordSchema = {
|
|
42
|
+
$id: 'onlyPasswordSchema',
|
|
43
|
+
type: 'object',
|
|
44
|
+
nullable: true,
|
|
45
|
+
properties: {
|
|
46
|
+
password: { type: 'string', description: 'Password' }
|
|
47
|
+
}
|
|
48
|
+
};
|
|
25
49
|
exports.blockBodySchema = {
|
|
26
50
|
$id: 'blockBodySchema',
|
|
27
51
|
type: 'object',
|
|
28
52
|
nullable: true,
|
|
29
53
|
properties: {
|
|
30
|
-
reason: { type: 'string' }
|
|
54
|
+
reason: { type: 'string', description: 'Reason' }
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.defaultResponse = {
|
|
58
|
+
$id: 'defaultResponse',
|
|
59
|
+
type: 'object',
|
|
60
|
+
description: 'Default response',
|
|
61
|
+
nullable: true,
|
|
62
|
+
properties: {
|
|
63
|
+
ok: { type: 'boolean' }
|
|
31
64
|
}
|
|
32
65
|
};
|
|
33
66
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../lib/schemas/common.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;IAClC,GAAG,EAAE,sBAAsB;IAC3B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6BAA6B;SAC3C;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4BAA4B;SAC1C;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO;YACb,WAAW,EACT;iFACyE;YAC3E,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;KACF;CACF,CAAA;AAEY,QAAA,eAAe,GAAG;IAC7B,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../lib/schemas/common.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;IAClC,GAAG,EAAE,sBAAsB;IAC3B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6BAA6B;SAC3C;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4BAA4B;SAC1C;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO;YACb,WAAW,EACT;iFACyE;YAC3E,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;KACF;CACF,CAAA;AAEY,QAAA,YAAY,GAAG;IAC1B,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE;KACjD;CACF,CAAA;AAEY,QAAA,cAAc,GAAG;IAC5B,GAAG,EAAE,gBAAgB;IACrB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;KAC9C;CACF,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE;KACtD;CACF,CAAA;AAEY,QAAA,eAAe,GAAG;IAC7B,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE;KAClD;CACF,CAAA;AAEY,QAAA,eAAe,GAAG;IAC7B,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,kBAAkB;IAC/B,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KACxB;CACF,CAAA"}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tokenSchema = exports.tokenBodySchema =
|
|
4
|
-
exports.tokenParamsSchema = {
|
|
5
|
-
$id: 'tokenParamsSchema',
|
|
6
|
-
type: 'object',
|
|
7
|
-
nullable: true,
|
|
8
|
-
properties: {
|
|
9
|
-
id: {
|
|
10
|
-
type: 'string',
|
|
11
|
-
description: 'Token id'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
3
|
+
exports.tokenSchema = exports.tokenBodySchema = void 0;
|
|
15
4
|
exports.tokenBodySchema = {
|
|
16
5
|
$id: 'tokenBodySchema',
|
|
17
6
|
type: 'object',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../lib/schemas/token.ts"],"names":[],"mappings":";;;AAAa,QAAA,
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../lib/schemas/token.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC/B,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;KAC5D;CACF,CAAA;AAEY,QAAA,WAAW,GAAG;IACzB,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACtB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC/B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;KACpD;CACF,CAAA"}
|
package/lib/api/auth/routes.ts
CHANGED
|
@@ -18,30 +18,9 @@ module.exports = {
|
|
|
18
18
|
config: {
|
|
19
19
|
title: 'Register new user',
|
|
20
20
|
description: 'Register a new user',
|
|
21
|
-
body: {
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: {
|
|
24
|
-
username: { type: 'string' },
|
|
25
|
-
email: { type: 'string' },
|
|
26
|
-
password1: { type: 'string' },
|
|
27
|
-
password2: { type: 'string' },
|
|
28
|
-
requiredRoles: { type: 'array', items: { type: 'string' } }
|
|
29
|
-
}
|
|
30
|
-
},
|
|
21
|
+
body: { $ref: 'authRegisterBodySchema#' },
|
|
31
22
|
response: {
|
|
32
|
-
200: {
|
|
33
|
-
description: 'Default response',
|
|
34
|
-
type: 'object',
|
|
35
|
-
properties: {
|
|
36
|
-
id: { type: 'string' },
|
|
37
|
-
_id: { type: 'string' },
|
|
38
|
-
externalId: { type: 'string' },
|
|
39
|
-
username: { type: 'string' },
|
|
40
|
-
email: { type: 'string' },
|
|
41
|
-
enabled: { type: 'boolean' },
|
|
42
|
-
roles: { type: 'array', items: { type: 'string' } }
|
|
43
|
-
}
|
|
44
|
-
}
|
|
23
|
+
200: { $ref: 'authRegisterResponseSchema#' }
|
|
45
24
|
}
|
|
46
25
|
}
|
|
47
26
|
},
|
|
@@ -54,21 +33,9 @@ module.exports = {
|
|
|
54
33
|
config: {
|
|
55
34
|
title: 'Unregister existing user (actually disables it)',
|
|
56
35
|
description: 'Unregister an existing user (actually disables it)',
|
|
57
|
-
body: {
|
|
58
|
-
type: 'object',
|
|
59
|
-
properties: {
|
|
60
|
-
email: { type: 'string' },
|
|
61
|
-
password: { type: 'string' }
|
|
62
|
-
}
|
|
63
|
-
},
|
|
36
|
+
body: { $ref: 'authLoginBodySchema#' },
|
|
64
37
|
response: {
|
|
65
|
-
200: {
|
|
66
|
-
description: 'Default response',
|
|
67
|
-
type: 'object',
|
|
68
|
-
properties: {
|
|
69
|
-
ok: { type: 'boolean' }
|
|
70
|
-
}
|
|
71
|
-
}
|
|
38
|
+
200: { $ref: 'defaultResponse#' }
|
|
72
39
|
}
|
|
73
40
|
}
|
|
74
41
|
},
|
|
@@ -81,20 +48,9 @@ module.exports = {
|
|
|
81
48
|
config: {
|
|
82
49
|
title: 'Validate password',
|
|
83
50
|
description: 'Validate password if valid and usable',
|
|
84
|
-
body: {
|
|
85
|
-
type: 'object',
|
|
86
|
-
properties: {
|
|
87
|
-
password: { type: 'string' }
|
|
88
|
-
}
|
|
89
|
-
},
|
|
51
|
+
body: { $ref: 'onlyPasswordSchema#' },
|
|
90
52
|
response: {
|
|
91
|
-
200: {
|
|
92
|
-
description: 'Default response',
|
|
93
|
-
type: 'object',
|
|
94
|
-
properties: {
|
|
95
|
-
ok: { type: 'boolean' }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
53
|
+
200: { $ref: 'defaultResponse#' }
|
|
98
54
|
}
|
|
99
55
|
}
|
|
100
56
|
},
|
|
@@ -107,23 +63,9 @@ module.exports = {
|
|
|
107
63
|
config: {
|
|
108
64
|
title: 'Change password',
|
|
109
65
|
description: 'Change password for an existing user',
|
|
110
|
-
body: {
|
|
111
|
-
type: 'object',
|
|
112
|
-
properties: {
|
|
113
|
-
email: { type: 'string' },
|
|
114
|
-
oldPassword: { type: 'string' },
|
|
115
|
-
newPassword1: { type: 'string' },
|
|
116
|
-
newPassword2: { type: 'string' }
|
|
117
|
-
}
|
|
118
|
-
},
|
|
66
|
+
body: { $ref: 'authChangePasswordBodySchema#' },
|
|
119
67
|
response: {
|
|
120
|
-
200: {
|
|
121
|
-
description: 'Default response',
|
|
122
|
-
type: 'object',
|
|
123
|
-
properties: {
|
|
124
|
-
ok: { type: 'boolean' }
|
|
125
|
-
}
|
|
126
|
-
}
|
|
68
|
+
200: { $ref: 'defaultResponse#' }
|
|
127
69
|
}
|
|
128
70
|
}
|
|
129
71
|
},
|
|
@@ -136,21 +78,9 @@ module.exports = {
|
|
|
136
78
|
config: {
|
|
137
79
|
title: 'Forgot password',
|
|
138
80
|
description: 'Forgot password for an existing user given the email or username',
|
|
139
|
-
body: {
|
|
140
|
-
type: 'object',
|
|
141
|
-
properties: {
|
|
142
|
-
username: { type: 'string' },
|
|
143
|
-
email: { type: 'string' }
|
|
144
|
-
}
|
|
145
|
-
},
|
|
81
|
+
body: { $ref: 'authForgotPasswordBodySchema#' },
|
|
146
82
|
response: {
|
|
147
|
-
200: {
|
|
148
|
-
description: 'Default response',
|
|
149
|
-
type: 'object',
|
|
150
|
-
properties: {
|
|
151
|
-
ok: { type: 'boolean' }
|
|
152
|
-
}
|
|
153
|
-
}
|
|
83
|
+
200: { $ref: 'defaultResponse#' }
|
|
154
84
|
}
|
|
155
85
|
}
|
|
156
86
|
},
|
|
@@ -163,20 +93,9 @@ module.exports = {
|
|
|
163
93
|
config: {
|
|
164
94
|
title: 'Confirm email',
|
|
165
95
|
description: 'Confirm email for an existing user',
|
|
166
|
-
body: {
|
|
167
|
-
type: 'object',
|
|
168
|
-
properties: {
|
|
169
|
-
code: { type: 'string' }
|
|
170
|
-
}
|
|
171
|
-
},
|
|
96
|
+
body: { $ref: 'onlyCodeSchema#' },
|
|
172
97
|
response: {
|
|
173
|
-
200: {
|
|
174
|
-
description: 'Default response',
|
|
175
|
-
type: 'object',
|
|
176
|
-
properties: {
|
|
177
|
-
ok: { type: 'boolean' }
|
|
178
|
-
}
|
|
179
|
-
}
|
|
98
|
+
200: { $ref: 'defaultResponse#' }
|
|
180
99
|
}
|
|
181
100
|
}
|
|
182
101
|
},
|
|
@@ -189,22 +108,9 @@ module.exports = {
|
|
|
189
108
|
config: {
|
|
190
109
|
title: 'Reset password',
|
|
191
110
|
description: 'Reset password for an existing user given the reset token',
|
|
192
|
-
body: {
|
|
193
|
-
type: 'object',
|
|
194
|
-
properties: {
|
|
195
|
-
code: { type: 'string' },
|
|
196
|
-
newPassword1: { type: 'string' },
|
|
197
|
-
newPassword2: { type: 'string' }
|
|
198
|
-
}
|
|
199
|
-
},
|
|
111
|
+
body: { $ref: 'resetPasswordBodySchema#' },
|
|
200
112
|
response: {
|
|
201
|
-
200: {
|
|
202
|
-
description: 'Default response',
|
|
203
|
-
type: 'object',
|
|
204
|
-
properties: {
|
|
205
|
-
ok: { type: 'boolean' }
|
|
206
|
-
}
|
|
207
|
-
}
|
|
113
|
+
200: { $ref: 'defaultResponse#' }
|
|
208
114
|
}
|
|
209
115
|
}
|
|
210
116
|
},
|
|
@@ -217,13 +123,7 @@ module.exports = {
|
|
|
217
123
|
config: {
|
|
218
124
|
title: 'Login',
|
|
219
125
|
description: 'Basic login authentication',
|
|
220
|
-
body: {
|
|
221
|
-
type: 'object',
|
|
222
|
-
properties: {
|
|
223
|
-
email: { type: 'string' },
|
|
224
|
-
password: { type: 'string' }
|
|
225
|
-
}
|
|
226
|
-
},
|
|
126
|
+
body: { $ref: 'authLoginBodySchema#' },
|
|
227
127
|
response: {
|
|
228
128
|
200: {
|
|
229
129
|
description: 'Default response',
|
|
@@ -251,13 +151,7 @@ module.exports = {
|
|
|
251
151
|
title: 'Invalidate all tokens',
|
|
252
152
|
description: 'Invalidate all tokens',
|
|
253
153
|
response: {
|
|
254
|
-
200: {
|
|
255
|
-
description: 'Default response',
|
|
256
|
-
type: 'object',
|
|
257
|
-
properties: {
|
|
258
|
-
ok: { type: 'boolean' }
|
|
259
|
-
}
|
|
260
|
-
}
|
|
154
|
+
200: { $ref: 'defaultResponse#' }
|
|
261
155
|
}
|
|
262
156
|
}
|
|
263
157
|
},
|
|
@@ -270,24 +164,10 @@ module.exports = {
|
|
|
270
164
|
config: {
|
|
271
165
|
title: 'Block a user by id',
|
|
272
166
|
description: 'Block a user by id',
|
|
273
|
-
params: {
|
|
274
|
-
|
|
275
|
-
properties: {
|
|
276
|
-
id: {
|
|
277
|
-
type: 'string',
|
|
278
|
-
description: 'User id'
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
body: { $ref: 'blockBodySchema' },
|
|
167
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
168
|
+
body: { $ref: 'blockBodySchema#' },
|
|
283
169
|
response: {
|
|
284
|
-
200: {
|
|
285
|
-
description: 'Default response',
|
|
286
|
-
type: 'object',
|
|
287
|
-
properties: {
|
|
288
|
-
ok: { type: 'boolean' }
|
|
289
|
-
}
|
|
290
|
-
}
|
|
170
|
+
200: { $ref: 'defaultResponse#' }
|
|
291
171
|
}
|
|
292
172
|
}
|
|
293
173
|
},
|
|
@@ -300,23 +180,9 @@ module.exports = {
|
|
|
300
180
|
config: {
|
|
301
181
|
title: 'Unblock a user by id',
|
|
302
182
|
description: 'Unblock a user by id',
|
|
303
|
-
params: {
|
|
304
|
-
type: 'object',
|
|
305
|
-
properties: {
|
|
306
|
-
id: {
|
|
307
|
-
type: 'string',
|
|
308
|
-
description: 'User id'
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
},
|
|
183
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
312
184
|
response: {
|
|
313
|
-
200: {
|
|
314
|
-
description: 'Default response',
|
|
315
|
-
type: 'object',
|
|
316
|
-
properties: {
|
|
317
|
-
ok: { type: 'boolean' }
|
|
318
|
-
}
|
|
319
|
-
}
|
|
185
|
+
200: { $ref: 'defaultResponse#' }
|
|
320
186
|
}
|
|
321
187
|
}
|
|
322
188
|
}
|
package/lib/api/health/routes.ts
CHANGED
|
@@ -16,13 +16,7 @@ module.exports = {
|
|
|
16
16
|
title: 'Health check service',
|
|
17
17
|
description: 'Health check service',
|
|
18
18
|
response: {
|
|
19
|
-
200: {
|
|
20
|
-
description: 'Default response',
|
|
21
|
-
type: 'object',
|
|
22
|
-
properties: {
|
|
23
|
-
ok: { type: 'boolean' }
|
|
24
|
-
}
|
|
25
|
-
}
|
|
19
|
+
200: { $ref: 'defaultResponse#' }
|
|
26
20
|
}
|
|
27
21
|
}
|
|
28
22
|
}
|
|
@@ -35,7 +35,12 @@ export async function create(req: FastifyRequest, reply: FastifyReply) {
|
|
|
35
35
|
return reply.status(400).send(Error('Token not registered'))
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const bearerToken = await reply.jwtSign(
|
|
38
|
+
const bearerToken = await reply.jwtSign(
|
|
39
|
+
{ sub: token.externalId },
|
|
40
|
+
{
|
|
41
|
+
sign: { expiresIn: undefined }
|
|
42
|
+
}
|
|
43
|
+
)
|
|
39
44
|
if (!bearerToken) {
|
|
40
45
|
return reply.status(400).send(Error('Token not signed'))
|
|
41
46
|
}
|
package/lib/api/token/routes.ts
CHANGED
|
@@ -54,7 +54,7 @@ module.exports = {
|
|
|
54
54
|
config: {
|
|
55
55
|
title: 'Find token',
|
|
56
56
|
description: 'Get token by id',
|
|
57
|
-
params: { $ref: '
|
|
57
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
58
58
|
response: {
|
|
59
59
|
200: {
|
|
60
60
|
description: 'Default response',
|
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
|
90
90
|
config: {
|
|
91
91
|
title: 'Update existing token',
|
|
92
92
|
description: 'Update an existing token',
|
|
93
|
-
params: { $ref: '
|
|
93
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
94
94
|
body: { $ref: 'tokenBodySchema' },
|
|
95
95
|
response: {
|
|
96
96
|
200: {
|
|
@@ -109,15 +109,9 @@ module.exports = {
|
|
|
109
109
|
config: {
|
|
110
110
|
title: 'Unregister existing token (actually disables it)',
|
|
111
111
|
description: 'Unregister an existing token (actually disables it)',
|
|
112
|
-
params: { $ref: '
|
|
112
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
113
113
|
response: {
|
|
114
|
-
200: {
|
|
115
|
-
description: 'Default response',
|
|
116
|
-
type: 'object',
|
|
117
|
-
properties: {
|
|
118
|
-
ok: { type: 'boolean' }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
114
|
+
200: { $ref: 'defaultResponse#' }
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
},
|
|
@@ -130,16 +124,10 @@ module.exports = {
|
|
|
130
124
|
config: {
|
|
131
125
|
title: 'Block a token by id',
|
|
132
126
|
description: 'Block a token by id',
|
|
133
|
-
params: { $ref: '
|
|
134
|
-
body: { $ref: 'blockBodySchema' },
|
|
127
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
128
|
+
body: { $ref: 'blockBodySchema#' },
|
|
135
129
|
response: {
|
|
136
|
-
200: {
|
|
137
|
-
description: 'Default response',
|
|
138
|
-
type: 'object',
|
|
139
|
-
properties: {
|
|
140
|
-
ok: { type: 'boolean' }
|
|
141
|
-
}
|
|
142
|
-
}
|
|
130
|
+
200: { $ref: 'defaultResponse#' }
|
|
143
131
|
}
|
|
144
132
|
}
|
|
145
133
|
},
|
|
@@ -152,15 +140,9 @@ module.exports = {
|
|
|
152
140
|
config: {
|
|
153
141
|
title: 'Unblock a token by id',
|
|
154
142
|
description: 'Unblock a token by id',
|
|
155
|
-
params: { $ref: '
|
|
143
|
+
params: { $ref: 'onlyIdSchema#' },
|
|
156
144
|
response: {
|
|
157
|
-
200: {
|
|
158
|
-
description: 'Default response',
|
|
159
|
-
type: 'object',
|
|
160
|
-
properties: {
|
|
161
|
-
ok: { type: 'boolean' }
|
|
162
|
-
}
|
|
163
|
-
}
|
|
145
|
+
200: { $ref: 'defaultResponse#' }
|
|
164
146
|
}
|
|
165
147
|
}
|
|
166
148
|
}
|
package/lib/hooks/onRequest.ts
CHANGED
|
@@ -15,18 +15,14 @@ module.exports = async (req, reply) => {
|
|
|
15
15
|
const isRoutePublic = (req.routeConfig.requiredRoles || []).some((role: Role) => role.code === roles.public.code)
|
|
16
16
|
|
|
17
17
|
if (prefix === 'Bearer' && bearerToken != null) {
|
|
18
|
-
let user: AuthenticatedUser =
|
|
19
|
-
let token: AuthenticatedToken =
|
|
20
|
-
|
|
21
|
-
console.log('bearer ' + bearerToken)
|
|
18
|
+
let user: null | AuthenticatedUser = null
|
|
19
|
+
let token: null | AuthenticatedToken = null
|
|
22
20
|
|
|
23
21
|
try {
|
|
24
22
|
const tokenData = reply.server.jwt.verify(bearerToken)
|
|
25
23
|
user = await req.server['userManager'].retrieveUserByExternalId(tokenData?.sub)
|
|
26
|
-
console.log(user)
|
|
27
24
|
if (!user) {
|
|
28
25
|
token = await req.server['tokenManager'].retrieveTokenByExternalId(tokenData?.sub)
|
|
29
|
-
console.log(token)
|
|
30
26
|
}
|
|
31
27
|
if (!user && !token) {
|
|
32
28
|
return reply.status(404).send({ statusCode: 404, code: 'USER_NOT_FOUND', message: 'User not found' })
|
package/lib/schemas/auth.ts
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const authLoginBodySchema = {
|
|
2
|
+
$id: 'authLoginBodySchema',
|
|
3
|
+
type: 'object',
|
|
4
|
+
nullable: true,
|
|
5
|
+
properties: {
|
|
6
|
+
email: { type: 'string' },
|
|
7
|
+
password: { type: 'string' }
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const authForgotPasswordBodySchema = {
|
|
11
|
+
$id: 'authForgotPasswordBodySchema',
|
|
12
|
+
type: 'object',
|
|
13
|
+
nullable: true,
|
|
14
|
+
properties: {
|
|
15
|
+
username: { type: 'string' },
|
|
16
|
+
email: { type: 'string' }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const authRegisterBodySchema = {
|
|
21
|
+
$id: 'authRegisterBodySchema',
|
|
22
|
+
type: 'object',
|
|
23
|
+
nullable: true,
|
|
24
|
+
properties: {
|
|
25
|
+
username: { type: 'string' },
|
|
26
|
+
email: { type: 'string' },
|
|
27
|
+
password1: { type: 'string' },
|
|
28
|
+
password2: { type: 'string' },
|
|
29
|
+
requiredRoles: { type: 'array', items: { type: 'string' } }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const authRegisterResponseSchema = {
|
|
34
|
+
$id: 'authRegisterResponseSchema',
|
|
35
|
+
type: 'object',
|
|
36
|
+
nullable: true,
|
|
37
|
+
properties: {
|
|
38
|
+
id: { type: 'string' },
|
|
39
|
+
_id: { type: 'string' },
|
|
40
|
+
externalId: { type: 'string' },
|
|
41
|
+
username: { type: 'string' },
|
|
42
|
+
email: { type: 'string' },
|
|
43
|
+
enabled: { type: 'boolean' },
|
|
44
|
+
roles: { type: 'array', items: { type: 'string' } }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const authChangePasswordBodySchema = {
|
|
49
|
+
$id: 'authChangePasswordBodySchema',
|
|
50
|
+
type: 'object',
|
|
51
|
+
nullable: true,
|
|
52
|
+
properties: {
|
|
53
|
+
email: { type: 'string' },
|
|
54
|
+
oldPassword: { type: 'string' },
|
|
55
|
+
newPassword1: { type: 'string' },
|
|
56
|
+
newPassword2: { type: 'string' }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const resetPasswordBodySchema = {
|
|
61
|
+
$id: 'resetPasswordBodySchema',
|
|
62
|
+
type: 'object',
|
|
63
|
+
nullable: true,
|
|
64
|
+
properties: {
|
|
65
|
+
code: { type: 'string' },
|
|
66
|
+
newPassword1: { type: 'string' },
|
|
67
|
+
newPassword2: { type: 'string' }
|
|
68
|
+
}
|
|
69
|
+
}
|
package/lib/schemas/common.ts
CHANGED
|
@@ -21,11 +21,48 @@ export const getQueryParamsSchema = {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export const onlyIdSchema = {
|
|
25
|
+
$id: 'onlyIdSchema',
|
|
26
|
+
type: 'object',
|
|
27
|
+
nullable: true,
|
|
28
|
+
properties: {
|
|
29
|
+
id: { type: 'string', description: 'Entity id' }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const onlyCodeSchema = {
|
|
34
|
+
$id: 'onlyCodeSchema',
|
|
35
|
+
type: 'object',
|
|
36
|
+
nullable: true,
|
|
37
|
+
properties: {
|
|
38
|
+
code: { type: 'string', description: 'Code' }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const onlyPasswordSchema = {
|
|
43
|
+
$id: 'onlyPasswordSchema',
|
|
44
|
+
type: 'object',
|
|
45
|
+
nullable: true,
|
|
46
|
+
properties: {
|
|
47
|
+
password: { type: 'string', description: 'Password' }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
24
51
|
export const blockBodySchema = {
|
|
25
52
|
$id: 'blockBodySchema',
|
|
26
53
|
type: 'object',
|
|
27
54
|
nullable: true,
|
|
28
55
|
properties: {
|
|
29
|
-
reason: { type: 'string' }
|
|
56
|
+
reason: { type: 'string', description: 'Reason' }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const defaultResponse = {
|
|
61
|
+
$id: 'defaultResponse',
|
|
62
|
+
type: 'object',
|
|
63
|
+
description: 'Default response',
|
|
64
|
+
nullable: true,
|
|
65
|
+
properties: {
|
|
66
|
+
ok: { type: 'boolean' }
|
|
30
67
|
}
|
|
31
68
|
}
|
package/lib/schemas/token.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
export const tokenParamsSchema = {
|
|
2
|
-
$id: 'tokenParamsSchema',
|
|
3
|
-
type: 'object',
|
|
4
|
-
nullable: true,
|
|
5
|
-
properties: {
|
|
6
|
-
id: {
|
|
7
|
-
type: 'string',
|
|
8
|
-
description: 'Token id'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
export const tokenBodySchema = {
|
|
14
2
|
$id: 'tokenBodySchema',
|
|
15
3
|
type: 'object',
|