@adminforth/two-factors-auth 4.2.0 → 4.2.1

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 CHANGED
@@ -17,5 +17,5 @@ custom/tsconfig.json
17
17
  custom/use2faApi.ts
18
18
  custom/utils.js
19
19
 
20
- sent 288,176 bytes received 248 bytes 576,848.00 bytes/sec
20
+ sent 288,163 bytes received 248 bytes 576,822.00 bytes/sec
21
21
  total size is 287,203 speedup is 1.00
@@ -18,7 +18,7 @@ export function registerTwoFaEndpoints(server, handlers) {
18
18
  method: 'POST',
19
19
  path: `/plugin/twofa/confirmLogin`,
20
20
  noAuth: true,
21
- handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response, cookies }) { return handlers.confirmLogin({ body, response, cookies }); }),
21
+ handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response, cookies, headers }) { return handlers.confirmLogin({ body, response, cookies, headers }); }),
22
22
  });
23
23
  server.endpoint({
24
24
  method: 'POST',
@@ -5,10 +5,11 @@ export declare function createTwoFaHandlers(ctx: any): {
5
5
  totpJWT: any;
6
6
  status: string;
7
7
  }>;
8
- confirmLogin: ({ body, response, cookies }: {
8
+ confirmLogin: ({ body, response, cookies, headers }: {
9
9
  body: any;
10
10
  response: any;
11
11
  cookies: any;
12
+ headers: any;
12
13
  }) => Promise<{
13
14
  status: string;
14
15
  allowedLogin: boolean;
@@ -17,8 +17,12 @@ export function createTwoFaHandlers(ctx) {
17
17
  }
18
18
  return toReturn;
19
19
  }),
20
- confirmLogin: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response, cookies }) {
20
+ confirmLogin: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response, cookies, headers }) {
21
21
  var _b, _c;
22
+ if (!(yield ctx.checkPasskeyLoginRateLimit(headers))) {
23
+ response.setStatus(429);
24
+ return { error: 'Too many login attempts, please try again later' };
25
+ }
22
26
  const totpTemporaryJWT = ctx.cookieService.getTotpTemporary(cookies);
23
27
  if (!totpTemporaryJWT) {
24
28
  return { error: 'Login session expired. Please log in again.' };
@@ -12,7 +12,7 @@ export function registerTwoFaEndpoints(server: IHttpServer, handlers: any): void
12
12
  method: 'POST',
13
13
  path: `/plugin/twofa/confirmLogin`,
14
14
  noAuth: true,
15
- handler: async ({ body, response, cookies }) => handlers.confirmLogin({ body, response, cookies }),
15
+ handler: async ({ body, response, cookies, headers }) => handlers.confirmLogin({ body, response, cookies, headers }),
16
16
  });
17
17
 
18
18
  server.endpoint({
@@ -9,7 +9,12 @@ export function createTwoFaHandlers(ctx: any) {
9
9
  return toReturn
10
10
  },
11
11
 
12
- confirmLogin: async ({ body, response, cookies }) => {
12
+ confirmLogin: async ({ body, response, cookies, headers }) => {
13
+ if (!(await ctx.checkPasskeyLoginRateLimit(headers))) {
14
+ response.setStatus(429);
15
+ return { error: 'Too many login attempts, please try again later' };
16
+ }
17
+
13
18
  const totpTemporaryJWT = ctx.cookieService.getTotpTemporary(cookies);
14
19
  if (!totpTemporaryJWT) {
15
20
  return { error: 'Login session expired. Please log in again.' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",