@adminforth/two-factors-auth 4.4.6 → 4.4.8

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 312,284 bytes received 248 bytes 625,064.00 bytes/sec
21
- total size is 311,311 speedup is 1.00
20
+ sent 311,882 bytes received 248 bytes 624,260.00 bytes/sec
21
+ total size is 310,909 speedup is 1.00
@@ -123,21 +123,16 @@
123
123
  </template>
124
124
 
125
125
  <script setup lang="ts">
126
- import { callAdminForthApi } from '@/utils';
126
+ import { callAdminForthApi, formatDateTime } from '@/utils';
127
127
  import adminforth, { useAdminforth } from '@/adminforth';
128
128
  import { onMounted, ref, Ref } from 'vue';
129
129
  import { useI18n } from 'vue-i18n';
130
130
  import { Dialog, Tooltip, Spinner, Input } from '@/afcl';
131
131
  import { IconTrashBinSolid, IconPenSolid, IconPlusOutline, IconInfoCircleOutline } from '@iconify-prerendered/vue-flowbite';
132
- import dayjs from 'dayjs';
133
- import utc from 'dayjs/plugin/utc';
134
- import timezone from 'dayjs/plugin/timezone';
135
132
  import { useCoreStore } from '@/stores/core';
136
133
  import { useTwoFactorsAuth } from './use2faApi';
137
134
 
138
135
  const { t } = useI18n();
139
- dayjs.extend(utc);
140
- dayjs.extend(timezone);
141
136
  const coreStore = useCoreStore();
142
137
  const twoFactorsAuth = useTwoFactorsAuth();
143
138
 
@@ -353,12 +348,6 @@
353
348
  addPasskeyMode.value = 'cross-platform';
354
349
  }
355
350
  }
356
-
357
- function formatDateTime(date: string) {
358
- if (!date) return '';
359
- const fmt = `${coreStore.config?.datesFormat} ${coreStore.config?.timeFormat}` || 'YYYY-MM-DD HH:mm:ss';
360
- return dayjs.utc(date).local().format(fmt);
361
- }
362
351
  </script>
363
352
 
364
353
  <style>
@@ -123,21 +123,16 @@
123
123
  </template>
124
124
 
125
125
  <script setup lang="ts">
126
- import { callAdminForthApi } from '@/utils';
126
+ import { callAdminForthApi, formatDateTime } from '@/utils';
127
127
  import adminforth, { useAdminforth } from '@/adminforth';
128
128
  import { onMounted, ref, Ref } from 'vue';
129
129
  import { useI18n } from 'vue-i18n';
130
130
  import { Dialog, Tooltip, Spinner, Input } from '@/afcl';
131
131
  import { IconTrashBinSolid, IconPenSolid, IconPlusOutline, IconInfoCircleOutline } from '@iconify-prerendered/vue-flowbite';
132
- import dayjs from 'dayjs';
133
- import utc from 'dayjs/plugin/utc';
134
- import timezone from 'dayjs/plugin/timezone';
135
132
  import { useCoreStore } from '@/stores/core';
136
133
  import { useTwoFactorsAuth } from './use2faApi';
137
134
 
138
135
  const { t } = useI18n();
139
- dayjs.extend(utc);
140
- dayjs.extend(timezone);
141
136
  const coreStore = useCoreStore();
142
137
  const twoFactorsAuth = useTwoFactorsAuth();
143
138
 
@@ -353,12 +348,6 @@
353
348
  addPasskeyMode.value = 'cross-platform';
354
349
  }
355
350
  }
356
-
357
- function formatDateTime(date: string) {
358
- if (!date) return '';
359
- const fmt = `${coreStore.config?.datesFormat} ${coreStore.config?.timeFormat}` || 'YYYY-MM-DD HH:mm:ss';
360
- return dayjs.utc(date).local().format(fmt);
361
- }
362
351
  </script>
363
352
 
364
353
  <style>
@@ -38,7 +38,7 @@ export function createTwoFaHandlers(ctx) {
38
38
  yield ctx.totpService.saveSecret(decoded.pk, decoded.newSecret);
39
39
  }
40
40
  ctx.cookieService.removeTotpTemporary(response);
41
- ctx.cookieService.setAuthCookie({ expireInDuration: decoded.sessionDuration, response, username: decoded.userName, pk: decoded.pk });
41
+ yield ctx.cookieService.setAuthCookie({ expireInDuration: decoded.sessionDuration, response, username: decoded.userName, pk: decoded.pk });
42
42
  return { status: 'ok', allowedLogin: true };
43
43
  }
