@adminforth/two-factors-auth 7.0.0 → 7.0.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
@@ -21,5 +21,5 @@ custom/tsconfig.json
21
21
  custom/use2faApi.ts
22
22
  custom/utils.js
23
23
 
24
- sent 299,994 bytes received 324 bytes 600,636.00 bytes/sec
25
- total size is 298,743 speedup is 0.99
24
+ sent 300,012 bytes received 324 bytes 600,672.00 bytes/sec
25
+ total size is 298,778 speedup is 0.99
@@ -146,7 +146,7 @@ function onCopyClick(){
146
146
  }
147
147
 
148
148
  onMounted(async () => {
149
- coreStore.getPublicConfig()
149
+ coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false })
150
150
  const resp = await callAdminForthApi({
151
151
  path: '/plugin/twofa/initSetup',
152
152
  method: 'POST',});
@@ -146,7 +146,7 @@ function onCopyClick(){
146
146
  }
147
147
 
148
148
  onMounted(async () => {
149
- coreStore.getPublicConfig()
149
+ coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false })
150
150
  const resp = await callAdminForthApi({
151
151
  path: '/plugin/twofa/initSetup',
152
152
  method: 'POST',});
package/dist/index.js CHANGED
@@ -278,7 +278,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
278
278
  }
279
279
  const beforeLoginConfirmation = this.adminforth.config.auth.beforeLoginConfirmation;
280
280
  const beforeLoginConfirmationArray = Array.isArray(beforeLoginConfirmation) ? beforeLoginConfirmation : [beforeLoginConfirmation];
