@adminforth/two-factors-auth 1.10.1 → 1.10.2

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/index.js CHANGED
@@ -429,7 +429,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
429
429
  userVerification: ((_m = this.options.passkeys) === null || _m === void 0 ? void 0 : _m.settings.authenticatorSelection.userVerification) || "required"
430
430
  },
431
431
  });
432
- const value = this.adminforth.auth.issueJWT({ "challenge": options.challenge }, 'tempPasskeyChallenge', '10m');
432
+ const value = this.adminforth.auth.issueJWT({ "challenge": options.challenge, "user_id": adminUser.pk }, 'tempPasskeyChallenge', '10m');
433
433
  this.adminforth.auth.setCustomCookie({ response, payload: { name: "registerPasskeyTemporaryJWT", value: value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true } });
434
434
  return { ok: true, data: options };
435
435
  })
@@ -448,6 +448,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
448
448
  if (!decodedPasskeysCookies) {
449
449
  return { error: 'Invalid passkey token' };
450
450
  }
451
+ if (decodedPasskeysCookies.user_id !== adminUser.pk) {
452
+ return { error: 'Invalid user' };
453
+ }
451
454
  const settingsOrigin = (_b = this.options.passkeys) === null || _b === void 0 ? void 0 : _b.settings.expectedOrigin;
452
455
  const expectedOrigin = body.origin;
453
456
  const expectedChallenge = decodedPasskeysCookies.challenge;
package/index.ts CHANGED
@@ -455,7 +455,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
455
455
  userVerification: this.options.passkeys?.settings.authenticatorSelection.userVerification || "required"
456
456
  },
457
457
  });
458
- const value = this.adminforth.auth.issueJWT({ "challenge": options.challenge }, 'tempPasskeyChallenge', '10m');
458
+ const value = this.adminforth.auth.issueJWT({ "challenge": options.challenge, "user_id": adminUser.pk }, 'tempPasskeyChallenge', '10m');
459
459
  this.adminforth.auth.setCustomCookie({response, payload: {name: "registerPasskeyTemporaryJWT", value: value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true}});
460
460
  return { ok: true, data: options };
461
461
  }
@@ -473,6 +473,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
473
473
  if (!decodedPasskeysCookies) {
474
474
  return { error: 'Invalid passkey token' };
475
475
  }
476
+ if (decodedPasskeysCookies.user_id !== adminUser.pk) {
477
+ return { error: 'Invalid user' };
478
+ }
476
479
  const settingsOrigin = this.options.passkeys?.settings.expectedOrigin;
477
480
  const expectedOrigin = body.origin;
478
481
  const expectedChallenge = decodedPasskeysCookies.challenge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",