44
44
  else {
@@ -69,7 +69,7 @@ export function createTwoFaHandlers(ctx) {
69
69
  }
70
70
  if (verified) {
71
71
  ctx.cookieService.removeTotpTemporary(response);
72
- ctx.cookieService.setAuthCookie({ expireInDuration: decoded.sessionDuration, response, username: decoded.userName, pk: decoded.pk });
72
+ yield ctx.cookieService.setAuthCookie({ expireInDuration: decoded.sessionDuration, response, username: decoded.userName, pk: decoded.pk });
73
73
  return { status: 'ok', allowedLogin: true };
74
74
  }
75
75
  else {
@@ -120,7 +120,7 @@ export function createTwoFaHandlers(ctx) {
120
120
  },
121
121
  }, expireInDuration);
122
122
  if (toReturn.allowedLogin === true) {
123
- ctx.cookieService.setAuthCookie({
123
+ yield ctx.cookieService.setAuthCookie({
124
124
  response,
125
125
  username,
126
126
  pk: userPk,
@@ -30,7 +30,7 @@ export declare class CookieService {
30
30
  username: string;
31
31
  pk: string;
32
32
  expireInDuration: string;
33
- }): void;
33
+ }): Promise<string>;
34
34
  getTotpTemporary(cookies: CookieList): string | null;
35
35
  verifyTotpTemporary(cookies: CookieList): Promise<TotpTemporaryPayload | null>;
36
36
  setTotpTemporary(response: IAdminForthHttpResponse, payload: TotpTemporaryPayload): void;
@@ -23,7 +23,7 @@ export class CookieService {
23
23
  return this.adminforth.auth.getCustomCookie({ cookies, name: AUTH_COOKIE });
24
24
  }
25
25
  setAuthCookie(opts) {
26
- this.adminforth.auth.setAuthCookie(opts);
26
+ return this.adminforth.auth.setAuthCookie(opts);
27
27
  }
28
28
  getTotpTemporary(cookies) {
29
29
  return this.adminforth.auth.getCustomCookie({ cookies, name: TOTP_TEMP_COOKIE });
@@ -32,7 +32,7 @@ export function createTwoFaHandlers(ctx: any) {
32
32
  await ctx.totpService.saveSecret(decoded.pk, decoded.newSecret);
33
33
  }
34
34
  ctx.cookieService.removeTotpTemporary(response)
35
- ctx.cookieService.setAuthCookie({expireInDuration: decoded.sessionDuration, response, username:decoded.userName, pk:decoded.pk})
35
+ await ctx.cookieService.setAuthCookie({expireInDuration: decoded.sessionDuration, response, username:decoded.userName, pk:decoded.pk})
36
36
  return { status: 'ok', allowedLogin: true }
37
37
  } else {
38
38
  return respondWithStatus({ error: 'Wrong or expired OTP code' }, response, HttpStatus.FORBIDDEN)
@@ -61,7 +61,7 @@ export function createTwoFaHandlers(ctx: any) {
61
61
  }
62
62
  if (verified) {
63
63
  ctx.cookieService.removeTotpTemporary(response)
64
- ctx.cookieService.setAuthCookie({expireInDuration: decoded.sessionDuration, response, username:decoded.userName, pk:decoded.pk})
64
+ await ctx.cookieService.setAuthCookie({expireInDuration: decoded.sessionDuration, response, username:decoded.userName, pk:decoded.pk})
65
65
  return { status: 'ok', allowedLogin: true }
66
66
  } else {
67
67
  return respondWithStatus({ error: verificationError }, response, HttpStatus.FORBIDDEN)
@@ -124,7 +124,7 @@ export function createTwoFaHandlers(ctx: any) {
124
124
  );
125
125
 
126
126
  if ( toReturn.allowedLogin === true ) {
127
- ctx.cookieService.setAuthCookie({
127
+ await ctx.cookieService.setAuthCookie({
128
128
  response,
129
129
  username,
130
130
  pk: userPk,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "4.4.6",
3
+ "version": "4.4.8",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,11 +29,11 @@
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "peerDependencies": {
32
- "adminforth": "^3.8.2"
32
+ "adminforth": "^3.31.5"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^22.10.7",
36
- "adminforth": "^3.8.2",
36
+ "adminforth": "^3.31.5",
37
37
  "semantic-release": "^24.2.1",
38
38
  "semantic-release-slack-bot": "^4.0.2",
39
39
  "typescript": "^5.7.3"
@@ -43,8 +43,8 @@ export class CookieService {
43
43
  return this.adminforth.auth.getCustomCookie({ cookies, name: AUTH_COOKIE });
44
44
  }
45
45
 
46
- public setAuthCookie(opts: { response: IAdminForthHttpResponse; username: string; pk: string; expireInDuration: string }): void {
47
- this.adminforth.auth.setAuthCookie(opts);
46
+ public setAuthCookie(opts: { response: IAdminForthHttpResponse; username: string; pk: string; expireInDuration: string }): Promise<string> {
47
+ return this.adminforth.auth.setAuthCookie(opts);
48
48
  }
49
49
 
50
50
  public getTotpTemporary(cookies: CookieList): string | null {