@adminforth/two-factors-auth 2.7.4 → 2.9.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 CHANGED
@@ -15,5 +15,5 @@ custom/package.json
15
15
  custom/tsconfig.json
16
16
  custom/utils.js
17
17
 
18
- sent 272,033 bytes received 210 bytes 544,486.00 bytes/sec
19
- total size is 271,206 speedup is 1.00
18
+ sent 272,839 bytes received 210 bytes 182,032.67 bytes/sec
19
+ total size is 272,023 speedup is 1.00
@@ -45,7 +45,7 @@
45
45
  </svg>
46
46
  <span class="sr-only">{{$t('Close modal')}}</span>
47
47
  </button>
48
- <IconShieldOutline class="w-16 h-16 text-lightPrimary dark:text-darkPrimary"/>
48
+ <IconShieldOutline class="af-2fa-shield-icon w-16 h-16 text-lightPrimary dark:text-darkPrimary"/>
49
49
  <p class="text-4xl font-semibold mb-4 text:gray-900 dark:text-gray-200 ">{{$t('Passkey')}}</p>
50
50
  <div class="mb-2 max-w-[300px] text:gray-900 dark:text-gray-200">
51
51
  <p class="mb-2">{{customDialogTitle}} </p>
@@ -55,7 +55,7 @@
55
55
  {{$t('Use passkey')}}
56
56
  </Button>
57
57
  <div v-if="modalMode === 'passkey'" class="max-w-sm px-6 pt-3 w-full bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700">
58
- <div class="mb-3 font-normal text-gray-700 dark:text-gray-400">
58
+ <div class="af-2fa-passkey-issues-card mb-3 font-normal text-gray-700 dark:text-gray-400">
59
59
  <p>{{$t('Have issues with passkey?')}}</p>
60
60
  <p class="underline hover:no-underline text-lightPrimary whitespace-nowrap hover:cursor-pointer" @click="modalMode = 'totp'" >{{$t('use TOTP')}}</p>
61
61
  </div>
@@ -128,6 +128,11 @@
128
128
  get2FaConfirmationResult: (verifyingCallback?: (confirmationResult: string) => Promise<boolean>, title?: string) =>
129
129
  new Promise(async (resolve, reject) => {
130
130
  if (modelShow.value) throw new Error('Modal is already open');
131
+ const skipAllowModal = await checkIfSkipAllowModal();
132
+ if (skipAllowModal) {
133
+ resolve({ code: "123456" }); // dummy code
134
+ return;
135
+ }
131
136
  await checkIfUserHasPasskeys();
132
137
  if (title) {
133
138
  customDialogTitle.value = title;
@@ -338,6 +343,24 @@
338
343
  });
339
344
  }
340
345
 
346
+
347
+ async function checkIfSkipAllowModal(){
348
+ try {
349
+ const response = await callAdminForthApi({
350
+ method: "GET",
351
+ path: "/plugin/twofa/skip-allow-modal",
352
+ });
353
+ if ( response.skipAllowed === true ) {
354
+ return true;
355
+ } else {
356
+ return false;
357
+ }
358
+ } catch (error) {
359
+ console.error('Error checking skip allow modal:', error);
360
+ return false;
361
+ }
362
+ }
363
+
341
364
  </script>
342
365
 
343
366
  <style scoped>
@@ -4,16 +4,27 @@
4
4
  "paths": {
5
5
  "@/*": [
6
6
  // "node_modules/adminforth/dist/spa/src/*"
7
- "../../../spa/src/*"
7
+ "../../../adminforth/spa/src/*"
8
8
  ],
9
9
  "*": [
10
10
  // "node_modules/adminforth/dist/spa/node_modules/*"
11
- "../../../spa/node_modules/*"
11
+ "../../../adminforth/spa/node_modules/*"
12
12
  ],
13
13
  "@@/*": [
14
14
  // "node_modules/adminforth/dist/spa/src/*"
15
15
  "."
16
16
  ]
17
17
  }
18
- }
18
+ },
19
+ "include": [
20
+ "./**/*.ts",
21
+ "./**/*.tsx",
22
+ "./**/*.vue",
23
+ "../**/*.ts",
24
+ "../**/*.tsx",
25
+ "../**/*.vue",
26
+ "../*.vue",
27
+ "../*.ts",
28
+ "../*.tsx"
29
+ ]
19
30
  }
@@ -45,7 +45,7 @@
45
45
  </svg>
46
46
  <span class="sr-only">{{$t('Close modal')}}</span>
47
47
  </button>
48
- <IconShieldOutline class="w-16 h-16 text-lightPrimary dark:text-darkPrimary"/>
48
+ <IconShieldOutline class="af-2fa-shield-icon w-16 h-16 text-lightPrimary dark:text-darkPrimary"/>
49
49
  <p class="text-4xl font-semibold mb-4 text:gray-900 dark:text-gray-200 ">{{$t('Passkey')}}</p>
50
50
  <div class="mb-2 max-w-[300px] text:gray-900 dark:text-gray-200">
51
51
  <p class="mb-2">{{customDialogTitle}} </p>
@@ -55,7 +55,7 @@
55
55
  {{$t('Use passkey')}}
56
56
  </Button>
57
57
  <div v-if="modalMode === 'passkey'" class="max-w-sm px-6 pt-3 w-full bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700">
58
- <div class="mb-3 font-normal text-gray-700 dark:text-gray-400">
58
+ <div class="af-2fa-passkey-issues-card mb-3 font-normal text-gray-700 dark:text-gray-400">
59
59
  <p>{{$t('Have issues with passkey?')}}</p>