281
- beforeLoginConfirmationArray.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser, response, adminforth, extra, sessionDuration }) {
281
+ beforeLoginConfirmationArray.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser, adminforth, extra, sessionDuration }) {
282
282
  var _b;
283
283
  if (((_b = extra === null || extra === void 0 ? void 0 : extra.meta) === null || _b === void 0 ? void 0 : _b.loginAllowedByPasskeyDirectSignIn) === true) {
284
284
  return { body: { loginAllowed: true }, ok: true };
@@ -299,7 +299,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
299
299
  const userCanSkipSetup = this.options.usersFilterToAllowSkipSetup ? this.options.usersFilterToAllowSkipSetup(adminUser) : false;
300
300
  if (!secret) {
301
301
  newSecret = this.totpService.generateSecret(issuerName, userName);
302
- this.cookieService.setTotpTemporary(response, { userName, newSecret, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
302
+ this.cookieService.setTotpTemporary(extra.response, { userName, newSecret, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
303
303
  return {
304
304
  body: {
305
305
  loginAllowed: false,
@@ -309,7 +309,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
309
309
  };
310
310
  }
311
311
  else {
312
- this.cookieService.setTotpTemporary(response, { userName, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
312
+ this.cookieService.setTotpTemporary(extra.response, { userName, issuer: issuerName, pk: userPk, userCanSkipSetup, sessionDuration });
313
313
  return {
314
314
  body: {
315
315
  loginAllowed: false,
@@ -71,7 +71,7 @@ export class PasskeyRepository {
71
71
  resource: this.getCredentialResource(),
72
72
  recordId: passkeyRecord[this.getCredentialResourcePkField()],
73
73
  oldRecord: passkeyRecord,
74
- record: newRecord,
74
+ updates: newRecord,
75
75
  adminUser,
76
76
  });
77
77
  });
@@ -41,7 +41,7 @@ export class CookieService {
41
41
  const value = this.adminforth.auth.issueJWT(payload, 'temp2FA', period);
42
42
  this.adminforth.auth.setCustomCookie({
43
43
  response,
44
- payload: { name: TOTP_TEMP_COOKIE, value, expiry: undefined, expirySeconds: convertPeriodToSeconds(period), httpOnly: true },
44
+ payload: { name: TOTP_TEMP_COOKIE, value, expirySeconds: convertPeriodToSeconds(period), httpOnly: true },
45
45
  });
46
46
  }
47
47
  removeTotpTemporary(response) {
@@ -63,7 +63,7 @@ export class CookieService {
63
63
  const value = this.adminforth.auth.issueJWT({ challenge }, 'tempLoginPasskeyChallenge', ((_a = this.options.passkeys) === null || _a === void 0 ? void 0 : _a.challengeValidityPeriod) || '1m');
64
64
  this.adminforth.auth.setCustomCookie({
65
65
  response,
66
- payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true },
66
+ payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
67
67
  });
68
68
  }
69
69
  getRegisterPasskeyTemporary(cookies) {
@@ -82,7 +82,7 @@ export class CookieService {
82
82
  const value = this.adminforth.auth.issueJWT(payload, 'registerTempPasskeyChallenge', ((_a = this.options.passkeys) === null || _a === void 0 ? void 0 : _a.challengeValidityPeriod) || '1m');
83
83
  this.adminforth.auth.setCustomCookie({
84
84
  response,
85
- payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true },
85
+ payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
86
86
  });
87
87
  }
88
88
  setMfaGrace(response, hash) {
package/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AdminForthPlugin, suggestIfTypo, HttpExtra, RateLimiter } from "adminforth";
2
2
  import * as AdminForthRuntime from "adminforth";
3
- import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthAuth, IAdminForthHttpResponse } from "adminforth";
3
+ import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthAuth } from "adminforth";
4
4
  import { PluginOptions } from "./types.js"
5
5
  import { PasskeyService } from "./services/passkeyService.js";
6
6
  import { TotpService } from "./services/totpService.js";
@@ -331,7 +331,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
331
331
  const beforeLoginConfirmation = this.adminforth.config.auth.beforeLoginConfirmation;
332
332
  const beforeLoginConfirmationArray = Array.isArray(beforeLoginConfirmation) ? beforeLoginConfirmation : [beforeLoginConfirmation];
333
333
  beforeLoginConfirmationArray.push(
334
- async({ adminUser, response, adminforth, extra, sessionDuration }: { adminUser: AdminUser, response: IAdminForthHttpResponse, adminforth: IAdminForth, extra?: HttpExtra, sessionDuration?: string} )=> {
334
+ async({ adminUser, adminforth, extra, sessionDuration }: { adminUser: AdminUser, adminforth: IAdminForth, extra?: HttpExtra, sessionDuration?: string} )=> {
335
335
  if ( extra?.meta?.loginAllowedByPasskeyDirectSignIn === true) {
336
336
  return { body: { loginAllowed: true }, ok: true };
337
337
  }
@@ -353,7 +353,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
353
353
 
354
354
  if (!secret){
355
355
  newSecret = this.totpService.generateSecret(issuerName, userName);
356
- this.cookieService.setTotpTemporary(response, {userName, newSecret, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
356
+ this.cookieService.setTotpTemporary(extra.response, {userName, newSecret, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
357
357
 
358
358
  return {
359
359
  body:{
@@ -364,7 +364,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
364
364
  }
365
365
 
366
366
  } else {
367
- this.cookieService.setTotpTemporary(response, {userName, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
367
+ this.cookieService.setTotpTemporary(extra.response, {userName, issuer:issuerName, pk:userPk, userCanSkipSetup, sessionDuration });
368
368
 
369
369
  return {
370
370
  body:{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^22.10.7",
36
- "adminforth": "^3.32.0",
36
+ "adminforth": "^4.7.3",
37
37
  "semantic-release": "^24.2.1",
38
38
  "semantic-release-slack-bot": "^4.0.2",
39
39
  "typescript": "^5.7.3"
@@ -62,7 +62,7 @@ export class PasskeyRepository {
62
62
  resource: this.getCredentialResource(),
63
63
  recordId: passkeyRecord[this.getCredentialResourcePkField()],
64
64
  oldRecord: passkeyRecord,
65
- record: newRecord,
65
+ updates: newRecord,
66
66
  adminUser,
67
67
  });
68
68
  }
@@ -62,7 +62,7 @@ export class CookieService {
62
62
  const value = this.adminforth.auth.issueJWT(payload, 'temp2FA', period);
63
63
  this.adminforth.auth.setCustomCookie({
64
64
  response,
65
- payload: { name: TOTP_TEMP_COOKIE, value, expiry: undefined, expirySeconds: convertPeriodToSeconds(period), httpOnly: true },
65
+ payload: { name: TOTP_TEMP_COOKIE, value, expirySeconds: convertPeriodToSeconds(period), httpOnly: true },
66
66
  });
67
67
  }
68
68
 
@@ -84,7 +84,7 @@ export class CookieService {
84
84
  const value = this.adminforth.auth.issueJWT({ challenge }, 'tempLoginPasskeyChallenge', this.options.passkeys?.challengeValidityPeriod || '1m');
85
85
  this.adminforth.auth.setCustomCookie({
86
86
  response,
87
- payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true },
87
+ payload: { name: PASSKEY_LOGIN_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
88
88
  });
89
89
  }
90
90
 
@@ -102,7 +102,7 @@ export class CookieService {
102
102
  const value = this.adminforth.auth.issueJWT(payload, 'registerTempPasskeyChallenge', this.options.passkeys?.challengeValidityPeriod || '1m');
103
103
  this.adminforth.auth.setCustomCookie({
104
104
  response,
105
- payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true },
105
+ payload: { name: REGISTER_PASSKEY_TEMP_COOKIE, value, expirySeconds: 10 * 60, httpOnly: true },
106
106
  });
107
107
  }
108
108