60
60
  <p class="underline hover:no-underline text-lightPrimary whitespace-nowrap hover:cursor-pointer" @click="modalMode = 'totp'" >{{$t('use TOTP')}}</p>
61
61
  </div>
@@ -128,6 +128,11 @@
128
128
  get2FaConfirmationResult: (verifyingCallback?: (confirmationResult: string) => Promise<boolean>, title?: string) =>
129
129
  new Promise(async (resolve, reject) => {
130
130
  if (modelShow.value) throw new Error('Modal is already open');
131
+ const skipAllowModal = await checkIfSkipAllowModal();
132
+ if (skipAllowModal) {
133
+ resolve({ code: "123456" }); // dummy code
134
+ return;
135
+ }
131
136
  await checkIfUserHasPasskeys();
132
137
  if (title) {
133
138
  customDialogTitle.value = title;
@@ -338,6 +343,24 @@
338
343
  });
339
344
  }
340
345
 
346
+
347
+ async function checkIfSkipAllowModal(){
348
+ try {
349
+ const response = await callAdminForthApi({
350
+ method: "GET",
351
+ path: "/plugin/twofa/skip-allow-modal",
352
+ });
353
+ if ( response.skipAllowed === true ) {
354
+ return true;
355
+ } else {
356
+ return false;
357
+ }
358
+ } catch (error) {
359
+ console.error('Error checking skip allow modal:', error);
360
+ return false;
361
+ }
362
+ }
363
+
341
364
  </script>
342
365
 
343
366
  <style scoped>
@@ -4,16 +4,27 @@
4
4
  "paths": {
5
5
  "@/*": [
6
6
  // "node_modules/adminforth/dist/spa/src/*"
7
- "../../../spa/src/*"
7
+ "../../../adminforth/spa/src/*"
8
8
  ],
9
9
  "*": [
10
10
  // "node_modules/adminforth/dist/spa/node_modules/*"
11
- "../../../spa/node_modules/*"
11
+ "../../../adminforth/spa/node_modules/*"
12
12
  ],
13
13
  "@@/*": [
14
14
  // "node_modules/adminforth/dist/spa/src/*"
15
15
  "."
16
16
  ]
17
17
  }
18
- }
18
+ },
19
+ "include": [
20
+ "./**/*.ts",
21
+ "./**/*.tsx",
22
+ "./**/*.vue",
23
+ "../**/*.ts",
24
+ "../**/*.tsx",
25
+ "../**/*.vue",
26
+ "../*.vue",
27
+ "../*.ts",
28
+ "../*.tsx"
29
+ ]
19
30
  }
package/dist/index.js CHANGED
@@ -25,6 +25,12 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
25
25
  var _a, _b, _c, _d;
26
26
  if (!confirmationResult)
27
27
  return { error: "Confirmation result is required" };
28
+ if (this.options.usersFilterToApply) {
29
+ const res = this.options.usersFilterToApply(opts.adminUser);
30
+ if (res === false) {
31
+ return { ok: true };
32
+ }
33
+ }
28
34
  if (confirmationResult.mode === "totp") {
29
35
  const code = confirmationResult.result;
30
36
  const authRes = this.adminforth.config.resources
@@ -487,6 +493,19 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
487
493
  }
488
494
  }),
489
495
  });
496
+ server.endpoint({
497
+ method: "GET",
498
+ path: "/plugin/twofa/skip-allow-modal",
499
+ handler: (_a) => __awaiter(this, [_a], void 0, function* ({ adminUser }) {
500
+ if (this.options.usersFilterToApply) {
501
+ const res = this.options.usersFilterToApply(adminUser);
502
+ if (res === false) {
503
+ return { skipAllowed: true };
504
+ }
505
+ }
506
+ return { skipAllowed: false };
507
+ }),
508
+ });
490
509
  server.endpoint({
491
510
  method: 'POST',
492
511
  path: `/plugin/twofa/verify`,
package/index.ts CHANGED
@@ -32,7 +32,12 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
32
32
  opts?: { adminUser?: AdminUser; userPk?: string; cookies?: any }
33
33
  ): Promise<{ ok: true } | { error: string }> {
34
34
  if (!confirmationResult) return { error: "Confirmation result is required" };
35
-
35
+ if (this.options.usersFilterToApply) {
36
+ const res = this.options.usersFilterToApply(opts.adminUser);
37
+ if ( res === false ) {
38
+ return { ok: true };
39
+ }
40
+ }
36
41
  if (confirmationResult.mode === "totp") {
37
42
  const code = confirmationResult.result;
38
43
  const authRes = this.adminforth.config.resources
@@ -538,6 +543,19 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
538
543
  }
539
544
  },
540
545
  });
546
+ server.endpoint({
547
+ method: "GET",
548
+ path: "/plugin/twofa/skip-allow-modal",
549
+ handler: async ({ adminUser }) => {
550
+ if ( this.options.usersFilterToApply ) {
551
+ const res = this.options.usersFilterToApply(adminUser);
552
+ if ( res === false ) {
553
+ return { skipAllowed: true };
554
+ }
555
+ }
556
+ return { skipAllowed: false };
557
+ },
558
+ });
541
559
  server.endpoint({
542
560
  method: 'POST',
543
561
  path: `/plugin/twofa/verify`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.7.4",
3
+ "version": "2.9.0",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",